J'ai essayé de reproduire l'exemple du tutoriel, mais j'ai un problème de traduction au niveau de l'appel à glVertexPointer.
Voici mon code :
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
 
 CubeArray: Array[0..47] of GLfloat;
 IndiceArray: Array[0..35] of GLuint;
 CubeBuffers: Array[0..1] of GLuint;
 
...
 
   glVertexPointer: procedure(size: GLint; _type: GLenum; stride: GLsizei; const _pointer: GLvoid);   stdcall;
   glColorPointer: 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;
 
...
 
   glGenBuffers(2, @CubeBuffers);
 
   glBindBuffer(GL_ARRAY_BUFFER, CubeBuffers[0]);
   glBufferData(GL_ARRAY_BUFFER, SizeOf(CubeArray), @CubeArray, GL_STATIC_DRAW);
 
   glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, CubeBuffers[1]);
   glBufferData(GL_ELEMENT_ARRAY_BUFFER, SizeOf(IndiceArray), @IndiceArray, GL_STATIC_DRAW);
end;
 
procedure TFormGL.AffVBO;
const
   GL_COLOR_ARRAY = $8076;
   GL_VERTEX_ARRAY = $8074;
begin
   // Utilisation des données des buffers
   glBindBuffer(GL_ARRAY_BUFFER, CubeBuffers[0]);
   // glVertexPointer(3, GL_FLOAT, 6 * sizeof(float), ((float*)NULL + (3)));
   glVertexPointer(3, GL_FLOAT, 6 * SizeOf(Double), nil);      // <--- ERREUR :  violation d'accès ici !
   // glColorPointer(3, GL_FLOAT, 6 * sizeof(float), 0);
   glColorPointer(3, GL_FLOAT, 6 * SizeOf(Double), nil);
 
   glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, CubeBuffers[1]);
 
   // Activation d'utilisation des tableaux
   glEnableClientState(GL_VERTEX_ARRAY);
   glEnableClientState(GL_COLOR_ARRAY);
 
   // Rendu de notre géométrie
   glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_INT, nil);
 
   glDisableClientState(GL_COLOR_ARRAY);
   glDisableClientState(GL_VERTEX_ARRAY);
end;
J'obtiens une violation d'accès à l'appel de glVertexPointer, parce que je ne sais pas ce qu'il faut mettre en dernier paramètre.
Comment traduire ((float*)NULL + (3)) ?