PDA

View Full Version : render to texture, ordering help!



bensta00
06-19-2004, 08:59 AM
Hi, as part of a project I am trying to project textures onto a plane, then render the plane, then using glCopyTexImage2D() I grab the screen, copy to a texture, and project this texture onto another plane, and finally render this to screen, this as my visual output.

I first coded it as follows...



setupPixelShader();
ProjectTex();
releasePixelShader();
glCopyTexImage2D(to new grabbed texture);
projectGrabbedTex();What seems to happen is the screengrabbed texture is rendered first, then the pixelshaded textures are projected and rendered on top. This seems to be in the wrong order to me?!

So I tried doing it the other way round,



projectGrabbedTexture();
enablePixelShader();
ProjectText();
disablePixelShader();
glCopyTexImage2D(to grabbed texture);
Now the grabbed texture is rendered on top, as I want, however the texture contains the image of the grabbed texture. Hope this makes sense!

Basically I am wondering what I can do? I have no idea why they are being rendered in the wrong order, and it's probably me being stupid, that's why I've posted in the beginner forum!!

Any help would be VERY gratefully received!!

Thanks,

Ben.

bensta00
06-19-2004, 09:38 AM
I've just found that my program works if I call glFlush(). Now I have to find out why...! :-)