PDA

View Full Version : Rendering problem

iris_raj
10-07-2003, 01:26 AM
The following is the code for drawing a Electric pole in a scene.
While I execute the pole always stands little above the ground position. It is not fixed on the ground. What may be problem

void draw_pole()
{
glBegin(GL_LINES);
glVertex2f(0.0f,0.0f);
glVertex2f(0.0f,2.0f);
glEnd();
glBegin(GL_LINES);
glVertex2f(-2.0f,4.0f);
glVertex2f(2.0f,4.0f);
glEnd();
}

10-07-2003, 03:50 AM
Well, I'm going to assume you're not drawing the ground at Y=0...which could be a problem...but there's no way to tell as you've provided about as little information as anyone could humanly provide..=P (Can we see some more code?)

iris_raj
10-08-2003, 01:13 AM
I have a more detailed code.First I am adding a Ground in the scene. On the top of it I am drawing the ELectric pole.

void renderScene(void)
{
glColor3f(0.6f, 0.6f, 0.9f);
glBindTexture(GL_TEXTURE_2D,texName[1]);
/* All Tex coordinate were added */
glTexCoord2f(0.0,0.0);
glVertex3f(-100.0f, 0.0f, -100.0f);
glTexCoord2f(0.0,1.0);
glVertex3f(-100.0f, 0.0f, 100.0f);
glTexCoord2f(1.0,1.0);
glVertex3f( 100.0f, 0.0f, 100.0f);
glTexCoord2f(1.0,0.0);
glVertex3f( 100.0f, 0.0f, -100.0f);
glEnd();

glTranslatef(0,1.75,0);
for(l =-5;l<5;l++)
{
for(m=-5;m<5;m++)
{
glPushMatrix();
glTranslatef(l*10.0,0.0,m*10.0);
if(l%2 == 0 && m%2 == 0)
{
draw_pole();
}
else
{
draw_barn();
}
glPopMatrix();
}
}
}

draw_pole()
{