Précédent   Forum du club des développeurs et IT Pro > Applications > Développement 2D, 3D et Jeux > API graphiques > OpenGL
OpenGL Forum d'entraide sur le développement en OpenGL. Avant de poster -> FAQ OpenGL
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 25/12/2012, 18h11   #1
FoX_*D i E*
Membre du Club
 
Inscription : septembre 2007
Messages : 160
Détails du profil
Informations personnelles :
Âge : 26

Informations forums :
Inscription : septembre 2007
Messages : 160
Points : 54
Points : 54
Par défaut Problème d'affichage sur certains ordi

Bonjour,

J'ai développé un pseudo jeu vidéo en C utilisant la bibliothèque OpenGL. C'est un projet libre pour un cours de robotique.

Sur mon PC Windows et Linux, tout s'affiche bien et le refresh rate (indiqué en haut a gauche pendant la partie) est autour de 25 donc fluide.

Le ploblème c'est que lorsque on tourne le jeu sur un autre ordi, soit le refresh rate est de 4 (pas fluide), soit les objets s'affichent mal, soit un objet et la caméra doivent etre proche pour l'afficher correctement ; ou soit les trois.

J'utilisais Code::Blocks 10.05 sur Windows (je n'ai pas testé l'execution un autre PC linux), j'ai bien linké : glut32 opengl32 glu32 winmm gdi32 "libfmod.a"

A cette url, vous trouverez "afficher les image" et "visionner la vidéo de présentation" pour voir ce que ca me donne sur mon ordi ''compilateur'', et enfin le jeu a telecharger.

http://hammoutene.free.fr/amir/project.html#linkrobot


Quels sont les problèmes a vos avis ?
FoX_*D i E* est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/12/2012, 10h02   #2
dragonjoker59
Membre Expert
 
Homme Sylvain DOREMUS
Développeur informatique
Inscription : juin 2005
Messages : 645
Détails du profil
Informations personnelles :
Nom : Homme Sylvain DOREMUS
Âge : 31
Localisation : France, Alpes de Haute Provence (Provence Alpes Côte d'Azur)

Informations professionnelles :
Activité : Développeur informatique
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : juin 2005
Messages : 645
Points : 1 549
Points : 1 549
Envoyer un message via MSN à dragonjoker59
Sur mon PC le frame rate est de 29, ce qui n'est quand même pas très élevé pour le nombre de polys apparents.
Peux-tu montrer tes fonctions de dessin ? (parce que sans ça on va avoir le plus grand mal à t'aider)
__________________
Si vous ne trouvez plus rien, cherchez autre chose...

Chef de projet (et unique exécutant pour l'instant) pour Castor 3D
dragonjoker59 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/12/2012, 11h21   #3
FoX_*D i E*
Membre du Club
 
Inscription : septembre 2007
Messages : 160
Détails du profil
Informations personnelles :
Âge : 26

Informations forums :
Inscription : septembre 2007
Messages : 160
Points : 54
Points : 54
je ne vois pas ce que tu veux dire par fonction dessin. Il y a plus de 3K lignes de code pour ce programme et la plupart servent à dessiner la salle, le robot et les objets
FoX_*D i E* est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/12/2012, 14h07   #4
dragonjoker59
Membre Expert
 
Homme Sylvain DOREMUS
Développeur informatique
Inscription : juin 2005
Messages : 645
Détails du profil
Informations personnelles :
Nom : Homme Sylvain DOREMUS
Âge : 31
Localisation : France, Alpes de Haute Provence (Provence Alpes Côte d'Azur)

Informations professionnelles :
Activité : Développeur informatique
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : juin 2005
Messages : 645
Points : 1 549
Points : 1 549
Envoyer un message via MSN à dragonjoker59
Utilises-tu glBegin() ... glEnd() ?
Quelles optimisations GPU utilises-tu (display list, vertex array, VBO, VAO) ?
Quelle est la configuration des postes sur lesquels tu as ces ralentissements ?
__________________
Si vous ne trouvez plus rien, cherchez autre chose...

Chef de projet (et unique exécutant pour l'instant) pour Castor 3D
dragonjoker59 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/12/2012, 17h46   #5
FoX_*D i E*
Membre du Club
 
Inscription : septembre 2007
Messages : 160
Détails du profil
Informations personnelles :
Âge : 26

Informations forums :
Inscription : septembre 2007
Messages : 160
Points : 54
Points : 54
Bonjour,
oui j'utilise souvent glbegin et glend

pour la config du PC ou ca ralenti, qu'est ce que je regarde ? je peux te dire que sur l'ordi ou ca ralenti (9 en refresh rate) c un Windows 7 processeur GenuineIntel, 1.30GHz, ram 3Go, 64 bits
et sur le PC compilateur (35 en refresh rate) c un Windows 7 processeur Intel Core 2 Duo CPU T6600, 2.20GHz, ram 4Go, 64 bits
les PC ou ca affiche mal les objets je n'ai pas les config

je ne sais pas bien si ca repond à ta question sur l'optimisation mais je suis allé (sur CodeBlocks) dans Build Option, Release, Compiler setting, Compiler Flags, selection de la liste Optimization et j'ai cela de coché :

-s et -O2

bonne fêtes ^^
FoX_*D i E* est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/12/2012, 19h50   #6
FoX_*D i E*
Membre du Club
 
Inscription : septembre 2007
Messages : 160
Détails du profil
Informations personnelles :
Âge : 26

Informations forums :
Inscription : septembre 2007
Messages : 160
Points : 54
Points : 54
voila un bon de mon code :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
int main(int argc , char **argv)
{
    FSOUND_Init(44100, 32, 0);
    glutInit(&argc,argv);
    Initialise();  /* Fonction à écrire pour initialiser la machine OpenGL */
    glutKeyboardFunc(Keyboard);
    glutSpecialFunc(SpecialKeyboard);
    glutKeyboardUpFunc(KeyboardUp);
    glutSpecialUpFunc(SpecialKeyboardUp);
    glutDisplayFunc(DrawScene);  /* fonction à appeler avec la fonction principale de rendu à écrire */
    glutReshapeFunc(Resize);
    loadSample(1,"audio/walker.mp3");
    loadSample(2,"audio/batwing.mp3");
    loadSample(3,"audio/car.mp3");
    loadSample(4,"audio/falco.mp3");
    loadSample(5,"audio/pika.mp3");
    loadSample(6,"audio/rabbid.mp3");
    FSOUND_SetVolume (1, 0);
    FSOUND_SetVolume (2, 0);
    FSOUND_SetVolume (3, 0);
    FSOUND_SetVolume (4, 0);
    FSOUND_SetVolume (5, 0);
    FSOUND_SetVolume (6, 0);
    glutMainLoop(); /* Fonction de boucle infinie */
    FSOUND_Close ();
    return 0;
}
 
GLvoid Initialise()
{
    int i;
    glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF);
    for(i=0;i<7;i++) keyPressed[i]=0;
    GLvoid DefineWindow(char *);
    glutInitDisplayMode( GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE );
    DefineWindow("Elbow Manipulator");
    glPointSize(5.f);
    glLineWidth(3.f);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_BLEND);
    glEnable(GL_POINT_SMOOTH);
    glEnable(GL_LINE_SMOOTH);
    glDisable(GL_CULL_FACE );
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
    glPolygonMode(GL_FRONT_AND_BACK,GL_FILL );
    glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,25.f);
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
 
 
 
    DefineLight(4);
    loadView();
 
  glGetFloatv(GL_MODELVIEW_MATRIX, TrMatrix);
 
    OBJallmalloc();
   AF4loaded = ReadOBJModel ("models/Humanoid_Bird_by_FryeLock.obj",AF4);
   AF6loaded = ReadOBJModel ("models/Sonic_by_Dr._MECha.obj",AF6);
   AF5loaded = ReadOBJModel ("models/pikachu_by_Yusuf_ES.obj",AF5);
   AF7loaded = ReadOBJModel ("models/rabbids-ubisoft_by_jondiyolahe.obj",AF7);
   V2loaded = ReadOBJModel ("models/ati_walker_by_Saturnix.obj",V2);
   V3loaded = ReadOBJModel ("models/Batwing_by_crocobaura.obj",V3);
   V5loaded = ReadOBJModel ("models/Hyundai_Coupe_by_petomavar.obj",V5);
 
   Boxloaded = ReadOBJModel ("models/CartonBox_out_by_JCihelka.obj",Box);
   hatloaded = ReadOBJModel ("models/Hat_by_3d_Wanderer.obj",hat);
   sherlockloaded = ReadOBJModel ("models/MagnifyingGlass_by_Will_LaPuerta.obj",sherlock);
time (&timeold);
time (&timenow);
    startclock = clock();
 
 
}
 
GLvoid Resize(GLsizei WindowWidth , GLsizei WindowHeight  )
{
    glViewport( 0, 0,WindowWidth , WindowHeight) ;
    ratio = (GLdouble)  WindowWidth /  (GLdouble)WindowHeight;
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(45.,ratio,0.0001,10.);
    glMatrixMode(GL_MODELVIEW);
 
}
FoX_*D i E* est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 27/12/2012, 08h56   #7
dragonjoker59
Membre Expert
 
Homme Sylvain DOREMUS
Développeur informatique
Inscription : juin 2005
Messages : 645
Détails du profil
Informations personnelles :
Nom : Homme Sylvain DOREMUS
Âge : 31
Localisation : France, Alpes de Haute Provence (Provence Alpes Côte d'Azur)

Informations professionnelles :
Activité : Développeur informatique
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : juin 2005
Messages : 645
Points : 1 549
Points : 1 549
Envoyer un message via MSN à dragonjoker59
Déjà, si tu stockes tes modèles dans des VBO ça ira beaucoup mieux (glBegin ... glEnd c'est déprécié depuis pas mal de temps déjà). Tu devrais commencer par là, je pense.
__________________
Si vous ne trouvez plus rien, cherchez autre chose...

Chef de projet (et unique exécutant pour l'instant) pour Castor 3D
dragonjoker59 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 27/12/2012, 12h06   #8
FoX_*D i E*
Membre du Club
 
Inscription : septembre 2007
Messages : 160
Détails du profil
Informations personnelles :
Âge : 26

Informations forums :
Inscription : septembre 2007
Messages : 160
Points : 54
Points : 54
Bonjour,

je ne connais pas ce jargon, VBO?
j'ai cherché sur le net ca ne m'a pas parut clair
voila des bouts de mon code liés au stockage des objet :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
obj_model_t *AF4;
 obj_model_t *AF6;
 obj_model_t *AF5;
 obj_model_t *AF7;
 
 obj_model_t *V2;
 obj_model_t *V3;
 obj_model_t *V5;
 
 obj_model_t *hat;
 obj_model_t *sherlock;
 
 obj_model_t *Box;
 
typedef struct
{
  int num_verts;              /* number of vertices */
  int num_texCoords;          /* number of texture coords. */
  int num_normals;            /* number of normal vectors */
  int num_faces;              /* number of polygons */
 
  int has_texCoords;          /* has texture coordinates? */
  int has_normals;            /* has normal vectors? */
 
  obj_vertex_t *vertices;     /* vertex list */
  obj_texCoord_t *texCoords;  /* tex. coord. list */
  obj_normal_t *normals;      /* normal vector list */
  obj_face_t *faces;          /* model's polygons */
 
} obj_model_t;
 
 
OBJallmalloc();
   AF4loaded = ReadOBJModel ("models/Humanoid_Bird_by_FryeLock.obj",AF4);
   AF6loaded = ReadOBJModel ("models/Sonic_by_Dr._MECha.obj",AF6);
   AF5loaded = ReadOBJModel ("models/pikachu_by_Yusuf_ES.obj",AF5);
   AF7loaded = ReadOBJModel ("models/rabbids-ubisoft_by_jondiyolahe.obj",AF7);
   V2loaded = ReadOBJModel ("models/ati_walker_by_Saturnix.obj",V2);
   V3loaded = ReadOBJModel ("models/Batwing_by_crocobaura.obj",V3);
   V5loaded = ReadOBJModel ("models/Hyundai_Coupe_by_petomavar.obj",V5);
 
   Boxloaded = ReadOBJModel ("models/CartonBox_out_by_JCihelka.obj",Box);
   hatloaded = ReadOBJModel ("models/Hat_by_3d_Wanderer.obj",hat);
   sherlockloaded = ReadOBJModel ("models/MagnifyingGlass_by_Will_LaPuerta.obj",sherlock);
 
 
void OBJallmalloc()
{
 
    AF4 = (obj_model_t *)malloc (sizeof (obj_model_t));
    AF6 = (obj_model_t *)malloc (sizeof (obj_model_t));
    AF7 = (obj_model_t *)malloc (sizeof (obj_model_t));
    AF5 = (obj_model_t *)malloc (sizeof (obj_model_t));
 
    V2 = (obj_model_t *)malloc (sizeof (obj_model_t));
    V3 = (obj_model_t *)malloc (sizeof (obj_model_t));
    V5 = (obj_model_t *)malloc (sizeof (obj_model_t));
 
    sherlock = (obj_model_t *)malloc (sizeof (obj_model_t));
    hat = (obj_model_t *)malloc (sizeof (obj_model_t));
    Box = (obj_model_t *)malloc (sizeof (obj_model_t));
}
 
 
int ReadOBJModel (const char *filename, obj_model_t *mdl)
{
  FILE *fp;
  fprintf (stderr, "\nLoading \"%s\"...\n", filename);
  fp = fopen (filename, "r");
  if (!fp)
    {
      fprintf (stderr, "error: couldn't open \"%s\"!\n", filename);
      return 0;
    }
 
  /* reset model data */
  memset (mdl, 0, sizeof (obj_model_t));
 
  /* first pass: read model info */
  if (!FirstPass (fp, mdl))
    {
      fclose (fp);
      return 0;
    }
 
  rewind (fp);
 
  /* memory allocation */
  if (!MallocModel (mdl))
    {
      fclose (fp);
      FreeModel (mdl);
      return 0;
    }
 
  /* second pass: read model data */
  if (!SecondPass (fp, mdl))
    {
      fclose (fp);
      FreeModel (mdl);
      return 0;
    }
 
  fprintf (stderr, "Loaded: \"%s\"!\n\n", filename);
  fclose (fp);
  return 1;
}
 
 
 
void
FreeModel (obj_model_t *mdl)
{
  int i;
 
  if (mdl)
    {
      if (mdl->vertices)
	{
	  free (mdl->vertices);
	  mdl->vertices = NULL;
	}
 
      if (mdl->texCoords)
	{
	  free (mdl->texCoords);
	  mdl->texCoords = NULL;
	}
 
      if (mdl->normals)
	{
	  free (mdl->normals);
	  mdl->normals = NULL;
	}
 
      if (mdl->faces)
	{
	  for (i = 0; i < mdl->num_faces; ++i)
	    {
	      if (mdl->faces[i].vert_indices)
		free (mdl->faces[i].vert_indices);
 
	      if (mdl->faces[i].uvw_indices)
		free (mdl->faces[i].uvw_indices);
 
	      if (mdl->faces[i].norm_indices)
		free (mdl->faces[i].norm_indices);
	    }
 
	  free (mdl->faces);
	  mdl->faces = NULL;
	}
    }
}
 
 
int
MallocModel (obj_model_t *mdl)
{
  if (mdl->num_verts)
    {
      mdl->vertices = (obj_vertex_t *)
	malloc (sizeof (obj_vertex_t) * mdl->num_verts);
      if (!mdl->vertices)
	return 0;
    }
 
  if (mdl->num_texCoords)
    {
      mdl->texCoords = (obj_texCoord_t *)
	malloc (sizeof (obj_texCoord_t) * mdl->num_texCoords);
      if (!mdl->texCoords)
	return 0;
    }
 
  if (mdl->num_normals)
    {
      mdl->normals = (obj_normal_t *)
	malloc (sizeof (obj_normal_t) * mdl->num_normals);
      if (!mdl->normals)
	return 0;
    }
 
  if (mdl->num_faces)
    {
      mdl->faces = (obj_face_t *)
	malloc (sizeof (obj_face_t) * mdl->num_faces);
      if (!mdl->faces)
	return 0;
    }
 
  return 1;
}
 
int
FirstPass (FILE *fp, obj_model_t *mdl)
{
  int v, t, n;
  char buf[256];
 
  while (!feof (fp))
    {
      /* read whole line */
      fgets (buf, sizeof (buf), fp);
 
      switch (buf[0])
	{
	case 'v':
	  {
	    if (buf[1] == ' ')
	      {
		/* vertex */
		mdl->num_verts++;
	      }
	    else if (buf[1] == 't')
	      {
		/* texture coords. */
		mdl->num_texCoords++;
	      }
	    else if (buf[1] == 'n')
	      {
		/* normal vector */
		mdl->num_normals++;
	      }
	    else
	      {
		printf ("warning: unknown token \"%s\"! (ignoring)\n", buf);
	      }
 
	    break;
	  }
 
	case 'f':
	  {
	    /* face */
	    if (sscanf (buf + 2, "%d/%d/%d", &v, &n, &t) == 3)
	      {
		mdl->num_faces++;
		mdl->has_texCoords = 1;
		mdl->has_normals = 1;
	      }
	    else if (sscanf (buf + 2, "%d//%d", &v, &n) == 2)
	      {
		mdl->num_faces++;
		mdl->has_texCoords = 0;
		mdl->has_normals = 1;
	      }
	    else if (sscanf (buf + 2, "%d/%d", &v, &t) == 2)
	      {
		mdl->num_faces++;
		mdl->has_texCoords = 1;
		mdl->has_normals = 0;
	      }
	    else if (sscanf (buf + 2, "%d", &v) == 1)
	      {
		mdl->num_faces++;
		mdl->has_texCoords = 0;
		mdl->has_normals = 0;
	      }
	    else
	      {
		/* shloud never be there or the model is very crappy */
		fprintf (stderr, "error: found face with no vertex!\n");
	      }
 
	    break;
	  }
 
	case 'g':
	  {
	    /* group */
	    /*	fscanf (fp, "%s", buf); */
	    break;
	  }
 
	default:
	  break;
	}
    }
 
  /* check if informations are valid */
  if ((mdl->has_texCoords && !mdl->num_texCoords) ||
      (mdl->has_normals && !mdl->num_normals))
    {
      fprintf (stderr, "error: contradiction between collected info!\n");
      return 0;
    }
 
  if (!mdl->num_verts)
    {
      fprintf (stderr, "error: no vertex found!\n");
      return 0;
    }
/*
#if 1
  printf ("first pass results: found\n");
  printf ("   * %i vertices\n", mdl->num_verts);
  printf ("   * %i texture coords.\n", mdl->num_texCoords);
  printf ("   * %i normal vectors\n", mdl->num_normals);
  printf ("   * %i faces\n", mdl->num_faces);
  printf ("   * has texture coords.: %s\n", mdl->has_texCoords ? "yes" : "no");
  printf ("   * has normals: %s\n", mdl->has_normals ? "yes" : "no");
#endif
*/
  return 1;
}
 
int
SecondPass (FILE *fp, obj_model_t *mdl)
{
  obj_vertex_t *pvert = mdl->vertices;
  obj_texCoord_t *puvw = mdl->texCoords;
  obj_normal_t *pnorm = mdl->normals;
  obj_face_t *pface = mdl->faces;
  char buf[128], *pbuf;
  int i;
 
  while (!feof (fp))
    {
      /* read whole line */
      fgets (buf, sizeof (buf), fp);
 
      switch (buf[0])
	{
	case 'v':
	  {
	    if (buf[1] == ' ')
	      {
		/* vertex */
		if (sscanf (buf + 2, "%f %f %f %f",
			    &pvert->xyzw[0], &pvert->xyzw[1],
			    &pvert->xyzw[2], &pvert->xyzw[3]) != 4)
		  {
		    if (sscanf (buf + 2, "%f %f %f", &pvert->xyzw[0],
				&pvert->xyzw[1], &pvert->xyzw[2] ) != 3)
		      {
			fprintf (stderr, "error reading vertex data!\n");
			return 0;
		      }
		    else
		      {
			pvert->xyzw[3] = 1.0;
		      }
		  }
 
		pvert++;
	      }
	    else if (buf[1] == 't')
	      {
		/* texture coords. */
		if (sscanf (buf + 2, "%f %f %f", &puvw->uvw[0],
			    &puvw->uvw[1], &puvw->uvw[2]) != 3)
		  {
		    if (sscanf (buf + 2, "%f %f", &puvw->uvw[0],
				&puvw->uvw[1]) != 2)
		      {
			if (sscanf (buf + 2, "%f", &puvw->uvw[0]) != 1)
			  {
			    fprintf (stderr, "error reading texture coordinates!\n");
			    return 0;
			  }
			else
			  {
			    puvw->uvw[1] = 0.0;
			    puvw->uvw[2] = 0.0;
			  }
		      }
		    else
		      {
			puvw->uvw[2] = 0.0;
		      }
		  }
 
		puvw++;
	      }
	    else if (buf[1] == 'n')
	      {
		/* normal vector */
		if (sscanf (buf + 2, "%f %f %f", &pnorm->ijk[0],
			    &pnorm->ijk[1], &pnorm->ijk[2]) != 3)
		  {
		    fprintf (stderr, "error reading normal vectors!\n");
		    return 0;
		  }
 
		pnorm++;
	      }
 
	    break;
	  }
 
	case 'f':
	  {
	    pbuf = buf;
	    pface->num_elems = 0;
 
	    /* count number of vertices for this face */
	    while (*pbuf)
	      {
		if (*pbuf == ' ')
		  pface->num_elems++;
 
		pbuf++;
	      }
 
	    /* select primitive type */
	    if (pface->num_elems < 3)
	      {
		fprintf (stderr, "error: a face must have at least 3 vertices!\n");
		return 0;
	      }
	    else if (pface->num_elems == 3)
	      {
		pface->type = GL_TRIANGLES;
	      }
	    else if (pface->num_elems == 4)
	      {
		pface->type = GL_QUADS;
	      }
	    else
	      {
		pface->type = GL_POLYGON;
	      }
 
	    /* memory allocation for vertices */
	    pface->vert_indices = (int *)malloc (sizeof (int) * pface->num_elems);
 
	    if (mdl->has_texCoords)
	      pface->uvw_indices = (int *)malloc (sizeof (int) * pface->num_elems);
 
	    if (mdl->has_normals)
	      pface->norm_indices = (int *)malloc (sizeof (int) * pface->num_elems);
 
	    /* read face data */
	    pbuf = buf;
	    i = 0;
 
	    for (i = 0; i < pface->num_elems; ++i)
	      {
		pbuf = strchr (pbuf, ' ');
		pbuf++; /* skip space */
 
		/* try reading vertices */
		if (sscanf (pbuf, "%d/%d/%d",
			    &pface->vert_indices[i],
			    &pface->uvw_indices[i],
			    &pface->norm_indices[i]) != 3)
		  {
		    if (sscanf (pbuf, "%d//%d", &pface->vert_indices[i],
				&pface->norm_indices[i]) != 2)
		      {
			if (sscanf (pbuf, "%d/%d", &pface->vert_indices[i],
				    &pface->uvw_indices[i]) != 2)
			  {
			    sscanf (pbuf, "%d", &pface->vert_indices[i]);
			  }
		      }
		  }
 
		/* indices must start at 0 */
		pface->vert_indices[i]--;
 
		if (mdl->has_texCoords)
		  pface->uvw_indices[i]--;
 
		if (mdl->has_normals)
		  pface->norm_indices[i]--;
	      }
 
	    pface++;
	    break;
	  }
	}
    }
/*
#if 1
  printf ("second pass results: read\n");
  printf ("   * %i vertices\n", pvert - mdl->vertices);
  printf ("   * %i texture coords.\n", puvw - mdl->texCoords);
  printf ("   * %i normal vectors\n", pnorm - mdl->normals);
  printf ("   * %i faces\n", pface - mdl->faces);
#endif
*/
  return 1;
}
FoX_*D i E* est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 27/12/2012, 20h45   #9
dragonjoker59
Membre Expert
 
Homme Sylvain DOREMUS
Développeur informatique
Inscription : juin 2005
Messages : 645
Détails du profil
Informations personnelles :
Nom : Homme Sylvain DOREMUS
Âge : 31
Localisation : France, Alpes de Haute Provence (Provence Alpes Côte d'Azur)

Informations professionnelles :
Activité : Développeur informatique
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : juin 2005
Messages : 645
Points : 1 549
Points : 1 549
Envoyer un message via MSN à dragonjoker59
Le but d'un VBO (Vertex Buffer Object) est d'avoir ton buffer de vertex (donc toutes les informations les concernant : positio, normales, coordonnées de texture ...) stocké à même la mémoire de la carte graphique. Ca permet entre autres de ne l'envoyer à la carte qu'une fois puis de demander son dessin.
Il faut donc créer le buffer (glCreateBuffers).
Puis on l'active (glBindBuffer), on lui affecte ses données (glBufferData) et enfin on le désactive (là aussi glBindBuffer).
Un fois qu'il est rempli, à chaque boucle d'affichage tu l'actives (glBindBuffer) tu le dessines (glDrawElements) et tu le désactives (là aussi glBindBuffer).
Tu stockes donc un buffer (en fait son index retourné par glCreateBuffers) par objet que tu as.
Je te conseille aussi de te renseigner sur les interleaved buffers pour avoir un seul buffer contenant toutes les informations de tes vertex.
__________________
Si vous ne trouvez plus rien, cherchez autre chose...

Chef de projet (et unique exécutant pour l'instant) pour Castor 3D
dragonjoker59 est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 27/12/2012, 21h21   #10
FoX_*D i E*
Membre du Club
 
Inscription : septembre 2007
Messages : 160
Détails du profil
Informations personnelles :
Âge : 26

Informations forums :
Inscription : septembre 2007
Messages : 160
Points : 54
Points : 54
j'vais travailler tout ca, j'te remercie pour ton aide
FoX_*D i E* est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/01/2013, 00h01   #11
LittleWhite
Responsable 2D/3D/Jeux


 
Avatar de LittleWhite
 
Homme Alexandre Laurent
Ingénieur développement logiciels
Inscription : mai 2008
Messages : 10 764
Détails du profil
Informations personnelles :
Nom : Homme Alexandre Laurent
Localisation : France

Informations professionnelles :
Activité : Ingénieur développement logiciels

Informations forums :
Inscription : mai 2008
Messages : 10 764
Points : 43 027
Points : 43 027
Bonjour,

C'est à ce moment lent que je conseille de la lecture, lecture proposée par Developpez.com ->
http://jeux.developpez.com/tutoriels/?page=gl
et plus précisément :
http://raptor.developpez.com/tutorial/opengl/vbo/
__________________
Vous souhaitez participer à la rubrique 2D / 3D / Jeux ? Contactez-moi
La rubrique a aussi un blog !

Ma page sur DVP
Mon Portfolio

Qui connaît l'erreur, connaît la solution.
LittleWhite est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 10h19.


 
 
 
 
Partenaires

Hébergement Web