Advertisement

drawing GL_QUADS in a for cmd.

Started by March 14, 2004 11:25 PM
2 comments, last by kc_0045 20 years, 11 months ago
im trying to make a tile effect witt opengl later im going to change it to make it like a hill but need to get this part working first. heres my code
int DrawGLScene(GLvoid)									// Here's Where We Do All The Drawing

{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear Screen And Depth Buffer

	glLoadIdentity();									// Reset The Current Modelview Matrix

	glTranslatef(0.0f,0.0f,-6.0f);
    glRotatef(wrotx,1.0f,0.0f,0.0f);
	glRotatef(wroty,0.0f,1.0f,0.0f);
	glRotatef(wrotz,0.0f,0.0f,1.0f);	
    for(int n=1; n<3; n++)
    {
    glBegin(GL_QUADS);									// Draw A Quad

		glColor3f(0.0f,0.0f,1.0f); glVertex3f(-1.0f, 1.0f*n, 0.0f);					// Top Left

		glColor3f(0.0f,0.0f,1.0f); glVertex3f( 1.0f, 1.0f*n, 0.0f);					// Top Right

		glColor3f(0.0f,1.0f,0.0f); glVertex3f( 1.0f,-1.0f*n, 0.0f);					// Bottom Right

		glColor3f(1.0f,0.0f,0.0f); glVertex3f(-1.0f,-1.0f*n, 0.0f);					// Bottom Left

	glEnd();
	}
    wrotz+=0.1f;											// Done Drawing The Quad

	return TRUE;										// Keep Going

} 
all it seems to do is overlap its self any ideas off how to fix? [edited by - kc_0045 on March 14, 2004 12:26:59 AM]
What is the position and orientation of the camera? The quads are increasing up the Y-axis. If your camera is facing down the Y-axis, you would see the quads overlap.
Advertisement
ahh glViewport(0,0,width,height); is that it? im not to sure about viewpoint stuff yet. but im sure there over laping like you can kinda see one though the other. and one more thing how do u set up arrays? im going to try to get up a grid thing like
grid_x[0]=0.0f;
grid_y[0]=1.0f;
grid_z[0]=1.0f;
how could i do that?

[edited by - kc_0045 on March 15, 2004 2:23:43 AM]
move the for loop inside of GlBegin() and glEnd() this should speedup a bit.

This topic is closed to new replies.

Advertisement