Je suis toujours en train d'essayer de faire fonctionner les VBO.

J'ai enfin trouvé ce qui me manquait pour utiliser les textures, mais j'obtiens un rendu bizarre :


Je ne vois que l'intérieur du cube (je ne sais pas si c'est visible sur l'image).
Quand je tourne autour du cube, je ne vois que les faces internes.



Voici le code concernant le cube :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
      _glVertexPointer: procedure(size: GLint; _type: GLenum; stride: GLsizei; const _pointer: GLvoid);   stdcall;
      _glColorPointer: procedure(size: GLint; _type: GLenum; stride: GLsizei; const _pointer: GLvoid);   stdcall;
      _glTexCoordPointer: procedure(size: GLint; _type: GLenum; stride: GLsizei; const _pointer: GLvoid);   stdcall;
      _glEnableClientState: procedure(_array: GLenum);   stdcall;
      _glDrawElements: procedure(mode: GLenum; count: GLsizei; _type: GLenum; const indices: GLvoid);   stdcall;
      _glDisableClientState: procedure(_array: GLenum);   stdcall;
 CubeArray: Array[0..47] of GLfloat;
 IndiceArray: Array[0..35] of GLuint;
 CubeBuffers: Array[0..1] of GLuint;
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
...
 
   _nHDLLGL := LoadLibrary(PChar('OpenGL32.dll'));
   if _nHInstDLL = 0 then
      MainForm.AddLog('[' + FormatDateTime('dd/mm/yyyy hh:nn:ss:zzz', Now) + ']  Erreur :  le chargement de la DLL (OpenGL32.dll) a échoué !' + #13#10 + SysErrorMessage(GetLastError))
   else
   begin
      //.Récupération des adresses des fonctions.
      _glVertexPointer := GetProcAddress(_nHDLLGL, 'glVertexPointer');
      _glColorPointer := GetProcAddress(_nHDLLGL, 'glColorPointer');
      _glTexCoordPointer := GetProcAddress(_nHDLLGL, 'glTexCoordPointer');
      _glEnableClientState := GetProcAddress(_nHDLLGL, 'glEnableClientState');
      _glDrawElements := GetProcAddress(_nHDLLGL, 'glDrawElements');
      _glDisableClientState := GetProcAddress(_nHDLLGL, 'glDisableClientState');
   end;
 
...
 
   glGenBuffers(2, @CubeBuffers);
 
   glBindBuffer(GL_ARRAY_BUFFER, CubeBuffers[0]);
   glBufferData(GL_ARRAY_BUFFER, SizeOf(CubeArray), @CubeArray, GL_STATIC_DRAW);
   glBindBuffer(GL_ARRAY_BUFFER, 0);
 
   glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, CubeBuffers[1]);
   glBufferData(GL_ELEMENT_ARRAY_BUFFER, SizeOf(IndiceArray), @IndiceArray, GL_STATIC_DRAW);
   glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
end;
 
procedure TFormGL.AffVBO;
const
   GL_VERTEX_ARRAY = $8074;
   GL_NORMAL_ARRAY = $8075;
   GL_COLOR_ARRAY = $8076;
   GL_TEXTURE_COORD_ARRAY = $8078;
begin
   glPushMatrix;
      glBindTexture(GL_TEXTURE_2D, TEXTURE_MUR_PIERRE_1);
 
      // Utilisation des données des buffers
      glBindBuffer(GL_ARRAY_BUFFER, CubeBuffers[0]);
      _glVertexPointer(3, GL_FLOAT, 6 * SizeOf(GLfloat), Pointer(3 * SizeOf(GLfloat)));
      _glColorPointer(3, GL_FLOAT, 6 * SizeOf(GLfloat), Pointer(0));
      _glTexCoordPointer(3, GL_FLOAT, 6 * SizeOf(GLfloat), Pointer(3 * SizeOf(GLfloat)));
 
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, CubeBuffers[1]);
 
      _glEnableClientState(GL_VERTEX_ARRAY);
      _glEnableClientState(GL_COLOR_ARRAY);
      _glEnableClientState(GL_TEXTURE_COORD_ARRAY);
 
      // Rendu de notre géométrie
      _glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_INT, nil);
 
      _glDisableClientState(GL_TEXTURE_COORD_ARRAY);
      _glDisableClientState(GL_COLOR_ARRAY);
      _glDisableClientState(GL_VERTEX_ARRAY);
   glPopMatrix;
end;
Une idée ?