c++ - GLSL - When and where is the vertex and fragment called? -


i want know when vertex , fragment shader called in opengl loop. @ end of glutdisplayfunc() or glutmainloop(), or @ every vertex draw call? , vertex , fragment consecutively called 1 after other(ie: vertex fragment), or different times?

say have following snippet of code:

glpushmatrix();     glrotatef(rot,0.0f,1.0f,0.0);     gltranslatef(0.0f,0.0f,25);     glcolor3f(0.0,0.0,1.0);     drawsphere(4,20,20); // draw triangles      glcolor3f(1.0,0.0,0.0);     gltranslatef(0.0f,0.0f,5);     drawsphere(4,20,20); // draw triangles glpopmatrix(); 

does vertex shader called after each vertex call, reads current matrix on top of stack, send pre-defined modelview matrix uniform vertex shader? when fragment shader run?

is @ end of glutdisplayfunc() or glutmainloop(),

neither, because glut is not part of opengl. it's library (for creating simple opengl applications).

or @ every vertex draw call?

from programmers point of view it's not specified when happens exactly. opengl has command queue , things asserted processed between them entering command queue , reaching called "synchronization point". synchronization point command makes use or transfers data outside of opengl context (like image read glreadpixels) produced former opengl commands.

for practical means can assume vertices , fragments processed, whole primitive has been specified. if draw triangles, every 3 vertices got need draw triangle , processing commences.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -