Skip to main content
gamedev.net
🔒 Locked

Doing a loop with Lines

Started by porra 1 reply 300+ views
Original Post
porra
porra
hi there, firstly, sorry ''bout my english eheeh i''m new trying to learn how opengl works.. i''m trying to make a tunnel.. made of lines... i made 4 quads with lines and i want to those quads to come closer, incrementing a variable but there is one problem, when those quads come closer, i don''t know how to make new ones appear starting from the center of the screen and moving like others.. i''ll post my code here int DrawGLScene(GLvoid) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(0.0f,0.0f,zoom); glColor3f(1.0f,0.0f,0.0f); glBegin(GL_LINES); glVertex3f(-u+2.0f,-u+2.0f,0.0f); glVertex3f( u-2.0f,-u+2.0f,0.0f); glVertex3f( u-2.0f, u-2.0f,0.0f); glVertex3f(-u+2.0f, u-2.0f,0.0f); glVertex3f( u-2.0f,-u+2.0f,0.0f); glVertex3f( u-2.0f, u-2.0f,0.0f); glVertex3f(-u+2.0f, u-2.0f,0.0f); glVertex3f(-u+2.0f,-u+2.0f,0.0f); glVertex3f(-u+4.0f,-u+4.0f,0.0f); glVertex3f( u-4.0f,-u+4.0f,0.0f); glVertex3f( u-4.0f, u-4.0f,0.0f); glVertex3f(-u+4.0f, u-4.0f,0.0f); glVertex3f( u-4.0f,-u+4.0f,0.0f); glVertex3f( u-4.0f, u-4.0f,0.0f); glVertex3f(-u+4.0f, u-4.0f,0.0f); glVertex3f(-u+4.0f,-u+4.0f,0.0f); glVertex3f(-u+6.0f,-u+6.0f,0.0f); glVertex3f( u-6.0f,-u+6.0f,0.0f); glVertex3f( u-6.0f, u-6.0f,0.0f); glVertex3f(-u+6.0f, u-6.0f,0.0f); glVertex3f( u-6.0f,-u+6.0f,0.0f); glVertex3f( u-6.0f, u-6.0f,0.0f); glVertex3f(-u+6.0f, u-6.0f,0.0f); glVertex3f(-u+6.0f,-u+6.0f,0.0f); glVertex3f(-u+7.9f,-u+7.9f,0.0f); glVertex3f( u-7.9f,-u+7.9f,0.0f); glVertex3f( u-7.9f, u-7.9f,0.0f); glVertex3f(-u+7.9f, u-7.9f,0.0f); glVertex3f( u-7.9f,-u+7.9f,0.0f); glVertex3f( u-7.9f, u-7.9f,0.0f); glVertex3f(-u+7.9f, u-7.9f,0.0f); glVertex3f(-u+7.9f,-u+7.9f,0.0f); glVertex3f( 0.1f, 0.1f,0.0f); glVertex3f( 8.0f, 8.0f,0.0f); glVertex3f(-0.1f,-0.1f,0.0f); glVertex3f(-8.0f,-8.0f,0.0f); glVertex3f( 0.1f,-0.1f,0.0f); glVertex3f( 8.0f,-8.0f,0.0f); glVertex3f(-0.1f, 0.1f,0.0f); glVertex3f(-8.0f, 8.0f,0.0f); glEnd(); u+=0.01f; return TRUE; } i think it''s quite simple, but i didn''t get thanks
dede
dede
This is one way to do it.

Do this, it will be much simpler

place = 0;
While(1)
{
place++;

drawQuads();

if(place > overlapped)
place = 0;
}


So you have to think about your quads as "blinking" christmas tree lights. they repeat the same frames over and over again, but because they are turning on and off, it looks as if they are traveling.

porra
porra
but where can i put the swapbuffer(hdc); command?

at nehe''s tutorial it comes after drawglscene();

how can i do it with this loop?

thanks

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.