Help With Texture Rendering

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

Here is the return to the start menu.

Here is the second pass where the texture is now not rendering correctly.

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

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

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.

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.

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.