my program display nothing !

a window appears but there is nothing in, even not a black color.
can you help me please !

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 &lt; 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 &lt;&lt; tab_vertices[i][0]&lt;&lt;" "&lt;&lt; tab_vertices[i][1]&lt;&lt;" "&lt;&lt; tab_vertices[i][2]&lt;&lt;endl ;
	
}

 fclose (cool) ;

}
void reshape (int w, int h)
{
glViewport (0, 0, w, h) ;
glMatrixMode (GL_PROJECTION) ;
glLoadIdentity () ;
glFrustum(-1.0 , 1.0, -1.0, 1.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, 50.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, GL_LINE) ;

	for (j = 0 ; j &lt;nb_vertices; j++)
	{
		glBegin (GL_TRIANGLES);
			glArrayElement (j);
		glEnd () ;
	}
}

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]) ;

glClearColor (0.0, 0.0, 0.0, 0.0) ;
glClear (GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT ) ;
glEnable( GL_DEPTH_TEST );

glutReshapeFunc (reshape) ;
glutDisplayFunc (display) ;
glutMainLoop () ;

}

[This message has been edited by airseb (edited 12-31-2002).]

Try enabling Depth_Test and glClear in your Display Function.

Ex: Take these functions and put them in your Display Function:
glClearColor (0.0, 0.0, 0.0, 0.0) ;
glClear (GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT ) ;
glEnable( GL_DEPTH_TEST );

Edit:
Change your glutInitDisplayMode Function to this.
glutInitDisplayMode( GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH );

  • VC6-OGL

[This message has been edited by VC6-OGL (edited 12-31-2002).]

thanks !
but now i have a black windows without the object that i want to display.

i think that the error come from the values of glFrustum but i’m not sure and i don’t know the values which i have to put. can you help me ?

well we dont have this file you are loading. so i dont think anybody is going to get anything but a black screen

when i tried your code i got a clear screen too. glClear and depth testing are fine. what you forgot is a glFlush(); in your display function. Now i get a black screen but i need that file or something to provide anymore help

Are you sure you are loading the *.ase file in your program correctly? Have you seen the program work before? What is the program supposed to do or look like?

  • VC6-OGL

[This message has been edited by VC6-OGL (edited 12-31-2002).]

If you want to enable Double Buffering, do the following,

Change your glutInitDisplayMode to:
· glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );

And at the end of your Display Function, add:
· glFlush();
· glutSwapBuffers();

  • VC6-OGL

Originally posted by VC6-OGL:
[b]Are you sure you are loading the *.ase file in your program correctly? Have you seen the program work before? What is the program supposed to do or look like?

  • VC6-OGL

[This message has been edited by VC6-OGL (edited 12-31-2002).][/b]

the program with the ase file work, i have tested it before by displaying the datas about meshes.

don’t you think that there is an error with glFrustum ?i have put the values a little randomly. Or is it glVertexPointer that just allow an array of one dimension instead of two ?

[his message has been edited by airseb (edited 12-31-2002).]

[This message has been edited by airseb (edited 12-31-2002).]

It might be your glFrustum, a needed gluPerspective or gluLookAt isn’t set in the right coordinates.

  • VC6-OGL

do you a method to find the right values, for glFrustum or gluLookAt ?

No, but I tried using gluLookAt and gluPerspective and I had no success.

If you want to load an *.ase file, try: http://www.gametutorials.com/download/OpenGL/ASELoader_OGL.zip

  • VC6-OGL

[This message has been edited by VC6-OGL (edited 12-31-2002).]

the program that read in the ase file work, i have retested it by deleting the // before the cout in the function “lecture”.

I’m far from being an expert in OpenGL but from what I know about black screen maybe I can help you.

When you’re using glFrustum you must set the near and the far parameters(the last two params) to value greater than zeros fo it to work.

This as for effect that everything to be visible must either be at -$near or the camera must be at -$near. Otherwise the camera is outside the scene I think.

Try setting the z position of the camera at -5.0f with either gluLookAt or do a glTranslatef(0.0f,0.0f,-5.0f) before drawing the scene.

Maybe I’m completely wrong but I’ve had many black screen and this was often the cause of it.

Read The OpenGL Programming RedBook for more details about glOrtho and glFrustum you’ll see how they differs in rendering the scene on other aspect than perpective. Look at gluPerspective it is often simpler to use than glFrustum and it is offers equivalents renderings.

Mr Pink