How to automatically select screen size in OpenGL - c++

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.

Related

SDL2 Fullscreen resolution issue (extending render over second screen)

I am using multiple monitors on my PC. One of them is a TV. When I launch my application on my regular monitors, the application gets scaled properly.
However, when I run the application in fullscreen on my TV, the resolution will be too large and the output shows partially on another screen (see the blue colored output in my screenshot).
The TV is connected via HDMI and uses the same resolution as the other screens (1920x1080). It seems to be a software issue, because the output is partially visible on another screen.
I am using the following code to toggle fullscreen mode:
SDL_SetWindowFullscreen( m_Window, SDL_WINDOW_FULLSCREEN );
Any ideas on how to solve this issue?
UPDATE
When I make the TV my main display in Windows, it seems to fit properly on the TV. However, it still shows partially on the other screen (but this time it shows twice) and the mouse positioning is incorrect on the TV. Maybe the resolution is changed differently?
UPDATE 2
Windows 10 allows font sizes to be changed on a monitor. This is why my resolution detection in SDL2 identified a different resolution for my TV. Now I need to find a way to work around this.

How can I check if the display is selected?

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.

Windows 8 tablet does not display TabTip (on-screen keyboard) on top of Qt OpenGL application

I have a full screen QT OpenGL application which needs to display the virtual keyboard (tabTip.exe) when input textboxes are entered. The problem I'm facing is that the virtual keyboard appears behind the application when the keyboard is invoked. I have tried many different things and found that the only way I can make it appear in front, is if my window is not fullscreen (e.g. making it 1 pixel less than full screen in the width and/or height). If I have the tablet in portrait mode this also still displays the keyboard even in full screen.
Now I'm trying to figure out if this is a driver issue, Qt issue, OpenGL issue or general windows issue.
Any suggestions?
Update:
I have investigated this a bit further and I think I see what's going on.
Windows 8, upon detecting that the monitor rotation is set to zero, and that it has an OpenGL window that matches the desktop resolution and covers the whole screen, kicks into legacy mode that blocks any Windows 8 themed animations from running (including virtual keyboard).
Do you have any suggestions on how I can stop windows from doing this? DwmEnableComposition has been removed in windows 8.

Creating a program that creates a full screen overlay

I want to write a program that would create a transparent overlay filling the entire screen in Windows 7, preferably with C++ and OpenGL. Though, if there is an API written in another language that makes this super easy, I would be more than willing to use that too. In general, I assume I would have to be able to read the pixels that are already on the screen somehow.
Using the same method screen capture software uses to get the pixels from the screen and then redrawing them would work initially, but the problem would then be if the screen updates. My program would then have to minimize/close and reappear in order for me to be able to read the underlying pixels.
Windows Vista introduced a new flag into the PIXELFORMATDESCRIPTOR: PFD_SUPPORT_COMPOSITION. If the OpenGL context is created with an alpha channel, i.e. AlphaBits of the PFD is nonzero, the alpha channel of the OpenGL framebuffer is respected by the Windows compositor.
Then by creating a full screen, borderless, undecorated window you get this exakt kind of overlay you desire. However this window will still receive all input events, so you'll have to do some grunt work and pass on all input events to the underlying windows manually.

get xorg.conf serverLayout with c++

I am currently working on a multi window application that spans over multiple screens. The software is written with xlib and runs on ubuntu 10.10, gnome desktop.
To get the position of every window I'd like to access the /etc/X11/xorg.conf file, expecially the section SeverLayout. It looks somehow like this:
Section "ServerLayout"
Identifier "aticonfig Layout"
Screen "screen0" 0 0
Screen "screen1" 1920 0
Screen "screen2" 3840 0
Screen "screen3" 5760 0
EndSection
I'd like to get the X values of each screen (0, 1920, ... ) Does xlib somehow provide access to this information?
thanks
Information about layout of multiple monitors in X, especially when they're combined into a single logical screen, is available via the libXrandr and libXinerama API's. Unfortunately, the multi-screen API's added to libXrandr in version 1.2 aren't covered in the man page, but require looking at the extension spec and Xrandr.h header file.
You can use XWidthOfScreen and XHeightOfScreen functions.
Use XScreenCount (to get number of screens) and XScreenOfDisplay to get appropriate screen structure.
A better way is to get the root window of a screen and parse it's geometry using XParseGeometry function.