Strange stuff happening with OpenGL

Hi,

so basically what the problem is when I start my level, the first thing that I see are kinda random sprites for no reason. It happens only for a split second.

I tried to make a screenshot, but in that screen shot I couldn’t see what I saw seeing on the screen. I thought I failed to make a screenshot, so I recorded everything. It didn’t show up on the recording as well.

What might be causing this? I’m using VBO to render this. What might be causing this strange thing? I wanted to make a screenshot or something, but as stated above it doesn’t really work like that :smiley:

I don’t even know what to ask. Why would stuff be appearing on the screen and not on the Print Screen or recorded video?

EDIT_1:
It seems like tile sprites are being replaced by one of the animation sprites. It happens for 2 game ticks (60/s). I just don’t get it. If I was swapping sprites by mistake or something it would show up on the screen i think. This is like an error with opengl or something.

EDIT_2:
I tried recording few more times using different frame rates. I managed to record the problem. My recorder probably wasn’t catching the game once it was running at 60 fps. So now this is a problem with my rendering or something. That is a relief :stuck_out_tongue: Now I can fix it somehow! :smiley:
This is how it looks like :smiley:

EDIT_3:
The problem occurs when I spawn zombies! :smiley: The problem only lasts one frame.
EDIT_4:
I could just spawn 1 zombie behind the scenes before the game even starts rendering, but that wouldn’t really solve the problem. This is just kinda strange.
EDIT_5:
My Zombie class has static SpriteSheet which is just an opengl texture basically. It isn’t used anywhere. I think the problem is with texture binding. When I create 1st zombie, static texture get created, therefore binding itself to opengl. I still need to confirm this, but problem is probably with texture binding. My Tile sprite seems to be rendering at the same coordinates but from the other texture.
EDIT_6:
Yeap the problem is with binding. I have this “abstract” kinda class for rendering called screen. When I render a sprite, I try to set current texture to that of sprite. If the texture is already the same, I don’t do anything. If it is different, I have a reference to the last spritesheet I set. When I create textures, I don’t use screen class to set textures at all, therefore breaking it. In the other words, this is just an error of binding textures properly.

Hmm are you adding anything to your game that might be drawn say a rogue render call in one of the constructors?

Post some code. This isn’t an OpenGL issue obviously, so why wouldn’t you include code? This is a personal code issue, and no one can see your code unless you share it.

It seems to me that you are rendering and logic at the same time with two threads.

This is pretty big code. Would be messy if I started posting. + you wouldn’t even want to look at it. As I posted in the thread, this happens when I spawn first zombie. Obviously this has to do something with initializing static sprites or something.

This line in my texture class fixed everything! :smiley:

if(Screen.currentSpriteSheet != null) Screen.currentSpriteSheet.bind();