Can You resize a window with OpenGL and SDL?

Can You resize a window with OpenGL and SDL?

One problem you probably have is, that resizing a window with SDL a new OpenGL context is created, which means that all the things you uploaded before (textures, vertex buffer objects) and state you set (like vertex array pointers) are lost. You need to reinitialize them if using SDL. If you want to keep them, don’t use SDL for window management.

What should be included in SDL opengl.h?

SDL_opengl.h, however, will include all of the headers required by a specific platform needed to use OpenGL. When compiling on Windows, for instance, SDL_opengl.h will include before GL/gl.h and GL/glu.h to avoid errors.

Can a SDL display resolution be changed on Linux?

One final note: on Linux the SDL-owned OpenGL context is never destroyed in the first place (as it should), and as such no special measures need to be taken on Linux when switching display resolutions. It just works! Email: martijn AT bytehazard DOT com

How does changevideomode ( ) work in OpenGL?

ChangeVideoMode() can later be called at any time. ChangeVideoMode will in turn calls SetVideoMode(), but before doing so creates a temporary GL context, and shares the application’s current resources with it. The OpenGL drivers will then notdestroy those resources once SDL destroys it’s own GL context.

Where do the drawing commands go in OpenGL?

Drawing commands and state management that influences drawing belongs in the drawing function. That is the following: If you want a robust OpenGL program never put them (only) into the resize handler. They belong with the other drawing commands. Thanks for contributing an answer to Stack Overflow!

How to adjust glviewport call in OpenGL?

See adjusted glViewport call above. Also, gluOrtho2D is your camera, essentially. Since you aren’t moving the camera or the object so much, you don’t need to change that (so it just uses the initial WIDTH and HEIGHT ).

How can I adjust for the window being resized?

I am drawing several shapes (such as circles) that are keyed off of the window height & width. Since the window always starts at a given size, they are drawn correctly, but when the window is resized, it messes the aspect ratio up. How can I draw the shapes properly, regardless of window size?