PDA

View Full Version : why my triangles can be seen in the window?



06-21-2001, 10:29 PM
i am a beginner. This is my code:

glClearColor(0.3f,0.6f,0.7f,1.0f);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);


glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
glLineWidth(1.0f);
glColor3f(0.0f,0.0f,0.0f);

glPushMatrix();
for (int i=0;i<(Numplanes-1);i++)
glBegin(GL_TRIANGLE_STRIP);
for (int j=0;j<(NumPointsOnPlane);j++)
{
glVertex3d(a[i][j],b[i][j],c[i][j]);
glVertex3d(a[i+1][j],b[i+1][j],c[i+1][j]); } glVertex3d(a[i][0],b[i][0],c[i][0]); glVertex3d(a[i+1][j],b[i+1][j],c[i+1][j]);
glEnd();
}


and a={3.7558881e+02 3.7241258e+02
-3.6916080e+02 -3.7014718e+02 ....}
b=
{2.0283400e+03 2.0298425e+03
2.0315526e+03 2.0330736e+03 ....}

c={-1.6000000e+02 -1.6000000e+02
-1.6000000e+02 -1.6000000e+02
...
}


I think there are something wrong,but i don't know where it is .
could you help me ?

thank you very much.

ffish
06-21-2001, 11:07 PM
You have to setup your window in your Resize() function so that a whole triangle can be seen. I usually use glFrustum so I'd have something like this:



// glFrustum(left, right, top, bottom, near, far);
glFrustum(-400.0f, 400.0f, 400.0f, 400.0f, 10.0f, 1000.0f);

Hope that helps.

Julio
06-22-2001, 03:39 AM
Maybe try this code adjustment. Everytime you change the state it is the same as rendering thousands of triangles. maybe try this:
glBegin(GL_TRIANGLE_STRIP);
for (int i=0;i<(Numplanes-1);i++)
for (int j=0;j<(NumPointsOnPlane);j++)
{
glVertex3d(a[i][j],b[i][j],c[i][j]);
glVertex3d(a[i+1][j],b[i+1][j],c[i+1][j]); } glVertex3d(a[i][0],b[i][0],c[i][0]); glVertex3d(a[i+1][j],b[i+1][j],c[i+1][j]);
}
glEnd();

06-27-2001, 05:01 PM
Thank you all.
I've solved problem now.
I can't see my triangles because I set wrong Frustum, and my triangles were out of viewport. http://www.opengl.org/discussion_boards/ubb/smile.gif