This topic is now archived and is closed to further replies.


beginner's question: moving a quad and changing the light...

Recommended Posts

bkkazaz    122
Hi, I''ve 2 questions. 1. How can I move a quad (or a triangle, or a cube etc.) infinitely from one side of the window to the other. (for example from left to right, and then right to left). I don''t want to control it by keyboard or mouse. 2. Is there a way of changing the intensity of the light (which is in Lesson 7) by pressing a key? For example pressing "+" will make the object brighter while "-" makes it darker. Thanks...

Share this post

Link to post
Share on other sites
kenwi    122
I'm still no guru, but this is how I would have done it. I'm sure it's plenty of other possibilies, but however. Here goes.

Say you want to move the triangle by the X axis.

int iXaxis = 0;

glBegin(GL_TRIANGLES); // Drawing Using Triangles
glVertex3f( 0.0 +iXaxis, 1.0, 0.0); // Top
glVertex3f(-1.0 +iXaxis,-1.0, 0.0); // Bottom Left
glVertex3f( 1.0 +iXaxis,-1.0, 0.0); // Bottom Right
glEnd(); // Finished Drawing The Triangle

then later on int the main game loop, you + or - on the iXaxis to move the Triangle the direction you desire.

I think this will work, havent tried it for myself. As I said, I'm no guru, and I'm still just a beginner myself when it comes to OpenGL. So if anyone else has another way to do this, go ahead.

Kenneth Wilhelmsen
Download my little game project HERE
He who joyfully marches to music in rank and file has already earned my contempt. He has
been given a large brain by mistake, since for him the spinal cord would fully suffice. This
disgrace to civilization should be done away with at once. Heroism at command, senseless
brutality, deplorable love-of-country stance, how violently I hate all this, how despicable and ignoble war is; I would rather be torn to shreds than be a part of so base an action! It is my conviction that killing under the cloak of war is nothing but an act of murder

Edited by - kenwi on July 29, 2001 11:48:33 AM

Share this post

Link to post
Share on other sites
Ben_    122

Since I''ve had a pause in OpenGL programming for some time now I doesn''t remember the exact functions, but changing the brightness of ligth must be sth. like:
glLightColor(GL_LIGHT1, intensity, intensity, intensity);
Here intensity can reach from 0..1 where one is the brightest and 0 is off.
When using glTranslate to move your object rember that all objects painted after your square will be also moved, to avoid this you can either move after it in the negative direction, or push and pop the translation matrix.

Greetings Ben

Share this post

Link to post
Share on other sites