Bonjour,
Je viens de débuter sous Delphi, et pour un projet, je dois coder un jeu (moteur graphique disons) en OpenGL.
Pour la librairie, nous avons choisi glfw (pas de GLScene :/).
J'ai pas mal googlé, mais je trouve principalement du code C/C++ ou alors, c'est en rapport avec des classes, des gros trucs de bourrin...
Sauf que je ne sais pas comment indiquer à Delphi le GLFWCALL :
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 void GLFWCALL OnResize(int w, int h) // C'est ceci qui me bloque { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0, w, 0, h); } void Display() { glClear(GL_COLOR_BUFFER_BIT); } int main() { int running = GL_TRUE; glfwInit(); if(!glfwOpenWindow(640, 480, 0, 0, 0, 0, 0, 0, GLFW_WINDOW)) { glfwTerminate(); return -1; } glfwSetWindowPos(192, 144); glfwSetWindowTitle("Fenêtre GLFW"); glfwSetWindowSizeCallback(OnResize); // et là son appel glClearColor(0.0f, 0.0f, 0.0f, 0.0f); while(running) { Display(); glfwSwapBuffers(); running = !glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam(GLFW_OPENED); } glfwTerminate(); return 0; }
Je l'ai transposé en Delphi comme tel :
et l'appel :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 procedure {GLFWCALL} OnResize(w, h : integer); begin glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0, w, 0, h); end;
Je sais que c'est pas beau, dans le glfw.pas, il y a :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 glfwSetWindowSizeCallback(OnResize);
qui est inclu au projet. OnResize a besoin de deux parametres : w et h, mais je ne voies pas ou ils sont appelés dans la source en C.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 procedure glfwSetWindowRefreshCallback(cbfun: GLFWwindowrefreshfun); stdcall;
J'espère que quelqu'un pourra m'aider, ca m'embête déjà d'être bloqué à ce niveau... J'ai certainement du louper quelque chose, donc si vous avez des conseils, adresses, codes sources pour apprendre, j'en serai ravi
Merci ^^
Partager