How can I check if the display is selected? - opengl

I'd like to check if an LWJGL Display is selected or not, i.e. if it is in the foreground.
Is there a Display.isInForeground() method?

Display#isActive
Returns:
true if window is active, that is, the foreground display of the operating system.
Or if you are using LWJGL 3 and GLFW the equivalent is glfwGetWindowAttrib with GLFW_FOCUSED.

Related

How to automatically select screen size in OpenGL

I have 2 screens. 1 is 1920*1080 and 2 screen is 1024*768. When the display 2 is detect my OpenGL output should be run in that display.
I tried with glutInitWindowPostion(500,100) but when screen 2 is not detect at time output will not display in display 1. Also, I try glutFullScreen() but it's not working.
How to do?
I am using Glut library for displaying window. I am using windows 7.
Switch to a window/context management library with display enumeration support like GLFW or SDL.

How to create a Qt Drop Shadow without using transparencies? (Because the window manager doesn't support it)

I'm building a UI in Qt 5.9 that needs to run on an X11 display. I'm trying to add drop shadows to my dialog windows - but they don't work over X11.
The approach I'm taking is from zeFree's answer in This Question. (Put everything in the window in one widget, set the window translucent, and create a dropshadow effect on the widget).
setAttribute(Qt::WA_TranslucentBackground); //enable Window to be transparent
QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect();
effect->setBlurRadius(5);
ui->widget->setGraphicsEffect(effect);
It works great in my redhat vm:
RedHat Dropshadow
But when I send to the X11 display I, it looks like the transparency isn't supported, and I get the shadow on black instead:
X11 Dropshadow
My question is: Is there a way to make my Dialogs project a drop shadow onto my main window instead of onto their own (transparent) background? My application will be full screen on the X11 display so I don't need to worry about shadow effects outside of the window.
Any answer that gives me a clean way to get a drop shadow effect on this X11 display will be accepted.
If your window manage doesn't support transparency you are out of luck IMO. At least with your current approach.
There is theoretically a way to fake it, provided you can grab the pixel values from the underlying window manager composite that is under your application, then draw those pixels from your application, filling the black void, with the shadow composed over that, and finally your GUI stuff.
There is also the more viable course of giving up on native windowed dialogs and fake the dialog using a regular floating widget. This has the disadvantage that it will only be able to move within the confines of your main window, but this way you will have complete control over the drawing and not fall victim to platform limitations.

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().

Does Displaying in FullScreen diable 'rendering' of other windows in GLUT

Currently developing an APP using C++.
I am displaying multiple sub-windows in a single main window.
When one of the subwindows is put in Full Screen Mode , does the rendering of the other windows stop?
does the rendering of the other windows stop?
That depends on the implementation. If the program is implemented correctly, then the rendering should stop only if the window is fully covered.
Some people like to update the window in a timer callback (which is a bad practice), and then it would continue to render even when covered.
glutDisplayFunc is called only when there is a need to refresh the window.

Windows not drawing above OpenGL windows

I have an application with an OpenGL window as a child window of the main window.
When I display a dialog box above the OpenGL window, it doesn't get drawn. It's like it's not getting WM_PAINT messages. If I can guess the title bar position of the dialog box, I can drag it and it's still responsive.
I realise this might be a vague question, but I was wondering if anyone else has seen this sort of behaviour before and knew of a solution?
I wondered if the Pixel Format Descriptor would make a difference - I had PFD_DRAW_TO_WINDOW, but changing to PDF_DRAW_TO_BITMAP didn't make any difference. I'm not sure what else I should be looking at?
Bugger. Should have given all the details. I was running Windows in a virtual machine on Mac OS X using Parallels. I upgrade from Parallels 3 to 4 and now everything is working fine. I suspect a Parallels video driver issue.
Thanks to all those who answered with suggestions.
Is your opengl window constantly rendering. It is possible that the 3D hardware is simply rendering into an overlay that is overdrawing your dialog box. If you position the dialog box so it overlaps your main window, can you see some of it?
Try to pause rendering into the main display to see if it effects the results.
You will also need to make sure that your window style ensures the results are clipped...
cs.style |= WS_CLIPSIBLINGS | WS_CLIPCHILDREN ;
You should check though all the items mentioned in this MSDN article, as it covers a lot of the basics for getting opengl rendering in a window correctly.
http://msdn.microsoft.com/en-us/library/ms970745.aspx
You may need to switch overlay off. It can be done via forcing back buffer presenting method to copy instead of swap.
Use wglChoosePixelFormatARB and one of parameters should be
WGL_SWAP_METHOD_ARB with value WGL_SWAP_COPY_ARB
This may seems stupid but are you sure your OpenGL window is not flagged "topmost" ?
Does the dialog box disappear also behind borders of your window or just behind the OpenGL rendering rectangle ?