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);
bindfrgprog(frgid);

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

!!ARBvp1.0\n
OPTION ARB_position_invariant;
MOV result.color,vertex.color;
END

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

!!ARBfp1.0
MOV result.color,fragment.color;
END

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:

glProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB,n,x,y,z,w);

Using the Qt framework we write:

setfrgprogpar(n,x,y,z);

Retrieved from http://schorsch.efi.fh-nuernberg.de/roettger/index.php/MedicalVisualization/OpenGLShaderPrograms

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