I don’t use the function you stippled. With some Internet searches, you’ll be able to find out good sources examples about how to switch between fullscreen and window mode, as for creating directly a window/fullscreen window.
The code is more complex at first glances, but it’s not so hard to understand.
Here is some code I was able to find on my old working codes. There might not have all things needed, but there’s almost all.
class WinAttr
{
public:
int x, y;
uint width, height;
uint depth;
bool fullscreen;
char *name;
XSetWindowAttributes attributes;
int *glx_attr;
WinAttr()
{
glx_attr= new int[11];
glx_attr[0]= GLX_RGBA;
glx_attr[1]= GLX_DOUBLEBUFFER;
glx_attr[2]= GLX_RED_SIZE;
glx_attr[3]= 4;
glx_attr[4]= GLX_GREEN_SIZE;
glx_attr[5]= 4;
glx_attr[6]= GLX_BLUE_SIZE;
glx_attr[7]= 4;
glx_attr[8]= GLX_DEPTH_SIZE;
glx_attr[9]= 16;
glx_attr[10]= None;
name= new char[14];
strcpy( name, "Window on GLX");
width= 640;
height= 480;
x=0; y=0;
depth= 24;
fullscreen= false;
}
void SetXWAttr( XSetWindowAttributes& a)
{ attributes= a;}
};
class Window
{
protected:
Display *display;
Window window;
GLXContext context;
XVisualInfo *visual;
int screen;
XF86VidModeModeInfo mode_info;
WinAttr attributes;
public:
Window(){}
bool CreateWindow();
};
bool Window::CreateWindow()
{
Colormap cmap;
int dw, dh;
int i;
int glx_rel_maj, glx_rel_min;
int vid_rel_maj, vid_rel_min;
XF86VidModeModeInfo **modes;
int mode_num;
int best_mode= 0;
Atom wm_delete;
uint border_dummy;
Window win_dummy;
display= XOpenDisplay( 0);
screen= DefaultScreen( display);
XF86VidModeQueryVersion( display, &vid_rel_maj, &vid_rel_min);
XF86VidModeGetAllModeLines(display, this->screen, &mode_num, &modes);
this->mode_info= *modes[0];
for( i=0; i< mode_num; i++)
if( ( modes[i]->hdisplay==attributes.width) && ( modes[i]->vdisplay== attributes.height))
best_mode= i;
this->visual= glXChooseVisual( display, screen, attributes.glx_attr);
if( !visual)
return false;
glXQueryVersion( display, &glx_rel_maj, &glx_rel_min);
this->context= glXCreateContext( display, visual, 0, GL_TRUE);
cmap= XCreateColormap( display,
RootWindow( this->display,
this->visual->screen), this->visual->visual, None);
this->attributes.attributes.colormap= cmap;
this->attributes.attributes.border_pixel= 0;
if( attributes.fullscreen){
XF86VidModeSwitchToMode( this->display, this->screen, modes[best_mode]);
XF86VidModeSetViewPort( this->display, this->screen, 0, 0);
dw= modes[best_mode]->hdisplay;
dh= modes[best_mode]->vdisplay;
XFree( modes);
attributes.attributes.override_redirect= true;
attributes.attributes.event_mask=
ExposureMask | KeyPressMask |
ButtonPressMask | StructureNotifyMask;
this->window= XCreateWindow( this->display,
RootWindow( this->display,
this->visual->screen), 0, 0, dw, dh, 0,
this->visual->depth, InputOutput,
this->visual->visual, CWBorderPixel |
CWColormap | CWEventMask |
CWOverrideRedirect, &attributes.attributes);
XWarpPointer( this->display, None, this->window, 0,0,0,0,0,0);
XMapRaised( this->display, this->window);
XGrabKeyboard( this->display, this->window,
true, GrabModeAsync, GrabModeAsync,
CurrentTime);
XGrabPointer( this->display, this->window,
true, ButtonPressMask, GrabModeAsync,
GrabModeAsync,this->window, None,
CurrentTime);
}
else{
attributes.attributes.event_mask=
ExposureMask | KeyPressMask |
ButtonPressMask | StructureNotifyMask;
this->window= XCreateWindow( this->display,
RootWindow( this->display,
this->visual->screen), 0,
0,attributes.width, attributes.height, 0,
this->visual->depth, InputOutput,
this->visual->visual,CWBorderPixel |
CWColormap | CWEventMask |
CWOverrideRedirect, &attributes.attributes);
wm_delete= XInternAtom( this->display, "WM_DELETE_WINDOW", true);
XSetWMProtocols( this->display, this->window, &wm_delete, 1);
XSetStandardProperties( this->display,
this->window, attributes.name,
attributes.name, None, NULL, 0, NULL);
XMapRaised( this->display, this->window);
}
glXMakeCurrent( this->display, this->window, this->context);
XGetGeometry( this->display, this->window,
&win_dummy, &attributes.x, &attributes.y,
&attributes.width, &attributes.height,
&border_dummy, &attributes.depth);
return true;
}
Again, it’s somewhat an older code, but that should work on recent libs too. Xorg or XFree doesn’t matter (at least for the moment).
That must help you.