Results 1 to 9 of 9

Thread: How to show window without glutMainLoop() ?

  1. #1

    How to show window without glutMainLoop() ?

    Hello,

    I'm using GLUT, I could not manage to create a second window with OpenGL otherwise.

    Anyway, I have:

    glutDisplayFunc(MyDisplayFunction);
    glutReshapeFunc(MyReshapeFunction);
    glutIdleFunc(NULL); // No idle callback.

    can I have a window shown somehow without calling glutMainLoop() ?

    The problem is that glutMainLoop never returns, and I really just need to draw stuff and then ReadPixels() to a buffer. An endless loop is not what I want here.

    I've (desperately) tried glutShowWindow() and glutPostRedisplay() but to no avail.

    Thanks for any input,

    Andru

  2. #2
    Senior Member Regular Contributor
    Join Date
    May 2002
    Location
    York, UK
    Posts
    128

    Re: How to show window without glutMainLoop() ?

    Hi,

    no go ... glut always needs you to drop into
    glutMainloop() in order to process events.

    However ... help is at hand ... check
    http://www-users.york.ac.uk/~rpf1/glut.html

    for details.

    I cannot build and distribute a new glut library (usage conditions bar this, but I have contacted Mark K at nVidia, but no response as yet!).

    If you take the new source, build into your own library, you should be OK.

    enjoy!

    Rob.

  3. #3

    Re: How to show window without glutMainLoop() ?

    Thanks Rob,

    That seems to be exactly what I am after!

    If I only could build the thing... get 4080 errors with VS .NET :-/

    After uncommenting the line #define GLUTCHECKLOOP in glut_event.c, I should just replace the 5 (or so) files and then rebuild all of GLUT: Build->Build GLUT32, right ? I admit I'm not very good at this...

    Cheers,

    // Andru

  4. #4
    Senior Member Regular Contributor
    Join Date
    May 2002
    Location
    York, UK
    Posts
    128

    Re: How to show window without glutMainLoop() ?

    Hi,

    Must admit I built under IRIX and on a PC using Borland C++

    Also, I'm sure that the sources are a little out of date, so I think the best thing to do is:

    1. Make sure you can build the lib from sources, without any changes.

    2. Apply the changes yourself to your own source code tree (saving originals, or course)

    3. The re-build.

    I will get round to updating the sources on-line when I can find a few spare moments.

    Don't forget you can do lots in the "idle loop" ...

    Let me know if you succeed! Should reall not be a problem if you can get the lib to build.

    Cheers

    Rob.

  5. #5

    Re: How to show window without glutMainLoop() ?

    Yeah, well...

    I'm using Visual Studio .NET here.

    I first compiled the original Win32 GLUT v3.7.6. It built fine.

    I then made the appropriate changes myself. Basically I searched for "Rob" in your modified source files. I hope you had your name in every spot you made a change

    So far it looks pretty good, although the "win32_winproc.c" file is really much different.

    I've made the changes but I still get the error "cannot convert from 'void (__stdcall *)(void)' to 'GLUTwmcloseCB'" in win32_winproc.c and glut_win.c and I really don't know how to fix this. I've never been into the APIENTRY CALLBACK strange things anyway, pretty cryptic to me...

    Hope you have time to look at it some time soon yourself

    // Andru

  6. #6
    Senior Member Regular Contributor
    Join Date
    May 2002
    Location
    York, UK
    Posts
    128

    Re: How to show window without glutMainLoop() ?

    Hi,

    Check very carefully that you have transplanted the code correctly in glut.h AND glutint.h

    GLUTwmcloseCB type is there just before the def of the window structure ...

    make sure your c modules do in fact use glutint.h

    email me on r.fletcher@york.ac.uk for more
    immediate returns on your queries ...

    Sounds like we can put this one to rest quite soon!

    Rob.

  7. #7
    Senior Member Regular Contributor
    Join Date
    Mar 2002
    Posts
    103

    Re: How to show window without glutMainLoop() ?

    There is no reason why you cannot draw some geometry and do glReadPixels and then exit. You can put what ever code you want in the callbacks. I do this all the time to generate screenshots and animations without breaking the glut loop.

  8. #8

    Re: How to show window without glutMainLoop() ?

    Rob:

    It's done, working fine. I don't know if the window closing callback works but I don't need it anyway glutCheckLoop() works fine, thanks =)

    gumby:

    ehm, have I understood it wrong then ? I thought glutMainLoop() *never* returns ?
    Please elaborate on how you do it, pseudocode example please ?

    Thanks,

    // Andru

  9. #9
    Senior Member Regular Contributor
    Join Date
    May 2002
    Location
    York, UK
    Posts
    128

    Re: How to show window without glutMainLoop() ?

    Hi, to answer for gumby too:

    The sort of thing I do to e.g. capture an
    AVI animation is to have in the display loop
    a flag which can be checked to see if a I should capture frames and write AVI ...

    This flag is switched on and off in the keyboard handling callbacks.

    You can do this for most of the "additional" tweaks and things you need to do inside a display function.

    I usually hang my display function off a timer too, rather than free run it (to give ME control over frame rates!)

    Hope this helps.

    Rob.

    P.S. You "ought" to use the new window closing stuff as when you shut a glut program down by closing ANY of its windows, all it does is "exit(0)", which simply kills the lot. This can be very nasty ... no chance to clean up and so on ... or even warn the user perhaps!

Similar Threads

  1. Replies: 0
    Last Post: 08-02-2006, 09:24 PM
  2. Replies: 5
    Last Post: 08-02-2006, 01:59 AM
  3. How to hide/show console window when using glut
    By job in forum OpenGL: General
    Replies: 6
    Last Post: 08-11-2004, 05:46 AM
  4. How to show the OpenGL scene in part of the window?
    By Ameng in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 07-25-2002, 07:21 PM
  5. How to show Text on OpenGL window?
    By tyyu in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 03-26-2001, 05:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean