Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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_RGBA_16_SNORM,32,32, 0, GL_RGBA, GL_BYTE,0);


                    }

                            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);"));

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

glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, width1, height1);
nResult |= GL_ERROR_CHECK((GL_NO_ERROR, "glBindRenderbuffer(GL_RENDERBUFFER, depth);"));

glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth);
nResult |= GL_ERROR_CHECK((GL_NO_ERROR, "glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth);"));
}

    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.

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?

share|improve this question
    
What kind of corruption? Do you have images? –  Jari Komppa Jan 9 '13 at 21:43
    
@jari komppa Sometimes it renders black cube w/o any texture while sometimes it renders cube with uneven red color with black patches.. –  user1737197 Jan 10 '13 at 2:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.