gKit2 light
Loading...
Searching...
No Matches
intro1.glsl
Go to the documentation of this file.
1
3
4#version 330
5
6#ifdef VERTEX_SHADER
7
8const float dx= 0.0;
9const float dy= 0;
10const float dz= 0;
11
12/* vec3 et vec4 sont des types de base, ils sont equivalents a :
13
14 struct vec3 { float x, y, z; };
15 struct vec4 { float x, y, z, w; };
16 */
17
18void main( )
19{
20 // intialiser les coordonnees des 3 sommets
21 vec3 positions[3]= vec3[3]( vec3(-0.5, -0.5, 0), vec3(0.5, -0.5, 0), vec3(0, 0.5, 0) );
22
23 // recuperer le sommet a traiter
24 vec3 p= positions[gl_VertexID];
25
26 // calculer le resultat
27 vec4 r;
28 r.x= p.x + dx;
29 r.y= p.y + dy;
30 r.z= p.z + dz;
31 r.w= 1;
32
33 // renvoyer le sommet transforme
34 gl_Position= r;
35}
36#endif
37
38
39#ifdef FRAGMENT_SHADER
40
41out vec4 fragment_color;
42
43void main( )
44{
45 // remplir le triangle avec une couleur uniforme
46 fragment_color= vec4(0.8, 0.4, 0, 1);
47}
48#endif
vecteur generique, utilitaire.
Definition vec.h:169
vecteur generique 4d, ou 3d homogene, utilitaire.
Definition vec.h:192