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?
Related
I'm trying to do something like what Auslogics Disk Defrag does with its custom window:
As can be seen, the blurred semi transparent shadow surrounding the window is much darker than the standard one, so the program must be drawing it by itself. The problem is, I can't find a way to paint anything transparent around a window.
In an answer to a similiar question, someone suggested creating a slightly bigger transparent window (using WS_EX_LAYERED + SetLayeredWindowAttributes()) behind the actual application window, and then do the translucent drawing on the transparent one. Not only does it sound like an ugly hack, it doesn't actually work. If, for example, one tries to draw a semi transparent black rectangle on a transparent window via GDI+, alpha blending is applied to the shape's color over the window background color (which would also be the transparency color) and then the shape is drawn with the calculated color, which obviously is not the window transparency, resulting in an opaque rectangle.
The semi transparent shadow is actually done by Gaussian Blur of the black square.
You can use this effect to create glows and drop shadows and use the
composite effect to apply the result to the original image. It is
useful in photo processing for filters like highlights and shadows.
You can use the output of this effect for input into lighting effects,
like the Specular Lighting or Diffuse Lighting effects, because the
alpha channel is blurred, too and lighting effects use the alpha
channel to determine surface geometry as a height map.
This effect is used by the built-in Shadow effect.
Refer: Gaussian blur effect
Then remove the standard frame, the entire window is your client area, so you can draw shadow in the extended frame.
Refer: Drawing in the Extended Frame Window
I think I've found a solution that works for me. I was hoping I wouldn't have to create an extra window just for the shadow, but every method I could find or think of would require me to draw all the controls by myself and/or somehow correct their alpha values.
So, I'm using a layered window with per pixel alpha. I paint over it with Direct2D, or, alternatively, I use some PNGs with transparency for the edges and corners of the shadow and copy them on a memory DC. Either way I simply recreate the shadow with the right dimensions when the window is resized, and call UpdateLayeredWindowIndirect. Both methods seem to be working well on Windows 7 and 10, and so far I haven't found any glitches.
Preventing it from showing on the taskbar was a bit tricky. All the ways I know have drawbacks. What worked best for me was making the layered window owned by the main one. At least that way it will only be visible on the desktop where the program is actually running, unlike other alternatives which would force it to show on every virtual desktop. Finally, because I disable that window, I interact with it by processing WM_SETCURSOR.
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
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?
I'm working on a project using JOGL API.
Now I am stuck at a point that is the followed:
-I run the program and it shows a Canvas divided in 4 viewPorts. The objective of the project is basically in each of the viewPorts we need to "project" an object from 4 diferent points of view. But first, we need to when clicking [1,2,3,4] to "expand"/"full-screen" the matched ViewPort.
My idea is when clicking any number create a new viewPort like this:gl.glViewport(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT). But this only creates a new viewPort with the size of the canvas.
How can I expand the "content" of any of the 4 viewPort to "enter" that new viewPort?
I think you've got confused what glViewport does. I don't know what you think it does (not), but what it's specified to do is, to set the portion of the OpenGL window, to which to map the post-projection (NDC) space. Or in layman terms, you use it to determine where in the window things get drawn. If you want to render full screen: Make the window full screen and set the viewport to the window size.
If you want to "expand" an existing drawing, you have to set the proper viewport and redraw the parts in question.
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().