Trouble with gluPerspective() call in init()

Hi,
Can anyone suggest why a call to gluPerspective() in the init() method has no affect on the image rendered via the display() method?

The only way I get to see my primitives on-screen is by placing my gluPerspective() call in the display() method - where it’s called for every frame rendered.

I’ve stripped my code down until it’s of the form:

in init()

  1. switch to projection matrix 2) load identity 3) issue gluPerspective call 4) switch to model/view matrix 5) continue set-up
    in display()
  2. apply model/view transforms 7) render display list

I see nothing on-screen unless I move steps 1 to 4 into the display() method.

Am I missing something obvious here?
Could the code in the reshape() method play a part in this?
Do I need to post real code here or can anyone suggest likely errors?

Any / all suggestions mightily appreciated.

You don’t know the window width and height in the init() method, so how are you choosing the parameters to pass in to gluPerspective()?

Have you looked at the jogl demos’ source code to see how they handle resizes, etc.?

Ken,

Thanks for the feedback.

My window is of fixed width/height and user-selected before firing up the animator thread, so I know the aspect ratio at this point.

I suggested the reshape() method as a possibility more in desperation rather than anything else.
I had assumed that as my window was fixed the reshape method wouldn’t be called but I wasn’t 100% sure of that.

I’ll take a look at the code in the jogl demos as the reshape code I’m using was culled from a 2D demo using orthagonal projection.

What I’m trying to ascertain with this post is whether there’s anything fundamentally wrong with my approach, i.e. setting the projection matrix once in the init() method and expecting that to remain set as each frame is rendered by the display() method. (Assuming my code is fine and not bugged in some way)

I’ll investigate further.
Cheers.

Setting up the projection and modelview matrices in your init() method should work fine; JOGL doesn’t do anything internally which would overwrite them. It does set up the viewport before it calls your reshape() method, but this should not affect your application.