View Full Version : Help NEED!!!

01-20-2004, 10:27 PM
I am coding a 3D program by GLUT.
A simple question, but I still could not find the answer:
How can I remove the window frame when it was created by GLUT?


Tom Nuydens
01-20-2004, 11:28 PM
This is hardly an advanced question. I'll move this thread to the toolkits forum. Meanwhile, I'd suggest that you look at the source code of some of the many Glut-based demos on the web.

-- Tom

01-21-2004, 06:30 PM
I'm sure you can't do this via glut unless you go fullscreen, you may be able to do it using X or Win32 functions (SetWindowLong on win32).

You can make the current window fullscreen by calling glutFullScreen (). This will maximize your window and disable all frames etc. Or if you want to render in fullscreen mode and change resolution, bit depth, etc you can use GLUT "Game Mode" http://www.lighthouse3d.com/opengl/glut/index.php3?gameglut

01-21-2004, 07:45 PM

Thanks for your replying.
In my case, I can not use fullscreen mode because I need another windows viewing in another area of the screen.

01-22-2004, 07:33 AM
Are you using linux or windows?
In windows you could probably use the SetWindowLong function to change the style of the window after you've created it with glut. You probably could do it in X-windows as well but I know nothing about this.

01-22-2004, 05:21 PM
I am using Linux. It is very simple in X window. Maybe combine X-window and GLUT is the closet way for fixing this issue.

Thanks again, and hoping more informations.


02-12-2004, 02:25 AM
Got a soln for the issue.. Given the name of the window, we can remove its decorations.. Here is the sample code.
Compile with :
gcc -g -I/usr/include/GL -I/usr/X11R6/include -L/usr/lib/ -L/usr/X11R6/lib/ -o glutWindowWithoutDecorations glutWindowWithoutDecorations.c -lglut -lGLU -lGL -lXext -lX11 -lXm -lXi -lGLw

Code : glutWindowWithoutDecorations.c
#include <glut.h>
#include <Xm/MwmUtil.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glx.h>
#include <GL/GLwMDrawA.h> /* Motif OpenGL drawing area. */

float angle = 0.0;

static String fallbackResources[] = {
"*glxarea*width: 300", "*glxarea*height: 300",
"*frame*x: 20", "*frame*y: 20",
"*frame*topOffset: 20", "*frame*bottomOffset: 20",
"*frame*rightOffset: 20", "*frame*leftOffset: 20",
"*frame*shadowType: SHADOW_IN", NULL
static int snglBuf[] = {GLX_RGBA, GLX_DEPTH_SIZE, 12, GLX_RED_SIZE, 1, None};

static int dblBuf[] = {GLX_RGBA, GLX_DEPTH_SIZE, 12, GLX_DOUBLEBUFFER, GLX_RED_SIZE, 1, None};
Bool doubleBuffer = True;
Display *dpy;
int screen;
XVisualInfo *visinfo;
GLXContext glxcontext;
Colormap cmap;
XtAppContext app;

void OnIdle() {

void display(void)
glColor3f(0.0, 0.0, 1.0); /* blue */
glVertex2i(0, 0);
glColor3f(0.0, 1.0, 0.0); /* green */
glVertex2i(200, 200);
glColor3f(1.0, 0.0, 0.0); /* red */
glVertex2i(20, 200);
glFlush(); /* Single buffered, so needs a flush. */

Colormap getShareableColormap(XVisualInfo * vi)
Status status;
XStandardColormap *standardCmaps;
Colormap cmap;
int i, numCmaps;

/* Be lazy; using DirectColor too involved for this example. */
#if defined(_CH_) | | defined(__cplusplus)
if (vi->c_class != TrueColor)
if (vi->class != TrueColor)
XtAppError(app, "no support for non-TrueColor visual");
/* If no standard colormap but TrueColor, just make an
unshared one. */
status = XmuLookupStandardColormap(dpy, vi->screen, vi->visualid,
vi->depth, XA_RGB_DEFAULT_MAP,
False, /* Replace. */
True); /* Retain. */
if (status == 1) {
status = XGetRGBColormaps(dpy, RootWindow(dpy, vi->screen),
&standardCmaps, &numCmaps, XA_RGB_DEFAULT_MAP);
if (status == 1)
for (i = 0; i < numCmaps; i++)
if (standardCmaps[i].visualid == vi->visualid) {
cmap = standardCmaps[i].colormap;
return cmap;
cmap = XCreateColormap(dpy, RootWindow(dpy, vi->screen), vi->visual, AllocNone);
return cmap;

Window getWindowIdFromName(Display *dpy, Window level, char *name)
Window *children;
Window dmy;
Window root;
Window id;
char *window_name;
int i;
int no_of_children;

if (0 == XQueryTree(dpy, level, &dmy, &dmy, &children, &no_of_children))
return 0;

for (i=0; i<no_of_children; i++)
if (XFetchName(dpy,children[i], &window_name))
if (strcmp (name, window_name)) XFree(window_name);
return children[i];
if (id = getWindowIdFromName(dpy, children[i], name))
return id;
return 0;

int main(int argc, char **argv)
Widget w;
Window window, root, id;
XSetWindowAttributes swattr;
PropMwmHints motf_prop;
Atom motf_atom;

/* Section to make a glut Window called "single traiangle"*/
glutInit(&argc, argv);
glutCreateWindow("single triangle");

/* Now that window is created, Get its window ID from the name "single triangle"*/
if (NULL == (dpy = XOpenDisplay(NULL)))
printf ("Could not open display");

root = DefaultRootWindow(dpy);
/* we must get id from name string */
if (0 == (id = getWindowIdFromName(dpy, root, "single triangle")))
printf ("Invalid window name");

printf("ID = %d\n", id);
// This is the window id of "single triangle" .. can check with xwininfo -id <num>

/* Now we need to get permission to modify Window properties.
Check reasoning in http://tronche.com/gui/x/xlib/window/attributes/override-redirect.html*/

swattr.override_redirect = 1;
XChangeWindowAttributes( dpy, id, CWOverrideRedirect, &swattr);

/* Now set the flags for FUNCTIONS and DECORATIONS of the Window to null and apply*/
motf_atom = XInternAtom(dpy, "_MOTIF_WM_HINTS", False);
motf_prop.flags = 0;

XChangeProperty(dpy, id, motf_atom, motf_atom,32,PropModeReplace,
(unsigned char *)&motf_prop, PROP_MWM_HINTS_ELEMENTS);

/* Now back to glut.. start the MainLoop */
glutIdleFunc( OnIdle );


return 0;

/**** End of Code ****/


02-15-2004, 03:31 AM

thanks a lot for your help, I will try this program.
Thanks again for your kindness! http://www.opengl.org/discussion_boards/ubb/smile.gif