PDA

View Full Version : Help With Texture Rendering



HarvP
09-02-2011, 05:16 PM
Hello all,

I'm working on a Tetris clone for my first solo project. I have gotten to where I can have single blocks drop from the top of the screen to the bottom. When the screen fills to the top the game ends and it switches back to the start menu state. When I re-enter the play game state the blocks don't render fully. Its like the texture has been unloaded. I've gone over the code that takes place when the states are switched and can find nothing that would change the texture in anyway. The first go through everything is fine and then any after that without exiting will do the same thing. Here are some pics to help explain.

Here is what it looks like on the first attempt
http://oi52.tinypic.com/11kgmxt.jpg

Here is the return to the start menu.
http://oi54.tinypic.com/24lieq1.jpg

Here is the second pass where the texture is now not rendering correctly.
http://oi55.tinypic.com/2rwsuo4.jpg


Any help is appreciated. Not sure why this is happening.

ZbuffeR
09-03-2011, 12:29 AM
Could be a lot of things, so try to reduce the code a lot while still showing this problem, then either the solution will be directly apparent to you or post this reduced code here if you still need help.
Some things to verify :
- textures are created only once for the whole life of the program
- clear both color and depth : glClear(GL_COLOR_BUFFER_BIT | GL_COLOR_BUFFER_BIT);

BionicBytes
09-03-2011, 03:06 AM
I had something similar happen to me like this once. It turned out to be some state which needed resetting. Ensure you have enabled and set EVERY peice of state and disabled all others prior to rendering to see what's the cause.
It could be another texture unit left accidentally enabled for example.

zeoverlord
09-03-2011, 08:09 AM
Most likely you just need to call glBindTexture(GL_TEXTURE_2D,block_texture_id); before rendering the blocks since it looks like your font texture is used instead of the block texture.
Alternatively check if when you load the font_texture you don't accidentally overwrite the block texture.

HarvP
09-03-2011, 12:31 PM
Thanks for the feedback guys.

The glBindTexture worked. Not sure why that fixed it since the collision which is based on the texture size was working fine.