# OpenGL Simple Vertex Question

This topic is 5070 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm new to using OpenGL and have a simple question regarding vertices. Why will the following code display a line: // Draw a line from the center towards the top right hand corner glTranslatef(0.0f,0.0f,0.0f) glBegin(GL_LINES); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(1.0f, 1.0f, 0.0f); // Draw a 45deg line glEnd(); but the follwing code won't // Draw a translated line towards the center i.e. from the top left hand corner down towards the center of the view glTranslatef(-1.0f,1.0f,0.0f) glBegin(GL_LINES); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(0.8f, -1.0f, 0.0f); // Draw a steeper line, NOTE: 0.8f glEnd(); It won't seem to draw a line in the second case unless the values for the coeffecients are all 1.0f or 0.0f i.e. only horizontal,vertical and 45degree lines will be displayed. Is there something I'm doing wrong/have I missed something or is my logic regarding translations etc wrong?

##### Share on other sites
does it work if u remove -> glTranslatef(-1.0f,1.0f,0.0f)

##### Share on other sites
yeah it does - draws a steep line from the center. All I'm trying to do is draw a line offset from the center

##### Share on other sites
try changing
glTranslatef(-1.0f,1.0f,0.0f)
to
glTranslatef(-0.0001f,0.0f,0.0f)

u shold see the line slowly moving ( i assume the problem is youre not restting the modelview matrix ever frame thus the translations are accumulating)

1. 1
2. 2
3. 3
4. 4
5. 5
Rutin
17

• 10
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631420
• Total Posts
2999987
×

## Important Information

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!