call glDrawArrays() without a bound array
buffer.
A vertex shader with no explicit inputs has
implicit inputs from the GL:
gl_VertexID and
gl_InstanceID.
If you now test this and it works even in
compatibility profile, you’re most likely to
have a NVidia GPU, as NVidias drivers will
accept this. They are wrong here and the ATI
drivers are correct in not allowing attribute-
less rendering in compatibility. Sadly, NVidia
is more error tolerant than the spec –
sounds great at first, but can be problematic
when testing wrong code on other graphics
cards (‘it worked before, that’s not my
fault…’).
After some problems with this, in core
attribute-less rendering works for both, ATI
and NVidia cards. You can download the
OpenGL sample pack from g-truc creation to
test this on your card.
29
Introduction à OpenGL et WebGL
Programme Source des Vertex Shaders
Le Pipeline Graphique
Plan de Travail du Modèle de
la Camera Synthétique
Le Pipeline Graphique make_resources ( ) , render( )
The vertex shader file: vsSource.glsl
vsSource =`#version 300 es
const vec2 data[4] = vec2[ ] (
vec2(-0.5, 0.5) , vec2(-0.5, -0.5),
vec2( 0.5, 0.5) , vec2( 0.5, -0.5) ) ;
//varying
Out vec4 v_color ;
void main( ){
gl_Position = vec4( data[ gl_VertexID ] ,
0.0, 1.0);
v_color = vec4(1.0 , 0.0 , 1.0 , 1.0 ) ;
// gl_PointSize = 10.0;
}`;
Le fragment shader file: fsSource.glsl
fsSource = `#version 300 es
precision highp float;
//precision mediump float;
//varying vec4 v_color ;
// we need to declare an output for the
//fragment shader
out vec4 outColor;
void main() {
// gl_FragColor = vec4(1, 0, 0.5, 1); //
outColor = vec4(0.5, 0.5, 0.5, 1) ; v_color ;
}`;
1. des données dites vertex sont:
1. projetés dans plan de
projection, par les vertex
shaders,
2. assemblé en triangle et enfin
3. "rastérisé" (pixelisé) en
fragments de la taille d'un
pixel (en gros, fragment =
pixel).
2. Les fragments dans le
framebuffer assignés des
couleurs par des fragments
shaders.
3. Finalement, le framebuffer
est dessiné sur l'espace écran
("screen space").
make_ressources( ) doit être
implémentée on fait appel à:
make_shader( ).
Avec la satisfaction d'avoir le
plan de projection, on va ré-
utiliser le même
programme. On est prêt:
1. à remplir la fonction
make_resources( ) avec:
des vertex objects,
2. des shader objects et
3. des texture objects
2. à projeter (dessiner) la
scène avec la fonction
render( ).
au fur et à mesure qu’on
avance dans le cours.
Les prochains chapitres, on
introduit les textures
OpenGL.
Les spécifications des objets
de la scène sont
indépendants des
spécifications de la camera.
Implémenter les objets dans
la scène.
Définir le frustum.
Définir la camera synthétique
Dessiner l’image sur le plan
de projection.