MedicalVisualization

Open GL Shader Programs

OpenGL Shader Documentation | | Iso-Contouring With Graphics Hardware

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

  • The shader program API supplies the following methods:
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);


OpenGL Shader Documentation | | Iso-Contouring With Graphics Hardware

Options: