PDA

View Full Version : Can you help me with glortho and the camera ?



airseb
06-30-2002, 01:20 PM
this is my program :

#include <GL/glut.h>
#include <stdlib.h>

#define X .525731112119133606
#define Z .850650808352039932


void display ()
{
static GLfloat tableau_entrelace [] = {1.0, 1.0, 1.0, -X, 0.0, Z, 1.0, 1.0, 1.0, X, 0.0, Z,
1.0, 1.0, 1.0, -X, 0.0, -Z,1.0, 1.0, 1.0, X, 0.0, -Z, 1.0, 1.0, 1.0, 0.0, Z, X,
1.0, 1.0, 1.0, 0.0, Z, -X, 1.0, 1.0, 1.0, 0.0, -Z, X, 1.0, 1.0, 1.0, 0.0, -Z, -X,
1.0, 1.0, 1.0, Z, X, 0.0, 1.0, 1.0, 1.0, -Z, X, 0.0,1.0, 1.0, 1.0, Z, -X, 0.0,
1.0, 1.0, 1.0, -Z, -X, 0.0} ;

glInterleavedArrays (GL_C3F_V3F, 0, tableau_entrelace) ;

static GLuint indices [20][3]= {1,4,0,4,9,0,4,5,9,8,5,4,1,8,4,1,10,8,10,3,8,8,3,5 ,3,2,5,
3,7,2,3,10,7,10,6,7,6,11,7,6,0,11,6,1,0,10,1,6,11, 0,9,2,11,9,5,2,9,11,2,7};

glPolygonMode (GL_FRONT, GL_LINE) ;
glFrontFace (GL_CCW) ;
glEnable (GL_CULL_FACE) ;
glCullFace (GL_BACK) ;

glDrawElements (GL_TRIANGLES, 60, GL_UNSIGNED_BYTE, indices) ;

glutSwapBuffers() ;
glFlush () ;
}

void main (int argc, char** argv)

{
glutInit (&argc, argv) ;
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH) ;
glutInitWindowSize (640, 480) ;
glutInitWindowPosition (250,250) ;
glutCreateWindow (argv [0]) ;

glClearColor (0.0, 0.0, 0.0, 0.0) ;
glClear (GL_COLOR_BUFFER_BIT) ;

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

glOrtho(-10.0 , 10.0, -10.0, 10.0, -5.0, 20.0);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glutDisplayFunc (display) ;
glutMainLoop () ;

}

john
06-30-2002, 04:27 PM
y-e-s... that looks like a program to me! some dialect of C, if I'm not mistaken.

airseb
06-30-2002, 09:36 PM
but i don't work, we don't see the whole object