Reputation: 3781
I have seen this kind of functionality in DirectX apps only: when you resize the window, the rendering will also stretch accordingly, and it looks like it was actually a texture that was stretched.
How can i do this efficiently in OpenGL ? The purpose for this is to create a fullscreen application with native resolution, because its rather hard to choose lower resolution on LCD screens, and allow me to render with lower resolution to get higher FPS.
Upvotes: 2
Views: 1780
Reputation: 2818
You call glViewport() to tell OpenGL what part of the window (in pixels) will ultimately be rendered by OpenGL. You use a method like glFrustum(), glOrtho(), or glOrtho2D() in order to set the parameters of the "world" in which you are drawing in.
If you handle an event to tell you when the window is being resized, then you can call glViewport() again to update the size of your viewport accordingly.
So, if your world in square (for example), and your viewport is rectangular, then it will have the effect you are referring to (it will stretch accordingly, like it was actually a texture).
Upvotes: -1
Reputation: 474536
You will need to render to a texture or renderbuffer, then do a glBlitFramebuffer
to the actual default framebuffer. Then swap buffers as normal.
Upvotes: 2