openGL gl.glReadPixels -- at higher resolution than screen size - opengl

I'm trying to get the contents of a window, drawn in openGL, into a screenshot.
That window is at a set size (say 700 by 420), but I want to capture a screenshot of that window with an increased resolution of 1920 / 1080.
The full question is here, for blender:
https://blender.stackexchange.com/questions/128174/python-get-image-of-3d-view-for-streaming-realtime-eevee-rendering
under Edit #4, but this is essentially an openGL question:
Is it possible to get a higher resolution openGL screen of a window, without actually changing that window's resolution? (Similar to untity's screen recorder)?
A similar question was posted here: Need to improve resolution of screenshot from OpenGL, but the only answer says that changing the window resolution is the only solution.
I'm essentially trying to capture the 3D view in blender at a higher resolution than the current window size, but this same case can be applied to any window drawn with openGL that should be captured

Related

How to prevent direct2d “stretching” the view when window size changed?

I am rendering text with ID2D1HwndRenderTarget.
When there is a change of the UI window size, I want to prevent the stretch of the text being rendered - so it will be unchanged until I will directly make a rendering command.
On Direct2D documentation the behavior is described:
If EndDraw presents the buffer, this bitmap is stretched to cover the
surface where it is presented: the entire client area of the window
I know the ID2D1HwndRenderTarget::Resize method but I don't want to update the size immediately, just going to use it later on according to my program needs.
How can I ignore windows events to prevent this visual stretch?
You are already ignoring size change messages, and that's why surface size does not match client area size when presenting. You can try to offset this effect by setting target resolution according to "client area / current target size" factor, right before doing EndDraw(). I have no idea if that will help, or what will happen to uncovered window area outside of current target rectangle.

How to make a screenshot with changed render logical size in SDL?

You can set rendering resolution independently from window/fullscreen size with SDL_RenderSetLogicalSize, but all the methods of taking a screenshot gave either a black image, an image with exactly how it looks on screen (even with outside overlays, like RivaTuner Statistics Server), or the same, squished into left-upper corner of the screen. All screenshot are having window resolution instead of set rendering resolution. How to save a copy of viewport fresh after rendering into a file, so it would have set rendering resolution and won't have outside overlays?

SDL resetting glViewport

I'm testing supporting multiple resolutions in an application using SDL2 with OpenGL. To create my "letterbox" functionality I set my glViewport to an appropriate value and everything works perfectly.
However, if I create my window with the SDL_WINDOW_ALLOW_HIGHDPI flag set, whenever I move my window (after receiving the SDL_WINDOWEVENT_MOVED event) SDL modifies the viewport to the full size of the window, which can be verified by calling SDL_GL_GetDrawableSize during the event.
If I do not set SDL_WINDOW_ALLOW_HIGHDPI when creating the window, the viewport is not reset. I do believe this to be a bug, but cannot find anything through the SDL bugzilla so I thought to ask if anyone has seen similar behavior.
You may need to have a retina MacBook Pro to experience this behavior.
Just do what you should be doing anyway: Always re-/set the viewport at the beginning of drawing each frame. As soon as you want to implement a HUD, use framebuffer objects or similar things you'll have to set the viewport (several times) for drawing each frame.

How to determine size of the drawable area of an OpenGL 3.3 window using GLFW

I'm trying to create an game / application using GLFW and OpenGL 3.3. I'd like to be able to detect collision with the sides of the window, but it seems that the drawable area of the window differs from the size of the window set using glfwCreateWindow().
So my question is, how do I get that drawable area, ie. the size of the window minus the border? I'd rather not have to use the WinAPI so as to make it more cross-platform, and glfwGetWindowFrameSize() is in GLFW 3.1, which isn't completed yet.
Edit: My question makes it seem like I need to use GLFW do accomplish this, which isn't true. I just wanted to note that I'm using GLFW as a window / input handler.
You want glfwGetFramebufferSize.
glfwGetVideoMode returns the video mode of the specified monitor, not the size of your window. For fullscreen windows, they happen to be the same, but for other windows they are likely to be very different.
From the looks of it, you do not need to know the size of the window, I'm assuming in pixels? If you want to do collision detection with the border of the window, you just need to detect the the NDC of your vertex, and once it reaches x or y = (-1, 1) then you would've had a collision. Nonetheless, if you want to get the size in pixels of your OpenGL context then use glfwGetVideoMode().

Managing resolution in OpenGl

I use OpenGl. I would like to create a menu-control, but for this I need a constant resolution-control. I mean that I can set the position of a button by giving a coordinate, in 1024x768. But what if my window doesn't in it. And in full screen mode I hasn't found a method to change the resolution, nevertheless I can get it. So I got the screen width/height, the window width/height and 4 coordinates in 1024x768 for a rectangle. What should I do?