Discussion:
gluPerspective not working? Try this!
(too old to reply)
Fritz Foetzl
2004-04-08 21:31:08 UTC
Permalink
Raw Message
If you're pulling your hair out over gluPerspective not working, and
you're tired of being told to RTFM whenever you ask, try this:

1. You need to call gluLookAt as well, and
2. You need to call it AFTER gluPerspective.

If you call these functions in the wrong order, you'll see nothing.

Which, by the way, TFM doesn't tell you.

I hope this helps somebody.

ff
fungus
2004-04-08 21:47:58 UTC
Permalink
Raw Message
Post by Fritz Foetzl
If you're pulling your hair out over gluPerspective not working, and
1. You need to call gluLookAt as well, and
2. You need to call it AFTER gluPerspective.
If you call these functions in the wrong order, you'll see nothing.
Which, by the way, TFM doesn't tell you.
Try reading TFM a bit more closely.

I suspect what it really says is that you have to put
the perspective on the GL_PROJECTION stack and the
lookat on the GL_MODELVIEW stack - in which case you
can't possibly get them the wrong way around.
Post by Fritz Foetzl
I hope this helps somebody.
Nope.
--
<\___/> "To err is human, to moo bovine."
/ O O \
\_____/ FTB. For email, remove my socks.
John Tsiombikas (Nuclear / the Lab)
2004-04-09 02:31:13 UTC
Permalink
Raw Message
Post by Fritz Foetzl
If you're pulling your hair out over gluPerspective not working, and
1. You need to call gluLookAt as well, and
2. You need to call it AFTER gluPerspective.
If you call these functions in the wrong order, you'll see nothing.
Which, by the way, TFM doesn't tell you.
I hope this helps somebody.
ff
What the hell are you talking about ?!
what does gluLookAt (a helper function that generates a view matrix) has
to do with gluPerspective (a helper function that generates a projection
matrix)...
I never used gluLookAt and I rarely if ever use gluPerspective, however
I assure you I can see a lot of things :)

do yourself a favour and embark on a quest for the holy clue
--
John Tsiombikas (Nuclear / the Lab)
***@siggraph.org
http://thelab.demoscene.gr/nuclear/
Theo
2004-04-09 04:15:45 UTC
Permalink
Raw Message
Post by John Tsiombikas (Nuclear / the Lab)
what does gluLookAt (a helper function that generates a view matrix) has
to do with gluPerspective (a helper function that generates a projection
matrix)...
I never used gluLookAt and I rarely if ever use gluPerspective, however
I assure you I can see a lot of things :)
Just curious, as Im still in the "re-education" mode... dont you have to
say what the lookat point and up direction are for a moving camera? Perhaps
the default is 0,0,0 and 0,1,0 respectively?
John Tsiombikas (Nuclear / the Lab)
2004-04-11 01:09:58 UTC
Permalink
Raw Message
Post by Theo
Post by John Tsiombikas (Nuclear / the Lab)
I never used gluLookAt and I rarely if ever use gluPerspective, however
I assure you I can see a lot of things :)
Just curious, as Im still in the "re-education" mode... dont you have to
say what the lookat point and up direction are for a moving camera? Perhaps
the default is 0,0,0 and 0,1,0 respectively?
gluLookAt is just a helper function, it provides a way to conviniently
generate a view matrix that corresponds to the specified orientation.
Instead of using that you can generate the matrix yourself in a variety
of ways. For example you may have an orientation quaternion and a
position vector for the camera and create the apropriate transformation
from these, or even (for simple camera needs) you may just have a matrix
thatt begins with identity and concatenate there the inverse of the
transformations that you want the camera to perform.
Do not forget that a camera matrix (or view matrix) is just another
transformation on the way of every vertex of your scene to the screen,
not something magical.
And yes, to answer your final question, position 0,0,0 and up vector
0,1,0 are the defaults because that's what the identity matrix does to
vertices, leaves them unaffected.
--
John Tsiombikas (Nuclear / the Lab)
***@siggraph.org
http://thelab.demoscene.gr/nuclear/
Fritz Foetzl
2004-04-10 02:15:02 UTC
Permalink
Raw Message
Post by John Tsiombikas (Nuclear / the Lab)
Post by Fritz Foetzl
If you're pulling your hair out over gluPerspective not working, and
1. You need to call gluLookAt as well, and
2. You need to call it AFTER gluPerspective.
If you call these functions in the wrong order, you'll see nothing.
Which, by the way, TFM doesn't tell you.
I hope this helps somebody.
ff
What the hell are you talking about ?!
what does gluLookAt (a helper function that generates a view matrix) has
to do with gluPerspective (a helper function that generates a projection
matrix)...
I never used gluLookAt and I rarely if ever use gluPerspective, however
I assure you I can see a lot of things :)
Well, this turned out to be the silver bullet I was looking for. Given
the number of "help, gluPerspective doesn't work" posts here, I
thought it might
be helpful to someone else.
Post by John Tsiombikas (Nuclear / the Lab)
do yourself a favour and embark on a quest for the holy clue
Amazing. This ng isn't just unfriendly when one asks for help, it's
unfriendly when one tries to be helpful as well. If my tip isn't
helpful for you, just move along - you don't have to go out of your
way to insult me. (Unless, of course, it makes you feel better about
yourself - in which case knock yourself out. I'm here for you.)

ff
fungus
2004-04-10 08:02:10 UTC
Permalink
Raw Message
Post by Fritz Foetzl
Amazing. This ng isn't just unfriendly when one asks for help, it's
unfriendly when one tries to be helpful as well. If my tip isn't
helpful for you, just move along
Your amazing "tip" is *wrong*...
--
<\___/> "To err is human, to moo bovine."
/ O O \
\_____/ FTB. For email, remove my socks.
Fritz Foetzl
2004-04-10 14:23:15 UTC
Permalink
Raw Message
Post by fungus
Post by Fritz Foetzl
Amazing. This ng isn't just unfriendly when one asks for help, it's
unfriendly when one tries to be helpful as well. If my tip isn't
helpful for you, just move along
Your amazing "tip" is *wrong*...
No, it isn't. What you don't seem to realize is that I'm not pulling
things out of my ass here. I have a 3D OpenGL scene in which I was
seeing nothing but background. All the parameters to gluLookAt and
gluPerspective seemed to be in order, as far as I could tell. Just to
see, I tried calling gluLookAt after gluPerspective, and suddenly I
could see my scene. I don't know how you can argue with me here.

You got your panties in a bundle because I didn't frame my advice in
terms of the projection stack and modelview stack, and Theo got bitter
because he apparently thinks I said "the ONLY way to see ANYTHING" is
to use gluLookAt and gluPerspective...only I didn't say that.

So, to recap (please take special note of words in CAPS): for those
people WHO ARE TRYING TO USE GLUPERSPECTIVE, and have noticed that
GLUPERSPECTIVE MAKES THEIR SCENE DISAPPEAR AS SOON AS IT'S CALLED,
they MAY NEED TO CALL GLULOOKAT, AFTER GLUPERSPECTIVE. Of course, THIS
MAY NOT BE THE ONLY PROBLEM, IT'S JUST ONE POSSIBLE PROBLEM if a scene
isn't appearing properly.

Clear enough?

ff
fungus
2004-04-10 17:39:42 UTC
Permalink
Raw Message
Post by Fritz Foetzl
Post by fungus
Post by Fritz Foetzl
Amazing. This ng isn't just unfriendly when one asks for help, it's
unfriendly when one tries to be helpful as well. If my tip isn't
helpful for you, just move along
Your amazing "tip" is *wrong*...
No, it isn't.
Yes it is. Post the exact code which fails here
and I'll tell you where your big mistake is.
Post by Fritz Foetzl
What you don't seem to realize is that I'm not pulling
things out of my ass here.
Post the code and we'll see.
--
<\___/> "To err is human, to moo bovine."
/ O O \
\_____/ FTB. For email, remove my socks.
yooyo
2004-04-16 14:11:54 UTC
Permalink
Raw Message
Post by Fritz Foetzl
If you're pulling your hair out over gluPerspective not working, and
1. You need to call gluLookAt as well, and
2. You need to call it AFTER gluPerspective.
If you call these functions in the wrong order, you'll see nothing.
Which, by the way, TFM doesn't tell you.
I hope this helps somebody.
ff
Huh... that's normal... I suppose that you fogging and lighting code
doesn't work well to... Read this...

http://sjbaker.org/steve/omniv/projection_abuse.html

yooyo

Loading...