x11 - Opening a fullscreen OpenGL window -


i tring open opengl full screen window using glfw on linux red-hat. have desktop spans 2 monitors total resolution of 3840*1080.

i have 2 problems: 1. window opened on 1 monitor maximum window width of 1920 (the width of single monitor). 2. maximum height of window 1003 (which think height of screen minus height of task bar , top bar).

this code use open window:

if (glfwinit() == gl_false)     std::cout<< "unable initialize glfw\n"; glfwopenwindowhint(glfw_stereo, gl_false); if (glfwopenwindow(3840,1080,8,8,8,0,24,0,glfw_fullscreen) == gl_false)     std::cout<< "unable open window\n"; int width, height; glfwgetwindowsize(&width, &height); std::cout << "width = " << width << " height = " << height << "\n"; 

output: width = 1920 height = 1003

edit: used xrandr check available screen mode , got:

screen 0: minimum 3840 x 1080, current 3840 x 1080, maximum 3840 x 1080 default connected 3840x1080+0+0 0mm x 0mm 3840x1080 50.0*

edit2: have changed code open window using x11

int doublebufferattributes[] = { glx_drawable_type, glx_window_bit, glx_render_type,   glx_rgba_bit, glx_doublebuffer,  true,  /* request double-buffered color buffer */ glx_red_size,      1,     /* maximum number of bits per component    */ glx_green_size,    1,      glx_blue_size,     1,     none };  static bool waitfornotify( display *dpy, xevent *event, xpointer arg ) {     return (event->type == mapnotify) && (event->xmap.window == (window) arg); } int main( int argc, char *argv[] ) {     display              *dpy;     window                xwin;     xevent                event;     xvisualinfo          *vinfo;     xsetwindowattributes  swa;     glxfbconfig          *fbconfigs;     glxcontext            context;     glxwindow             glxwin;     int                   swamask;     int                   numreturned;     int                   swapflag = true;      /* open connection x server */  dpy = xopendisplay( null ); if ( dpy == null ) {     printf( "unable open connection x server\n" );     exit( exit_failure ); }  /* request suitable framebuffer configuration - try double  ** buffered configuration first */ fbconfigs = glxchoosefbconfig( dpy, defaultscreen(dpy),                                doublebufferattributes, &numreturned );  /* create x colormap , window visual matching first ** returned framebuffer config */ vinfo = glxgetvisualfromfbconfig( dpy, fbconfigs[0] );  swa.border_pixel = 0; swa.event_mask = structurenotifymask; swa.colormap = xcreatecolormap( dpy, rootwindow(dpy, vinfo->screen),                                 vinfo->visual, allocnone );  swamask = cwborderpixel | cwcolormap | cweventmask;  xwin = xcreatewindow( dpy, rootwindow(dpy, vinfo->screen), 0, 0, 3840, 1080,                       0, vinfo->depth, inputoutput, vinfo->visual,                       swamask, &swa ); xwindowattributes attt;  xgetwindowattributes( dpy,xwin, &attt); std::cout << "he = " << attt.height << " wi = " << attt.width << "\n";  /* create glx context opengl rendering */ context = glxcreatenewcontext( dpy, fbconfigs[0], glx_rgba_type,              null, true ); xgetwindowattributes( dpy,xwin, &attt); std::cout << "2he = " << attt.height << " wi = " << attt.width << "\n";   /* create glx window associate frame buffer configuration ** created x window */ glxwin = glxcreatewindow( dpy, fbconfigs[0], xwin, null ); xgetwindowattributes( dpy,xwin, &attt); std::cout << "3he = " << attt.height << " wi = " << attt.width << "\n";  /* map window screen, , wait appear */ xmapwindow( dpy, xwin ); xgetwindowattributes( dpy,xwin, &attt); std::cout << "4he = " << attt.height << " wi = " << attt.width << "\n";  xifevent( dpy, &event, waitfornotify, (xpointer) xwin ); xgetwindowattributes( dpy,xwin, &attt); std::cout << "5he = " << attt.height << " wi = " << attt.width << "\n";   /* bind glx context window */ glxmakecontextcurrent( dpy, glxwin, glxwin, context ); xgetwindowattributes( dpy,xwin, &attt); std::cout << "6he = " << attt.height << " wi = " << attt.width << "\n"; 

the output is:

he = 1080 wi = 3840 2he = 1080 wi = 3840 3he = 1080 wi = 3840 4he = 1080 wi = 3840 5he = 1003 wi = 1920 6he = 1003 wi = 1920 

it seems when window displayed size shrinks.

don't know glfw, perhaps it's buggy, x11 fullscreen windows don't work that. window manager worth salt force window fit (single, non-virtual) screen.

you want either bypass window manager (use overrideredirect window attribute), or ask wm cooperate (use window property _net_wm_state_fullscreen). first approach has numerous drawbacks, let's use second one. following program display window on display, , toggle full-screen mode:

#include <x11/x.h> #include <x11/xlib.h> #include <strings.h> #include <memory.h> #include <stdlib.h> #include <stdio.h>  int main () {     display* dis = xopendisplay(null);     window win = xcreatesimplewindow(dis, rootwindow(dis, 0), 0, 0, 10, 10,                                      0, blackpixel (dis, 0), blackpixel(dis, 0));      atom wm_state = xinternatom(dis, "_net_wm_state", false);     atom fullscreen = xinternatom(dis, "_net_wm_state_fullscreen", false);      xevent xev;     memset(&xev, 0, sizeof(xev));     xev.type = clientmessage;     xev.xclient.window = win;     xev.xclient.message_type = wm_state;     xev.xclient.format = 32;     xev.xclient.data.l[0] = 1;     xev.xclient.data.l[1] = fullscreen;     xev.xclient.data.l[2] = 0;      xmapwindow(dis, win);      xsendevent (dis, defaultrootwindow(dis), false,                     substructureredirectmask | substructurenotifymask, &xev);      xflush(dis);     /*sleep 5 seconds before closing.*/     sleep(5);     return(0);  } 

you use real screen dimensions window start, in order avoid resize animation effect.

i didn't try on multihead system because don't have one, on single display system works (covers panel, removes window decorations etc). please let me know if works you.

update multihead work, need use _net_wm_fullscreen_monitors property (see here). it's array of 4 integers should set this:

    atom fullmons = xinternatom(dis, "_net_wm_fullscreen_monitors", false);     xevent xev;     memset(&xev, 0, sizeof(xev));     xev.type = clientmessage;     xev.xclient.window = win;     xev.xclient.message_type = fullmons;     xev.xclient.format = 32;     xev.xclient.data.l[0] = 0; /* topmost monitor number */     xev.xclient.data.l[1] = 0; /* bottommost */     xev.xclient.data.l[2] = 0; /* leftmost */     xev.xclient.data.l[3] = 1; /* rightmost */     xev.xclient.data.l[4] = 0; /* source indication */      xsendevent (dis, defaultrootwindow(dis), false,                     substructureredirectmask | substructurenotifymask, &xev); 

with this, should able set fullscreen windows occupy single monitor, entire desktop, or (for more 2 monitors) in between.

i have not checked because don't have multihead system.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -