GLUT under Linux

Hi there everyone,

I haven’t been able to find a way for GLUT to draw on an existing Window or Drawable in X. Does anyone know how I would be able to take an existing Drawable like a GDKwindow or just a plain Window and draw on it using GLUT?


The normal use for GLUT is to setup some window that you can use for OpenGL rendering. If you already have a window with OpenGL capabilties why do you want to use GLUT? What exactly should GLUT be used for?

I guess my answer is “No, just configure the window with GLX for OpenGL rendering”.

Well, I just have a Window or Drawable (XID) and it is not configured for GLX. I want to use it in place of __glutCurrentWindow->win. I try to create a GLUTwindow and make it the current window and then set __glutCurrentWindow to whatever Drawable or Window I have from an interface and I get some unexpected results.

I would just like to take a Window or Drawable passed in from the interface.

The reason I am using GLUT is it is cross-platform and lightweight.

Based-on the above, should I still look into GLX for configuring my Window?

Thanks in advanced,

You can not use any window for OpenGL rendering and you must also have a OpenGL context, see the man page for glXIntro for a overview. The only way I know of to get a OpenGL window is to create it the right way.

From the GLX 1.2 spec.
“In GLX the definition of Visual has been extended to include the types, quantities and sizes of the ancillary buffers (depth, accumulation, auxiliary, and stencil).”
“Ancillary buffers are associated with a GLXDrawable, not with a rendering context. If several OpenGL renderers are all writing to the same window, they will share those buffers. Rendering operations to one win- dow never affect the unobscured pixels of another window, or of the corresponding pixels of ancillary buffers of that window.”

This page has a lot more information

Thank you very much.

Is it possible to change the attributes of an exiting window to be configured for GLX?



XChangeGC() ???


I think that the window should have a visual that supports OpenGL. From the second chapter of Xlib Programming Manual (O’Reilly & Associates, Inc.)
" It may clarify the picture to describe the features that window attributes do not affect. Setting the window attributes does not determine the size or position of a window, its parent, or its border width; these comprise the window configuration. Setting the window attributes does not affect the depth, class, or visual of a window; these are permanently set when the window is created. Attributes do not determine how graphics requests are interpreted; this is the job of the graphics context (GC)."

The book is online here

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.