i have ever tried in the beginner forum but nobody manage to found the error.
i have a black window when i execute the program which read in a .ase file.
this program is supposed to display the object which is in the file.
i have tested the function “lecture” (which read in the .ase file) and it works.
this is the code :
#include <stdio.h>
#include <iostream.h>
#include <string.h>
#include <GL/glut.h>
#define nb_vertices 697
char tmp [100] ;
int temp [nb_vertices] ;
char chaine [100] ;
float tab_vertices [nb_vertices][3] ;
int i, j ;
char nom_fichier[] = "cool.ase" ;
void lecture ()
{
FILE *cool ; //pointeur sur le fichier cool
if ((cool = fopen(nom_fichier, "r")) == NULL)
return ;
strcpy (chaine , "*MESH_VERTEX") ;
do
{
fscanf(cool, "%s", tmp) ;
}
while (strcmp (chaine, tmp) != 0) ;
for (i = 0; i < nb_vertices ;i++)//rempli le tableau avec des coordonnées de vertices
{
fscanf (cool, "%d%f%f%f%s", &(temp[0]) , &(tab_vertices[i][0]), &(tab_vertices[i][1]), &(tab_vertices[i][2]), tmp) ;
//cout << tab_vertices[i][0]<<" "<< tab_vertices[i][1]<<" "<< tab_vertices[i][2]<<endl ;
}
fclose (cool) ;
}
void reshape (int w, int h)
{
glViewport (0, 0, w, h) ;
glMatrixMode (GL_PROJECTION) ;
glLoadIdentity () ;
glFrustum(-100.0 , 100.0, -100.0, 100.0, 5.0, 500.0); //perspective conique
glMatrixMode(GL_MODELVIEW); //la matrice active de modelisation/visualisation sera affectée
glLoadIdentity(); //charge la matrice identité
gluLookAt (0.0, 0.0, 100.0, 0.0,0.0,0.0, 0.0, 1.0, 0.0) ; //caméra placée sur l'axe des Z et regardant vers l'origine
}
void display ()
{
glEnableClientState (GL_VERTEX_ARRAY);
glVertexPointer (3, GL_FLOAT, 0, &tab_vertices[0][0]);
glPolygonMode (GL_FRONT_AND_BACK, GL_LINE) ;
glClear (GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT ) ;
for (j = 0 ; j <nb_vertices; j++)
{
glBegin (GL_TRIANGLES);
glArrayElement (j);
glEnd () ;
}
glutSwapBuffers() ;
}
void main (int argc, char** argv)
{
lecture () ;
glutInit (&argc, argv) ;
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH) ;
glutInitWindowSize (640, 480) ;
glutInitWindowPosition (250,250) ;
glutCreateWindow (argv [0]) ;
glEnable( GL_DEPTH_TEST );
glutReshapeFunc (reshape) ;
glutDisplayFunc (display) ;
glutMainLoop () ;
}
[This message has been edited by airseb (edited 12-31-2002).]