Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1158 connectés 

  FORUM HardWare.fr
  Programmation
  C++

  [open gl] pourquoi mon programme n'affiche rien ?

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[open gl] pourquoi mon programme n'affiche rien ?

n°277929
airseb
Posté le 31-12-2002 à 19:11:02  profilanswer
 

Une fenètre apparait, elle est complétement vide, même pas une couleur à l'intérieur !
pouvez vous m'aider a trouver l'erreur ?
voici le code :
 
 

Code :
  1. #include <stdio.h>
  2. #include <iostream.h>
  3. #include <string.h>
  4. #include <GL/glut.h>
  5. #define nb_vertices 697
  6. char tmp [100] ;
  7. int temp [nb_vertices] ;
  8. char chaine [100] ;
  9. float tab_vertices [nb_vertices][3] ;
  10. int i, j ;
  11. char nom_fichier[] = "cool.ase" ;
  12. void lecture ()
  13. {
  14. FILE *cool ; //pointeur sur le fichier cool
  15. if ((cool = fopen(nom_fichier, "r" )) == NULL)
  16. return ;
  17. strcpy (chaine , "*MESH_VERTEX" ) ;
  18. do
  19. {
  20. fscanf(cool, "%s", tmp) ;
  21. }
  22. while (strcmp (chaine, tmp) != 0) ;
  23. for (i = 0; i < nb_vertices ;i++)//rempli le tableau avec des coordonnées de vertices
  24. {
  25. fscanf (cool, "%d%f%f%f%s", &(temp[0]) , &(tab_vertices[i][0]), &(tab_vertices[i][1]), &(tab_vertices[i][2]), tmp) ;
  26. //cout << tab_vertices[i][0]<<" "<< tab_vertices[i][1]<<" "<< tab_vertices[i][2]<<endl ;
  27. }
  28. fclose (cool) ;
  29. }
  30. void reshape (int w, int h)
  31. {
  32. glViewport (0, 0, w, h) ;
  33. glMatrixMode (GL_PROJECTION) ;
  34. glLoadIdentity () ;
  35. glFrustum(-1.0 , 1.0, -1.0, 1.0, 5.0, 500.0); //perspective conique
  36. glMatrixMode(GL_MODELVIEW); //la matrice active de modelisation/visualisation sera affectée
  37. glLoadIdentity(); //charge la matrice identité
  38. 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
  39. }
  40. void display ()
  41. {
  42. glEnableClientState (GL_VERTEX_ARRAY);
  43. glVertexPointer (3, GL_FLOAT, 0, &tab_vertices[0][0]);
  44. glPolygonMode (GL_FRONT, GL_LINE) ;
  45. for (j = 0 ; j <nb_vertices; j++)
  46. {
  47. glBegin (GL_TRIANGLES);
  48. glArrayElement (j);
  49. glEnd () ;
  50. }
  51. glutSwapBuffers() ;
  52. }
  53. void main (int argc, char** argv)
  54. {
  55. lecture () ;
  56. glutInit (&argc, argv) ;
  57. glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH) ;
  58. glutInitWindowSize (640, 480) ;
  59. glutInitWindowPosition (250,250) ;
  60. glutCreateWindow (argv [0]) ;
  61. glClearColor (0.0, 0.0, 0.0, 0.0) ;
  62. glClear (GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT ) ;
  63. glEnable( GL_DEPTH_TEST );
  64. glutReshapeFunc (reshape) ;
  65. glutDisplayFunc (display) ;
  66. glutMainLoop () ;
  67. }


Message édité par airseb le 31-12-2002 à 23:40:20
mood
Publicité
Posté le 31-12-2002 à 19:11:02  profilanswer
 

n°277944
airseb
Posté le 31-12-2002 à 23:40:40  profilanswer
 

:sweat:  :hello:

n°278007
airseb
Posté le 01-01-2003 à 15:02:41  profilanswer
 

up  :(

n°278042
chrisbk
-
Posté le 01-01-2003 à 16:25:01  profilanswer
 

Code :
  1. for (j = 0 ; j <nb_vertices; j++)
  2.     {
  3.       glBegin (GL_TRIANGLES);
  4.       glArrayElement (j);
  5.       glEnd () ;
  6.     }


 
[:wam]
 
heuh a mon avis, tu fais un glBegin() avant la loop et un apres, mais pas un par vtx
 
ensuite je ne sais pas si ton utilisation de glArrayElement est correcte, repenche toi sur la doc


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  C++

  [open gl] pourquoi mon programme n'affiche rien ?

 

Sujets relatifs
[open gl] affichage d'objetsProgramme Renommer .jpg en .mp3
[ éditeur ] - C'est quoi votre éditeur de programme ?j'ai un probleme bizarre avec mon programme qui lit dans un fichier
[C] arreter un programme proprement[Delphi] Comment savoir si mon programme est actif ?
[Linux] Utiliser une commande dans un programme(lire dans un fichier ascii) pourquoi mon programme ne marche pas ?
[XML] des balises ouvertes puis fermées dans rien entre les 2 on peut?Programme en mode console avec C++ Builder !
Plus de sujets relatifs à : [open gl] pourquoi mon programme n'affiche rien ?


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR