Bonjour a tous,
j'ai eu le livre OpenGL 2.0 guide officiel pour noel !
Je suis donc au chapitre de GLSL (opengl shading language).
Le probleme c'est que j'arrive meme pas a compilé l'exemple de base :
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
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
 
#include <SDL/SDL.h>
#include <GL/glew.h>
 
 
int tempsActuel,tempsPrecedent,nbImg;
char infoFPS[100];
 
void Draw(),Quit();
 
GLuint shader,program;
GLint compiled, linked;
const GLchar* shaderSrc[] = {
	"void main()"
	"{"
	"	gl_position = glModelViewProjectionMatrix * gl_vertex;"
	"}"
};
 
int main ( int argc, char** argv )
{
	//SDL
    putenv("SDL_VIDEO_WINDOW_POS=center");
 
    SDL_Init(SDL_INIT_VIDEO);
 
    atexit(SDL_Quit);
 
    SDL_WM_SetCaption("OGL Test", NULL);
    SDL_SetVideoMode(800, 600, 32, SDL_GL_DOUBLEBUFFER
										|SDL_GL_ACCELERATED_VISUAL);
	SDL_Event event;
 
    /* OpenGL */
 
    glMatrixMode( GL_PROJECTION );
 
    glLoadIdentity();
 
    gluPerspective(70,(double)800/600,1,1000000);                         
 
    glEnable(GL_DEPTH_TEST);
 
    glEnable(GL_TEXTURE_2D);
 
    glShadeModel(GL_SMOOTH);
 
    glEnable(GL_POLYGON_SMOOTH);
 
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
 
    glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
 
 
    /* GLEW */
    glewInit();
 
	//Shader
	shader = glCreateShaderObject(GL_VERTEX_SHADER);
 
 
	//Boucle principal
	while(1)
 
	{
 
        SDL_PollEvent(&event);
 
        switch(event.type)
 
        {
 
            case SDL_QUIT:
 
            Quit();
 
            break;
 
            case SDL_KEYDOWN:
 
            switch (event.key.keysym.sym)
 
            {
 
                case SDLK_ESCAPE:
 
                    Quit();
                    break;
 
            }
 
            break;
 
        }
 
 
 
        /*TEMPS*/
 
        tempsActuel = SDL_GetTicks();
 
        nbImg++;
 
        if (tempsActuel - tempsPrecedent > 1000)
 
        {
 
           sprintf(infoFPS,"FPS : %ld",nbImg);
		   SDL_WM_SetCaption(infoFPS, NULL);
 
           nbImg=0;
 
           tempsPrecedent = tempsActuel;
 
        }
 
 
 
 
 
        //DRAW
 
        Draw();
 
        glFlush();
 
        SDL_GL_SwapBuffers();
 
    }
 
 
 
    return 0;
 
}
 
 
 
void Draw()
 
{
 
     glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
 
     glMatrixMode( GL_MODELVIEW );
 
     glLoadIdentity( );
 
 
 
 
}
 
 
 
void Quit()
 
{
 
	SDL_Quit();
	exit(0);
 
}
La compilation :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 
[XT95@localhost tmp]$ make
g++ -o main.o -c main.cpp
main.cpp: In function ‘int main(int, char**)’:
main.cpp:46: erreur: ‘glCreateShaderObject’ was not declared in this scope
main.cpp:51: erreur: ‘glAttach’ was not declared in this scope
make: *** [main.o] Erreur 1
Voila. Il y a un truc spécial a inclure pour les shaders ?
Merci d'avance !