Salut j'ai deja fait quelques programmes en opengl avec glut, mais la j'essaie avec sdl.
J'ai donc telechargé les .lib .dll et .h, recopié un corps minimal de programme que voici :
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
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
 
#include <SDL.h>
#include <GL/gl.h>
#include <GL/glu.h>
 
 
void quit(int code)
{
   SDL_Quit();
   exit(code);
}
 
void handle_key_down(SDL_keysym* keysym)        // une touche a été pressée
{
   switch(keysym->sym)
   {
       case SDLK_ESCAPE:   quit(0); break;        // touche échap
   }
}
 
void process_events(void)
{
   SDL_Event event;
 
   while(SDL_PollEvent(&event))
   {
       switch(event.type) 
       {
           case SDL_KEYDOWN:
               handle_key_down(&event.key.keysym); break;
           case SDL_QUIT:
               quit(0); break;
       }
   }
}
 
void draw_screen(void)
{
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
 
   //scene(); // code d'affichage de la scene
 
   SDL_GL_SwapBuffers();
}
 
void setup_opengl( int width, int height )
{
   float ratio = (float) width / (float) height;
   glClearColor(0, 0, 0, 0);
   glViewport(0, 0, width, height);
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   gluPerspective(45, ratio, 0.5, 50);
   glMatrixMode(GL_MODELVIEW);
   glEnable(GL_DEPTH_TEST);
}
 
int main(int argc, char *argv[])
{
   const SDL_VideoInfo* info = NULL;
   int width = 400;
   int height = 400;
   int bpp = 0;
   int flags = 0;
 
   // initialisation de SDL
   if(SDL_Init(SDL_INIT_VIDEO) < 0)
   {
       printf("Video initialization failed: %s\n", SDL_GetError());
       quit(1);
   }
   info = SDL_GetVideoInfo();
   if(!info)
   {
       printf("Video query failed: %s\n", SDL_GetError());
       quit(1);
   }
 
   // propriétés de la fenêtre (RGB, profondeur et double buffer)
   bpp = info->vfmt->BitsPerPixel;
   SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
   SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
   SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
   SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
   SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
 
   flags = SDL_OPENGL;
   // éventuellement flags |= SDL_FULLSCREEN;
 
   if(SDL_SetVideoMode(width, height, bpp, flags) == 0 )
   {
       printf("Video mode set failed: %s\n", SDL_GetError());
       quit(1);
   }
   setup_opengl(width, height);
 
   while(1)        // boucle d'affichage
   {
       process_events();
       draw_screen();
   }
   return 0;
}
J'ai ajouté le chemin du contenu des .h de sdl à mon projet et à la compilation, j'ai 3 erreurs dans gl.h :
gl.h(1152) : error C2144: syntax error : missing ';' before type 'void'
gl.h(1152) : error C2501: 'WINGDIAPI' : missing storage-class or type specifiers
gl.h(1152) : fatal error C1004: unexpected end of file found

Voila la ligne 1152 de gl.h :
WINGDIAPI void APIENTRY glAccum (GLenum op, GLfloat value);

Ensuite j'ai ajouté <windows.h> dans les include, ca passe a la compilation mais 8 erreurs au link de ce genre :
proj.obj : error LNK2001: unresolved external symbol __imp__glLoadIdentity@0

J'espere que quelqu'un saura ou est le probleme... Merci d'avance.