Hi,
i encounter a strange behavior if i want to open a full-screen window at my second monitor in a dual screen setup. Monitors are recognized correctly at first, but finally the wrong one shows up.
I’m on Linux, Python 3.6.10, pyopengl 3.1.5, glfw 3.3.2, pyglfw 1.11.0 - but i confirmed with pure c, see attached example (c code is not allowed as upload, so inline).
output is:
$ ~/bin/glfw_2screen_minimaldemo
found 2 monitors
1600x900
1920x1200
should use monitor 1 with size 1920x1200
have window of size 1600x900
have frame of size 1600x900
Thanks and all the best,
Uli
/*
# example to demonstrate that 2nd screen is not used as intended
# behaviour: screen_0 shows fullscreen black for entire 5 secs
# screen_1 does not change
# expected: screen_0 should stay as is with desktop and console
# screen_1 should show fullscreen black for entire 5 sec; then desktop again
# printed output shows, that second monitor is recognized.
# but not used at all.
# meanwhile:
# $ xrandr -q | grep '*'
# 1600x900 60.01*+ 59.99 59.94 59.95 59.82 40.00
# 1920x1200 59.95*+
*/
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
int main( void ){
// Initialize the library
if (!glfwInit()) {
printf("init failed");
exit(0);
}
int count;
GLFWmonitor** monitors = glfwGetMonitors(&count); // list available monitors: ok
printf("found %d monitors\n", count);
int m;
int msel = 1; // chose 2nd monitor
int mw, mh; // its width and height
for (m=0; m<count; m++) {
const GLFWvidmode* mode = glfwGetVideoMode( monitors[m] ); // show modes of each monitor: ok
printf( "%dx%d\n", mode->width, mode->height );
if(m==msel) {
mw = mode->width;
mh = mode->height;
}
}
GLFWwindow* window = glfwCreateWindow(mw, mh, "none", monitors[msel], NULL); // become active
if (!window) { // ok
// Window or OpenGL context creation failed
printf("create window failed");
glfwTerminate();
exit(0);
}
printf("should use monitor %d with size %dx%d\n", msel, mw, mh ); // requested values
glfwGetWindowSize(window, &mw, &mh); // != used values
printf("have window of size %dx%d\n", mw, mh );
glfwMakeContextCurrent(window);
glfwSwapBuffers(window);
glfwGetFramebufferSize(window, &mw, &mh);
printf("have frame of size %dx%d\n", mw, mh);
sleep(5); // wait log enough to be sure we do not alter something with heavy latency
glfwDestroyWindow(window); // end nicely
glfwTerminate();
exit(0);
}