GLX and Removing Window Borders By Jaya Kanajan, SGI H1. Introduction: Sometimes having window borders is good, but when you're trying to go full screen, havng a window border is a problem. So this ultra-short article is simply to answer the question that we were asked at a recent meeting: "I have my GL app ported and running with ProPack 1.3-VW on my 550 but I can't get rid of the window borders for some reason.". H1. Details There are several ways to remove winodw borders, one is to instruct the window manager manually by adding an entry to the applications Xdefaults file like myapp*border: 0 This works, because the X server start scripts are setup to read the Xdefaults and app-defaults files on startup in order to set properties and preferences for various applications. However, that's not too handy if you want to be able to go back and forth with having a border versus not having a border easily. You can solve this problem using (X11) XChangeProperty to tell the window manager (at least Motif compliant window managers) to remove window border and other decorations. H1. Conclusion Use the Xdefaults/app-defaults mechanism if your application is always full screen. If you want to do it within your own code, use the XChangeProperty method to suggest removing window decorations. I tested the follwing application on my Silicon Graphics 550 with ProPack 1.3-VW on a VR7 graphics card and it works fine. H1. Example Application rmwmborder.c =============================================================================== /* * jaya@sgi.com * glx without window border example */ #include #include #include #include #include static Atom wm_atom = 0; Window makewindow(Display* dpy, int w, int h, int x, int y) { XSetWindowAttributes winattribs; Colormap cmap; XVisualInfo* vis; Window win; GLXContext ctxt; PropMwmHints hints; int attribs[] = { GLX_RGBA, GLX_DOUBLEBUFFER, None }; vis = glXChooseVisual( dpy, DefaultScreen( dpy ), attribs ); cmap = XCreateColormap( dpy, RootWindow(dpy, vis->screen), vis->visual, AllocNone ); winattribs.colormap = cmap; winattribs.border_pixel = 0; winattribs.background_pixel = 0; win = XCreateWindow( dpy, RootWindow(dpy, vis->screen), x, y, w, h, 0, vis->depth, InputOutput, vis->visual, CWColormap|CWBorderPixel|CWBackPixel, &winattribs ); wm_atom = XInternAtom(dpy, "_MOTIF_WM_HINTS", False); hints.decorations = 0x0; hints.flags |= MWM_HINTS_DECORATIONS; XChangeProperty(dpy, win, wm_atom, wm_atom, 32, PropModeReplace, (unsigned char *)&hints, PROP_MOTIF_WM_HINTS_ELEMENTS); XStoreName(dpy, win, "drawpixels test"); XSelectInput(dpy, win, ExposureMask | StructureNotifyMask | KeyReleaseMask ); XMapWindow( dpy, win ); XFlush( dpy ); ctxt = glXCreateContext( dpy, vis, 0, GL_TRUE ); glXMakeCurrent(dpy, win, ctxt); glViewport(0, 0, (GLint)w, (GLint)h); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); glOrtho(0, w, 0, h, -1, +1); glRasterPos2f(0.0, 0.0); return win; } int main(int argc, char **argv) { Display *dpy = XOpenDisplay(NULL); Window win; GLenum gltype = GL_RGBA; GLenum glformat = GL_UNSIGNED_BYTE; int i,j; int w = 300; int h = 300; int x = 0; int y = 0; char *buf,*ptrbuf,*buf2,*ptrbuf2; win = makewindow(dpy,w,h,x,y); buf = (char*) malloc(w*h*4*sizeof(char)); ptrbuf = buf; for (i=0;i