• Create Account

#ActualL. Spiro

Posted 03 June 2014 - 08:30 PM

If all the points are around the origin if the object and you are drawing something like Asteroids, rotate first, then translate. Once.

	void showLine(){
glRotatef(0.0f,0.0f,rot);				// glRotatef() has 3 parameters.  Rotate around Z.
glTranslatef(SCREEN_WIDTH/2,SCREEN_WIDTH/2,0.0f);	// Then move to the center of the screen.

// Or move to the position of the object relative to the center of the screen.
//glTranslatef(SCREEN_WIDTH/2+objPos.x,SCREEN_WIDTH/2+objPos.x,0.0f);

glBegin(GL_LINES);
glColor3f(1.0f,0.5f,0.3f);
glVertex2f(start.x,start.y);
glVertex2f(end.x,end.y);

glEnd();

}//this is only one line segment


I have looked on line and that's what appears to be the common method.

It was common perhaps 20 years ago. It’s outdated and deprecated, meaning no longer supported and not the common way anymore.

L. Spiro

#2L. Spiro

Posted 03 June 2014 - 08:29 PM

If all the points are around the origin if the object and you are drawing something like Asteroids, rotate first, then translate. Once.

	void showLine(){
glRotatef(0.0f,0.0f,rot);				// glRotatef() has 3 parameters.  Rotate around Z.
glTranslatef(SCREEN_WIDTH/2,SCREEN_WIDTH/2,0.0f);	// Then move to the center of the screen.

// Or move to the position of the object relative to the center of the screen.
//glTranslatef(SCREEN_WIDTH/2+objPos.x,SCREEN_WIDTH/2+objPos.x,0.0f);

glBegin(GL_LINES);
glColor3f(1.0f,0.5f,0.3f);
glVertex2f(start.x,start.y);
glVertex2f(end.x,end.y);

glEnd();

}//this is only one line segment


L. Spiro

#1L. Spiro

Posted 03 June 2014 - 08:26 PM

If all the points are around the origin if the object and you are drawing something like Asteroids, rotate first, then translate. Once.

	void showLine(){
glRotatef(rot,0.0f,0.0f,1.0f);
glTranslatef(SCREEN_WIDTH/2,SCREEN_WIDTH/2,0.0f);

glBegin(GL_LINES);
glColor3f(1.0f,0.5f,0.3f);
glVertex2f(start.x,start.y);
glVertex2f(end.x,end.y);

glEnd();

}//this is only one line segment


L. Spiro

PARTNERS