From Ohm

Open GL Shader Programs

We may use the Qt framework as a wrapper for using OpenGL shader programs.

int buildfrgprog(const char *prog);
void bindfrgprog(int progid);
void setfrgprogpar(int n,float p1,float p2,float p3,float p4);
void deletefrgprog(int progid);

To use the default shader (which just mimics the default behavior of the fixed function pipeline) we need the following setup:

int frgid = buildfrgprog(default_frgprg);

The default vertex shader program in OpenGL shader assembly language is:

OPTION ARB_position_invariant;
MOV result.color,vertex.color;

The default fragment shader program in OpenGL shader assembly language is:

MOV result.color,fragment.color;

Both the vertex and the fragment shader have a so called shader environment, which contains a set of at least 64 registers, which may contain constant 4-component vectors. To access register number n in the shader we write:

PARAM p=program.env[n];

To set register number n of a fragment shader from the C side, we write:


Using the Qt framework we write:


Retrieved from

Page last modified on November 18, 2020, at 08:03 PM