On missing GLUT functions

Hi all

I am currently learning OpenGL from the Red Book, and I am stuck with the examples using GLUT functions ;D.

I see how to handle window and event related stuff but how would you replace :

  • glutPostRedisplay
  • glutIdleFunc
  • glutMainLoop

The glutMainLoop thing seems to be handled by the Animator, but I can’t figure out the rest. Well, I hope that’s not a too dumb question :-[

Thx

Please look at the source code of the demos in the jogl-demos project on java.net for examples of how JOGL is used (as opposed to GLUT and C/C++).

Well, I gave a quick look at the source of these demos, and I still don’t see how to replace glutIdleFunc.

Anyway that function doesn’t seem to be that important : apart from 3-4 tutorials, I have found nothing using it. So I’ll skip that part for now and focus on much more interesting details. :wink:

Btw, is there a source release of the demos ? I got the code using CVS but binaries only are available in jogl download section. I’m asking because, on my machine, HWShadowmapsSimple works using webstart while the CVS version doesn’t (gray screen).

glutIdleFunc is called when the canvas isn’t visible, instead of the normal update function, correct? If you use the Animator class then this continually calls the display method regardless of visible/invisible. If you want that then I guess you’d listen for the maximised/minimised events for the window as normal and use that to set some state flag.

[quote]Btw, is there a source release of the demos ? I got the code using CVS but binaries only are available in jogl download section. I’m asking because, on my machine, HWShadowmapsSimple works using webstart while the CVS version doesn’t (gray screen).
[/quote]
Some changes were checked in within the last day or two that change some behavior of the HWShadowmapsSimple demo as well as internal context handling. This demo worked on my machine after the changes, though. What machine / OS / graphics card are you running on?

[quote]glutIdleFunc is called when the canvas isn’t visible, instead of the normal update function, correct?
[/quote]
Not exactly :slight_smile:
Here is an extract from glut specs :

[quote]glutIdleFunc sets the global idle callback to be func so a GLUT program can perform background processing
tasks or continuous animation when window system events are not being received. If enabled, the idle
callback is continuously called when events are not being received.

The amount of computation and rendering done in an idle callback should be minimized to avoid affecting
the programs interactive response. In general, not more than a single frame of rendering should be done in an
idle callback.
Passing NULL to glutIdleFunc disables the generation of the idle callback.
[/quote]
In the red book, glutIdleFunc is used with glutPostRedisplay to spin a square when a mouse event is fired.

My problem is that all the jogl examples I’ve seen so far use the Animator class to handle redisplay. But in that specific case, I would need to make explicit calls to the display() function. Would it be possible to stop the Animator when the event is fired and update the display manually ?

Ken Russell :

Windows 98
Geforce4 Ti4200 (detonator 44.05, if I remember well)
JDK 1.4.2
jogl 5th sept.

Unfortunately the CVS version gives no error message when it runs, simply a gray screen.

That explains it; you need to use the latest version of JOGL from the CVS repository if you’re going to use the CVS sources of the demos. Alternatively you can pick up those binaries from the nightly builds (the games-binaries project on java.net).

Thx that works fine now.

I found the solution to my main problem too. I’m sorry, I should have thought about it a bit more before posting but I were confused by the differences between straight OpenGL / GLUT and JoGL. Now that I’ve read part of the source, I understand better the way it works. :slight_smile: