Spaces:
Runtime error
Runtime error
{ | |
"ticketNumber" : "1027878", | |
"reporterName" : "buaawkp", | |
"rankPoints" : "1345", | |
"resolutionStatus" : "", | |
"ticketName" : "TDA2HG: [Opengl] -- the cube usage in fbo", | |
"rankName" : "Expert", | |
"replies" : "", | |
"views" : "", | |
"queryText" : "Part Number: TDA2HG Other Parts Discussed in Thread: TDA2 hi: I have a question about the usage of cubemap in fbo; the simple code as bellow: { glGenFramebuffers(1, &fboID); glBindFramebuffer(GL_FRAMEBUFFER,fboID); glGenTextures(1, &cubemapID); glBindTexture(GL_TEXTURE_CUBE_MAP, cubemapID); for (unsigned int i = 0; i < 6; ++i) { glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr); } glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glUniform.. //update the uniform variable glViewport(0, 0, 256, 256); for (unsigned int i = 0; i < 6; ++i) { glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, cubemapID, 0); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { printf(\"glCheckFramebufferStatus error!\\n\"); } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); renderCube(); } } when i test the code, it works well on windows, but when i move it to the tda2 platform, the question is comming, sometimes the effiect is black , or is white, or white and black , or other colors, it's change every time. how is this? and how to resolved it? thanks", | |
"imageList" : null, | |
"partNumber" : "NA", | |
"allResponseList" : [ { | |
"contentId" : "", | |
"userName" : "Hemant Hariyani", | |
"rankPoints" : "8385", | |
"rankName" : "TI__Expert", | |
"date" : "", | |
"userId" : "/members/4658", | |
"content" : "Hello, Can you try and see if this works: // Setup texture for cubemap\r\n glGenTextures(1, &textureCubeMap);\r\n char buffer0[CUBEMAP_TEX_LEN * CUBEMAP_TEX_LEN * 6];\r\n\r\n glBindTexture(GL_TEXTURE_CUBE_MAP, textureCubeMap);\r\n memset((void *)buffer0, 0x50, CUBEMAP_TEX_LEN*CUBEMAP_TEX_LEN*6);\r\n for(GLuint i = 0; i < 6; i++)\r\n {\r\n glTexImage2D(\r\n GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,\r\n 0, GL_RGBA8, CUBEMAP_TEX_LEN, CUBEMAP_TEX_LEN,\r\n 0, GL_RGBA, GL_UNSIGNED_BYTE, (char *)buffer0\r\n );\r\n }\r\n\r\n glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r\n glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r\n glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);\r\n glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);\r\n glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);\r\n\r\n // Setup Framebuffer for cubemap\r\n glGenFramebuffers(1, &fbCubeMap);\r\n \r\n \r\n // Rendering part\r\n GLint current_fbo;\r\n glGetIntegerv(GL_FRAMEBUFFER_BINDING, ¤t_fbo);\r\n glBindFramebuffer(GL_FRAMEBUFFER, fbCubeMap);\r\n \r\n // Render to cubemap\r\n for (int i = 0; i < 6; i++)\r\n\t{\r\n glFramebufferTexture2D(GL_FRAMEBUFFER,\r\n\t\t GL_COLOR_ATTACHMENT0,\r\n\t\t GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,\r\n\t\t textureCubeMap,\r\n\t\t 0);\r\n\t glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);\r\n\t //.... draw/render to cube map surface\r\n\t}\r\n\t\r\n\t// Bind the original frame buffer\r\n\tglBindFramebuffer(GL_FRAMEBUFFER, current_fbo);\r\n\t\r\n\t// Use cubemap texture\r\n\tglBindTexture(GL_TEXTURE_CUBE_MAP, textureCubeMap);\r\n\r\n //... draw to the final framebuffer using cubemap\r\n // In the shader code, use samplerCube to sample texture\r\n // e.g:\r\n // uniform samplerCube skybox;\r\n // ...\r\n // vec4 colorval = texture(skybox, direction);\r\n \r\n\r\n \r\n \r\n\t \r\n\r\n\r\n\r\n \r\n\r\n\r\n If it still doesn't work, can you try and use glGetError to check for any errors? Regards Hemant", | |
"imageList" : null | |
} ], | |
"tags" : [ ], | |
"fourmType" : "processors-forum" | |
} |