What happens when you resize a window in OpenGL?

What happens when you resize a window in OpenGL?

Remember that OpenGL is a state machine! 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.

How to draw relative to screen size in OpenGL?

You would have to init window size and set Ortho to the size of the screen (current display resolution), then draw relative to the size of the window. This is basic template that I use…

What happens if you delete glutdisplayfunc in OpenGL?

My glutDisplayFunc and glutReshapeFunc are below. As it is, the drawing disappears when the window is resized. If I delete the glClear () from displayFunc (), new pixels don’t “initialize” and there are clipping problems.

Can you use SDL for window management in OpenGL?

If you want to keep them, don’t use SDL for window management. I recommend GLFW. is the most common anti pattern found in beginners OpenGL code. Drawing commands and state management that influences drawing belongs in the drawing function.

How to change the size of the SDL window?

In the switch, use the flag SDL_WINDOWEVENT_RESIZED if you want only the final size of the window or SDL_WINDOWEVENT_SIZE_CHANGED if you want all the sizes between the first and the final. To finish, update your own camera with the new window width and height. Thanks for contributing an answer to Stack Overflow!

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!