PDA

View Full Version : Strange looking triangles



03-15-2005, 11:54 PM
I'm having troubles when drawing small triangles in a scene. They triangles doesn't look good, they look crooked even though the coordinates specifies a straight triangle.

What can be wrong? And how can I fix it?

I wonder if setting glMatrixMode to GL_PROJECTION may cause the problem?

I guess this is quite elementary but I would really appreciate any help.

Thanks in advance.

03-16-2005, 02:57 AM
You should post the code, we cannot help you if we do not know what you have done.

dvm
03-16-2005, 06:05 PM
do post code
...but yes not setting up a proper projection or modelview matrix would result in this behavior.

03-21-2005, 11:05 PM
This is what I do before i draw the triangles

glClearColor(0.0,0.0,0.0,1.0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(0.0,WIDTH,0.0,HEIGHT,1,1.5);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glTranslatef(0,0,-1.0010);

// draw triangles

WIDTH and HEIGHT variables are set to the width and height of the window. When I change the size of the window the appearance of the triangles change.

mikael_aronsson
03-22-2005, 03:03 AM
glFrustum( -(WIDTH/2.0), WIDTH/2.0, -(HEIGHT/2.0), HEIGHT/2.0, near, far);

And you might want to use lower/higher values for the clipping planes to make sure you don't clip the triangles.

Mikael