Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: glFramebufferTexture2D gives corruption with cube map textures

Threaded View

  1. #1
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    190

    glFramebufferTexture2D gives corruption with cube map textures

    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.

    Code :
     
        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_COLOR_ATTACHMENT0,types[i],id1,0);
        					nResult |= GL_ERROR_CHECK((GL_NO_ERROR, "glFramebufferTexture1D(GL_DRAW_FRAMEBUFFER,GL_COLOR_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.
    Last edited by debonair; 12-27-2012 at 10:49 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •