How do I keep things separate????? (see inside)
Hey ppl, I am really really hoping that some of you know how to do this.
Basically, I want to know how to keep all of my functions separate, but let them all run at the same time.. for example.
If I make it so that the sky texture rotates in a certain direction, I want it so that even if the camera turns upside down, or the world destroys itself, or whatever, I still want the sky to rotate in the same way as it was.
Another example would be gravity... I want to make it so that no matter which direction you are looking at e.t.c, gravity always applies downwards....
Can anyone help me with this.. it''s really bugging me ''cause I used to know how to do it!
Thanx in advance for any help.
~Cobra~
"Build a man a fire, and he will be warm for a day. Set a man on fire, and he will have warmth for the rest of his life"
Ummm... If I understand your question (doubtful), then the answer is to use a game loop:
(VB, since my C++ really stinks... I can''t even remember how to write a Do loop )
Trying is the first step towards failure.
(VB, since my C++ really stinks... I can''t even remember how to write a Do loop )
Do While bRunning GetInput MovePlayer DoGravity SpinSky DrawEverything FlipBackBufferLoop
Trying is the first step towards failure.
Trying is the first step towards failure.
Actually, I think I''ll just have to start using gluLookAt from now on.. this actually works like a camera, so it won''t affect anything in the rest of the level.
But thanx anyway.
~Cobra~
But thanx anyway.
~Cobra~
"Build a man a fire, and he will be warm for a day. Set a man on fire, and he will have warmth for the rest of his life"
I think that the reason that gluLookAt doesn''t mess up all the other junk is that it modifies the projection matrix, while normal transformations modify the model view matrix. So if you wanted to do it _without_ gluLookAt for some reason then you could glMatrixMode(GL_PROJECTION); mess with your camera, and go back to glMatrixMode(GL_MODEL_VIEW); (there''s about a 90% chance that I have every single one of those names wrong).
I just started with ogl about a month ago, so my understanding of how it works is still pretty shaky, but I think this is right. Someone please correct me if it isn''t.
/riley
I just started with ogl about a month ago, so my understanding of how it works is still pretty shaky, but I think this is right. Someone please correct me if it isn''t.
/riley
--Riley
Do While bRunning
GetInput
MovePlayer
DoGravity
SpinSky
DrawEverything
FlipBackBuffer
Loop
we wanna play, not watch the pictures
GetInput
MovePlayer
DoGravity
SpinSky
DrawEverything
FlipBackBuffer
Loop
do{ GetInput(); MovePlayer(); DoGravity(); SpinSky(); DrawEverything();}while(bRunning);
we wanna play, not watch the pictures
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia
My Page davepermen.net | My Music on Bandcamp and on Soundcloud
DONT mess with the projection matrix AT ALL
gluLookat works in modelview space (have a look at the mesa source for a sample code of what it does )
http://members.xoom.com/myBollux
gluLookat works in modelview space (have a look at the mesa source for a sample code of what it does )
http://members.xoom.com/myBollux
January 27, 2001 03:25 AM
what about glPushMatrix(), glPopMatrix()?? Maybe you''re rotating the sky, which then rotates the camera (since the camera is rotated after), which inturn rotates nething after... crappy explaination but I think u get it...
to stop this:
glPushMatrix()
// rotate 1 thing
glPopMatrix() <- resets the transformation matrix or whatever so you''re back where u started before glPushMatrix()
glPushMatrix() (again)
// rotate/move something else
glPopMatrix...
This way you can separate all your calls to rotate/move... You could draw a car for example like:
pushmatrix()
// move to car pos and draw car body
pushmatrix()
// move to front left wheel pos (relative to car pos) and draw it
popmatrix()
pushmatrix()
// move to front right wheel pos (relative to car pos) and draw it
popmatrix()
... do other wheels
popmatrix()
and this pop matrix gets you back to the state u were at before you moved to draw the car body
if this didnt help very much, look up glPushMatrix in the redbook, has a pretty good explaination, or NeHe
to stop this:
glPushMatrix()
// rotate 1 thing
glPopMatrix() <- resets the transformation matrix or whatever so you''re back where u started before glPushMatrix()
glPushMatrix() (again)
// rotate/move something else
glPopMatrix...
This way you can separate all your calls to rotate/move... You could draw a car for example like:
pushmatrix()
// move to car pos and draw car body
pushmatrix()
// move to front left wheel pos (relative to car pos) and draw it
popmatrix()
pushmatrix()
// move to front right wheel pos (relative to car pos) and draw it
popmatrix()
... do other wheels
popmatrix()
and this pop matrix gets you back to the state u were at before you moved to draw the car body
if this didnt help very much, look up glPushMatrix in the redbook, has a pretty good explaination, or NeHe
THATS IT!!!!!!!!
Thanx mr anonymous poster!..
I think that''s it.. I''ll go test it out now.. but I''m pretty sure that''s it.
~Cobra~
Thanx mr anonymous poster!..
I think that''s it.. I''ll go test it out now.. but I''m pretty sure that''s it.
~Cobra~
"Build a man a fire, and he will be warm for a day. Set a man on fire, and he will have warmth for the rest of his life"
Wow, I never knew just how useful glPushMatrix and glPopMatrix were! I never used them before! Now I''ll ALWAYS use them! hehehe.
I''ve managed to totally move all of my functions out of DrawGLScene, and just make calls to it using function calls now, so my DrawGLScene looks a lot like the loop you guys were showing earlier.
There''s just one thing that I don''t get now.
What is this FlipBackBuffer that you guys were mentioning?
Thanx in advance for any help.
~Cobra~
I''ve managed to totally move all of my functions out of DrawGLScene, and just make calls to it using function calls now, so my DrawGLScene looks a lot like the loop you guys were showing earlier.
There''s just one thing that I don''t get now.
What is this FlipBackBuffer that you guys were mentioning?
Thanx in advance for any help.
~Cobra~
"Build a man a fire, and he will be warm for a day. Set a man on fire, and he will have warmth for the rest of his life"
OpenGL dosen''t use a back buffer call it does it automaticly (I think) all a buffer is is a place to draw to then you swap the buffers front buffer is your current view back buffer is your next view. It eliminates flicker and increases framerates. You can impliment one in OGL i''m not shure how but i know you can DirectX requires you use one. Just another point at why OGL is a generaly better API.
A man walks into a bar.....ouch!?! Ya get it, do ya huh huh well....awww I give up.
A man walks into a bar.....ouch!?! Ya get it, do ya huh huh well....awww I give up.
A man walks into a bar.....ouch!?! Ya get it, do ya huh huh well....awww I give up.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement