How to use nvparse for ps.1.1 pixel shader parsing for OpenGL. Introduction. ------------ nvparse allows you to set OpenGL state corresponding to DX8.1 pixel shaders. Typically you want to save this state in an OpenGL display list and then invoke the display list as required. In order to do this correctly, you need to (a) specify the texture targets for the texture units used in your pixel shader (b) read back from nvparse the mapping it used to set the per-stage constants, i.e., which per-stage constant registers were used by nvparse to map the ps.1.1 constants c0, c1, etc. Steps ----- 1. Write the pixel shader code. 2. Invoke nvparse with the pixel shader string and the texture target mapping. At present ps.1.1 is the only version supported. The syntax for invoking nvparse with the texture target mapping is: nvparse(pixel_shader_string,count,texunit1,textarget1,...) where count is the number of arguments following the 'count' argument. For example: const char* ps_string = "ps.1.1 tex t0 mov r0, t0"; GLuint dlist = glGenLists(1); glNewList(dlist,GL_COMPILE); nvparse(ps_string,2,0,GL_TEXTURE_2D); glEndList(); char * const * errors = nvparse_get_errors(); // Now check for errors etc. 3. If your shader uses the ps.1.1 constants c0, c1, etc. you need to determine which registers this constants were mapped to so you can set the appropriate values in your OpenGL code. You can do this with the function: const int* nvparse_get_info(const char*, int*); This returns an array of size 3*n (n = number of constants) of the form {constNum,stage,constRegister,constNum,stage,constRegister,...} where constNum is the constant number (0 for c0, 1 for c1, etc.), stage is the combiner stage the constant was mapped to, and constRegister is either 0 or 1 depending on which constant of the stage it was mapped to. For example: int mapSize; const int* constMapping = nvparse_get_info(ps_string,&mapSize); int numConstants = mapSize/3; for (int i=0;i