Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 8 of 8

Thread: Help NEED!!!

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2004
    Location
    Japan
    Posts
    7

    Help NEED!!!

    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?
    If is POSSIBLE??


  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Oct 2000
    Location
    Belgium
    Posts
    857

    Re: Help NEED!!!

    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

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2004
    Location
    Northumberland
    Posts
    6

    Re: Help NEED!!!

    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/g....php3?gameglut

  4. #4
    Junior Member Newbie
    Join Date
    Jan 2004
    Location
    Japan
    Posts
    7

    Re: Help NEED!!!

    NeXus,

    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.

  5. #5
    Junior Member Newbie
    Join Date
    Jan 2004
    Location
    Northumberland
    Posts
    6

    Re: Help NEED!!!

    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.

  6. #6
    Junior Member Newbie
    Join Date
    Jan 2004
    Location
    Japan
    Posts
    7

    Re: Help NEED!!!

    Thanks,
    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.


    Linuxgirl

  7. #7
    Junior Member Newbie
    Join Date
    Jan 2004
    Location
    Bangalore, India
    Posts
    3

    Re: Help NEED!!!

    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/Xm.h>
    #include <Xm/MwmUtil.h>
    #include<stdio.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() {
    glutShowWindow();
    }

    void display(void)
    {
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_TRIANGLES);
    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);
    glEnd();
    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)
    #else
    if (vi->class != TrueColor)
    #endif
    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;
    XFree(standardCmaps);
    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);
    else
    {
    XFree(window_name);
    return children[i];
    }
    }
    else
    {
    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);
    glutInitDisplayMode(GLUT_RGB);
    if (! glutGet(GLUT_DISPLAY_MODE_POSSIBLE))
    glutInitDisplayMode(GLUT_INDEX);
    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...edirect.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 */
    glutDisplayFunc(display);
    glutIdleFunc( OnIdle );

    glutMainLoop();

    return 0;

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

    Amjad

  8. #8
    Junior Member Newbie
    Join Date
    Jan 2004
    Location
    Japan
    Posts
    7

    Re: Help NEED!!!

    Hi,

    thanks a lot for your help, I will try this program.
    Thanks again for your kindness!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •