PDA

View Full Version : what is the problem with my little program ?



airseb
06-24-2002, 12:33 PM
#include <GL/glut.h>
#include <stdlib.h>


void display (void)
{


static GLint vertices [] = {1,1,0, 10,1,0, 1,10,0, 10,10,0, 1,1,10, 10,1,10, 1,10,10,
10,10,10};
static GLfloat colors_RGB [] = {1.0,0.2,0.2, 0.2,0.2,1.0, 0.8,1.0,0.2, 0.75,0.75,0.75,
0.35,0.35,0.35, 0.5,0.5,0.5};

glEnableClientState (GL_COLOR_ARRAY);
glEnableClientState (GL_VERTEX_ARRAY);
glColorPointer (3, GL_FLOAT, 0, colors_RGB);
glVertexPointer (3, GL_INT, 0, vertices);

static GLubyte toutLesSommets [] = { 1,2,3,4, 1,5,7,3, 1,5,6,2, 2,6,8,4, 3,7,8,4, 7,8,6,5};

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

glDrawElements (GL_QUADS, 24, GL_UNSIGNED_BYTE, toutLesSommets) ;

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 (1.0, 1.0, 1.0, 1.0) ;
glClear (GL_COLOR_BUFFER_BIT) ;

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

glOrtho (0.0, 1.0, 0.0, 1.0, -1.0, 1.0) ;

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glutDisplayFunc (display) ;
glutMainLoop () ;

}


[This message has been edited by airseb (edited 06-25-2002).]

TriangleMan
06-24-2002, 12:55 PM
Change Glint vertices to GLint vertices.

airseb
06-24-2002, 12:58 PM
yes thanks but i have changed it and it appears a black window with nothing in !
what's wrong ?

JML
06-24-2002, 08:57 PM
Make sure your projection and modelview matrices are setup with the correct values. You are probably drawing your scene outside of the viewing frustum.

Jean-Marc.

airseb
06-25-2002, 12:35 AM
i have changed the program but there still a black window that appear, there is still another error or is it glortho which is wrong (i have writen wrong values because i don't know to use this function)
can you help me for that please ?

Bob
06-25-2002, 12:41 AM
Your view volume is a cube that extents from (0, 0, -1) to (1, 1, 1). The thing you draw is way larger that that. Look at the cooridnates. They range from 1 to 10 on the X ans Y axis, which is outside the view volume.

[This message has been edited by Bob (edited 06-25-2002).]

coredump
06-25-2002, 04:48 AM
static GLubyte toutLesSommets [] = { 1,2,3,4, 1,5,7,3, 1,5,6,2, 2,6,8,4, 3,7,8,4, 7,8,6,5};


i think your problem is that this variable is in French!

j/k http://www.opengl.org/discussion_boards/ubb/wink.gif

b