Switching between a window and fullscreen

My program will run either in a window or fullscreen quite happily. However, I can’t seem to switch successfully between the two.
I tried killing my window and recreating it with the new settings, and although this worked, I ended up with my objects ‘doubling’: I had two copies of each object I had made. One set continued properly, and the rest were all in the same position and did not move.

Any ideas? Is there something I’ve missed?


Do you clear the window before you draws to it?

noo…how? I know no win32 code at all yet…

Check out the nehe.gamedev.net website tutorial, it’ll show you how to do it gracefully.

I mean the buffer that OpenGL is rendering to and is displayed in the window. No win32 specific code is needed for doing that.

There’s a number of things that could cause that. nvidia_linux was talking about using glClear(), I think. Another thing that could cause that has to do with how you store your objects. If for instance, you store all your objects in a linked list and when you are re-creating the window you re-create those objects and store them in the linked list again and somehow only the new ones get updated positions.

Thanks for the suggestions, I’ll look into it.

I tried clearing it - makes no difference. I’m not using linked lists, I’m using simple arrays… I don’t see how they could be causing it. I’m stuck .

You should not get stuck on something like this. Try different things. Some suggestions:

  • Compare your code with the NeHe tutorials
  • Does resizing works?
  • Clear the buffer each frame

“Clear the buffer each frame” <-- Am doing
“Compare code with the Nehe tutorials” <-- Can find no obvious differences
“Does resizing work?” <-- Yes, but I still have all the extra objects. It is actually rendering them.

If you are clearing the scene then the only reason that the objects would still be showing is if you are telling them to show somewhere. So somewhere you must be making duplicates of your objects and not moving the old copies of them. There is not much anyone can tell you without taking a look at a lot more code.

I can’t see how that’s happening, although it seems to be the only reasonable explanation. I’m using arrays to hold object information, and a simple for() to go through and show each object. Since it only goes through a set amount of objects each time I’m not sure how it’s happening.