Advertisement

lost in opengl please help

Started by February 25, 2000 06:52 PM
3 comments, last by ECKILLER 24 years, 6 months ago
ok i''m trying to simply render a mesh pyramid but i cant even get the face down. Please tell whats wrong with this code(note its just a fragment): glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glBegin(GL_TRIANGLES); // draw face glVertex3f( 0.0f*diff, 1.0f*diff, 0.0f*diff); glVertex3f( 1.0f*diff, 0.0f*diff, 1.0f*diff); glVertex3f(-1.0f*diff, 0.0f*diff, 1.0f*diff); glEnd(); this is to draw my face of the triangle but alls i am gettiing is a horizontal line. Now some interesting things. If i rotate a certain way i actually get 4 sides sometimes. Anyway you probably need my reshape code: void reshape(int w, int h) { glViewport(0, 0, (GLsizei)w, (GLsizei)h); // sets the current matrix mode glMatrixMode(GL_PROJECTION); // replaces the current matrix with the identity //matrix glLoadIdentity(); // specifies the clipping volume are objects can //take place in glFrustum(-10.0f, 10.0f, -10.0f, 10.0f, 1.0, 20.0); // sets the current matrix mode glMatrixMode(GL_MODELVIEW); // replaces the current matrix with the identity //matrix glLoadIdentity(); } I''ve written the coords on paper and tey all seem fine. whats up?? ECKILLER
ECKILLER
The proplem is that you have placed the camera too close to the pyramid, perhaps even inside. Your frustum call tells OpenGL to clip everything that is closer than 1 unit. The horizontal line you see is the one that goes from (1,0,1) to (-1,0,1), assuming diff == 1.

Try translating it out of the pyramid with

glTranslatef(0, -0.5f, -3);

The call should be made last in reshape.

Edited by - Spellbound on 2/25/00 7:08:06 PM
Advertisement
that doesnt make since to me. If i can see the horizontal line (1,0,1) to (-1,0,1), then i would be able to see the whole tiangle since the tip is at 0,1,0 which is behind the horizontal line. Also i didn''t include it in my first post but i called a translate (0,0,-5) in the beginning of the render function. Still don''t get it.

ECKILLER
ECKILLER
My mistake, I forgot that OpenGL uses a right handed system, as opposed to DirectX''s left handed model. This means that positive Z-coordinates are behind the camera.
I think You''re right Spellbound.

After all, all you can see is that line from 1,0,1 to -1,0,1.

The frustum you specify is in my opinion a frustum in negative z-space. So you actually clip from -1 to -20 I think.

Did you try to translate ( 0, 0, 5 ) ?

NextS

This topic is closed to new replies.

Advertisement