PDA

View Full Version : glFramebufferTexture2D gives corruption with cube map textures



debonair
12-27-2012, 01:26 AM
I am using glFramebufferTexture2D with cube map textures but it gives corruption in texture.
draw_cube() function works perfectly when i draw that on default framebuffer.




GLenum types[]={GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z };


GLuint Fboid;
glGenTextures(1, &id1);
nResult |= GL_ERROR_CHECK((GL_NO_ERROR, "glGenTextures(1, &id1);"));

glBindTexture(*target11, id1);
nResult |= GL_ERROR_CHECK((GL_NO_ERROR, "glBindTexture(*target11, id1);"));

glGenFramebuffers(1, &Fboid);
nResult |= GL_ERROR_CHECK((GL_NO_ERROR, "glGenFramebuffers(1, &Fboid);"));

GLint fl=0;

switch(*target11)
{

case GL_TEXTURE_CUBE_MAP:
for(int i=0;i<6;i++)
{
glTexImage2D(types[i], 0, GL_RGBA16_SNORM,32, 32, 0, GL_RGBA, GL_BYTE,0);
nResult |= GL_ERROR_CHECK((GL_NO_ERROR, "glTexImage2D(types[i], 0, *format,width1, height1, 0, GL_RGBA, GL_BYTE,0);"));


}
if(*mipmap==1)
{

glGenerateMipmap(*target11);
nResult |= GL_ERROR_CHECK((GL_NO_ERROR, "glGenerateMipmap(*target11);"));
glTexParameterf(*target11, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
}
else

glTexParameteri(*target11, GL_TEXTURE_MIN_FILTER,GL_NEAREST);
nResult |= GL_ERROR_CHECK((GL_NO_ERROR, "glTexParameteri(*target11, GL_TEXTURE_MIN_FILTER,GL_NEAREST);"));

glTexParameteri(*target11, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
nResult |= GL_ERROR_CHECK((GL_NO_ERROR, "glTexParameteri(*target11, GL_TEXTURE_MAG_FILTER, GL_NEAREST);"));

glTexParameteri(*target11, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
nResult |= GL_ERROR_CHECK((GL_NO_ERROR, "glTexParameteri(*target11, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);"));

glTexParameteri(*target11, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
nResult |= GL_ERROR_CHECK((GL_NO_ERROR, "glTexParameteri(*target11, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);"));


break;


}
GLint framebuffer;
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING,&framebuffer);
nResult |= GL_ERROR_CHECK((GL_NO_ERROR, "glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING,&framebuffer);"));

glBindFramebuffer(GL_FRAMEBUFFER, Fboid);
nResult |= GL_ERROR_CHECK((GL_NO_ERROR, "glBindFramebuffer(GL_FRAMEBUFFER, Fboid);"));

switch(*target11)
{


case GL_TEXTURE_CUBE_MAP:
for(int i=0;i<6;i++)
{
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER,GL_COLO R_ATTACHMENT0,types[i],id1,0);
nResult |= GL_ERROR_CHECK((GL_NO_ERROR, "glFramebufferTexture1D(GL_DRAW_FRAMEBUFFER,GL_COLO R_ATTACHMENT0,*target11,id1,0);"));
draw_cube(fl);
}
break;
}
unsigned int status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
switch(status)
{
case GL_FRAMEBUFFER_COMPLETE: tdkPrintf("GL_FRAMEBUFFER_COMPLETE\n"); break;
case 0x8CDB: tdkPrintf("GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER\n"); break;
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: tdkPrintf("GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT\n"); break;
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: tdkPrintf("GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT\n"); break;

case GL_FRAMEBUFFER_UNSUPPORTED: tdkPrintf("GL_FRAMEBUFFER_UNSUPPORTED\n"); break;
default: tdkPrintf("Unknown issue (%X).\n",status); break;
}




glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
nResult |= GL_ERROR_CHECK((GL_NO_ERROR, "glBindFramebuffer(GL_FRAMEBUFFER, 0);"));

glUseProgram(shader_data.psId);
nResult |= GL_ERROR_CHECK((GL_NO_ERROR, "glUseProgram(shader_data.psId)"));

glViewport(0, 0, GetViewportWidth(), GetViewportHeight());
nResult |= GL_ERROR_CHECK((GL_NO_ERROR, "glViewport(0, 0, GetViewportWidth(), GetViewportHeight());"));

cube()
}

the issue occurs only for cub map textures.
for GL_TEXTURE_2D it works perfectly fine. i verified the shaders also.

debonair
01-09-2013, 10:30 AM
cubemap textures with glFramebufferTexture2D with above code gives currption on IMG driver but works fine with AMD driver. Is there any implementation difference for it or IMG driver is buggy?