Question

I'm porting a small graphics engine from DirectX 9 to OpenGL. The engine uses SDL (now ported to 2.0) to manage input and window creation.

I want to know how to correctly handle window events for both OpenGL and DirectX. I'm interested in these for Desktop platforms (linux, OSX and windows)

  • Window resolution change
  • Full screen to windowed / windowed to fullscreen handling
  • Alt+tab handling -

I've tried to search through the net but information is quite not focused in one place. I imagine many others faced the same problem before.

Are there any resources to read guidelines on that kind of handling for my engine? Is it possible to handle resolution change without losing transfered resources to the renderer system in both OpenGL and DirectX?

Was it helpful?

Solution

  • Window resolution change

OpenGL itself requires no special treatment for this. Unfortunately SDL goes through a full window reinitialization, including the OpenGL context on a window size change, which means, that all OpenGL state objects (that is, textures, vertex buffers, shaders and so on) are lost.

This is however a limitation of SDL.

Personally I thus prefer GLFW for creating a OpenGL window and context. You can still use SDL for other things though (like audio, networking, image loading and such).

  • Full screen to windowed / windowed to fullscreen handling

The is effectively a window size change as well. See above.

  • Alt+tab handling -

OpenGL requires no special effort for this. Just minimize the window when Alt+Tab-ing out and stop the game loop. When the window gets restored just continue the game loop.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top