Strange missing texture

Started by Kajos, February 17, 2013, 14:55:28

Previous topic - Next topic

Kajos

Hi,

I would like to post a potential bug, I have the newest drivers for a AMD A10 5800K setup. Perhaps it is indeed a problem with AMD's apu; I read somewhere it happened in Modern Warfare as well (random read on the internet).

     
for (int side = 0; side < 2; side++)
        {
            
            glPushAttrib(GL_ALL_ATTRIB_BITS);
            glBindTexture(GL_TEXTURE_2D, 0);
            glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, modelsFboId[side]);

            glViewport(0,0,screenWidth,screenHeight);
            glMatrixMode(GL_PROJECTION);
            glLoadIdentity();
            gluPerspective(SCREEN_FOV, SCREEN_RAT, NEAR, FAR);
            glMatrixMode(GL_MODELVIEW);
            glLoadIdentity();
            glShadeModel(GL_SMOOTH);
            glHint(GL_PERSPECTIVE_CORRECTION_HINT,
                GL_NICEST);
            glDisable(GL_BLEND);
            glEnable(GL_DEPTH_TEST);
            glDepthFunc(GL_LESS);
            glDepthMask(true);
            glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
            glClearDepth(1.0f);
            glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

            glLoadIdentity (); 

            camera.look();
                
            drawObject();

            glDisable(GL_DEPTH_TEST);
            glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

            glPopAttrib();
        }

I loop over two fbo's which are both created in a loop as well. The fbo's work fine, however the second iteration the texture doesn't want to bind. I tried switching to different active texture for the second iteration, I have a shader which I disabled, I tried setting the clientactivetexture as well. If I skip the first iteration nothing changes for the second If I skip the first iteration the second works. When I attach a color instead of a texture the object DOES show (it doesn't show at all with the texture bound).

I tried tracking down this bug for a good two days now to no avail.


 
    for (int side = 0; side < 2; side++) {
            modelsFboId[side] = glGenFramebuffersEXT();										
            modelsFboTextureId[side] = glGenTextures();										
            modelsDepthRenderBufferId[side] = glGenRenderbuffersEXT();

            glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, modelsFboId[side]); 	

            glBindTexture(GL_TEXTURE_2D, modelsFboTextureId[side]);								
            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);						
            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);			
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, screenWidth, screenHeight, 0,GL_RGBA, GL_INT, (java.nio.ByteBuffer) null);	
            glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_TEXTURE_2D, modelsFboTextureId[side], 0); 

            glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, modelsDepthRenderBufferId[side]);         
            glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, screenWidth, screenHeight);
            glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,GL_DEPTH_ATTACHMENT_EXT,GL_RENDERBUFFER_EXT, modelsDepthRenderBufferId[side]); 
            glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
          }


I do not get any errors out of opengl. I will to try to recreate the bug in a project and post it if that is necessary.

Thanks for the help in advance, this is really frustrating to me!

EDIT: Cleaned up matrix inits
EDIT2: I tried this with another computer as well, exact same problem.


Fool Running

Quote from: Kajos on February 18, 2013, 11:25:48
Bump
LOL, this isn't a very active forum. Give us more then 20 hours to respond.  :P

As to your problem, it looks very strange to me that you are clearing the screen (and doing all your perspective settings, etc.) in your loop.
Try something more like:
glViewport(0,0,screenWidth,screenHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(SCREEN_FOV, SCREEN_RAT, NEAR, FAR);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glShadeModel(GL_SMOOTH);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glDepthMask(true);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClearDepth(1.0f);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glLoadIdentity (); 
camera.look();

for (int side = 0; side < 2; side++)
{
            glPushMatrix(); // You may not need the push/pop of the matrix depending on what your draw code does.
            glPushAttrib(GL_ALL_ATTRIB_BITS);
            glBindTexture(GL_TEXTURE_2D, 0);
            glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, modelsFboId[side]);

            drawObject();

            glPopAttrib();
            glPopMatrix();
}

glDisable(GL_DEPTH_TEST);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

Kajos

Hi, no matter, I solved it! :) The loop is fine I think, it needs to render to two different fbo's, however I found that Slick needs to unbind textures for some (unknown to me) reason. TextureImpl.unbind() solved it.