• Advertisement
Sign in to follow this  

glProgramStringARB causing GL_INVALID_OPERATION...or Help with Fragment Programs

This topic is 3370 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to write a fragment program that will take a texture and clamp the texels between two values. That is, if the min value is say 0.2 and the max value is 0.6, any texel less than 0.2 will become 0, any texel greater than 0.6 will become 1.0, and all values in between will be mapped from 0 to 1.0. My call to glProgramStringARB is cause a GL_INVALID_OPERATION. I can't seem to figure out my problem. Please help. This is my first attempt at writing a shader so I'm not entirely sure what I'm doing. Here's my code:
String str = 
   "!!ARBfp1.0\n"+            
   "TEMP R0;\n"+
   "MOV R0.x, fragment.texcoord[1];\n"+
   "ADD R0.w, fragment.texcoord[2].x, -R0.x;\n"+
   "TEX R0.xyz, fragment.texcoord[0], texture[0], 2D;\n"+
   "RCP R0.w, R0.w;\n"+
   "ADD R0.xyz, R0, -fragment.texcoord[1].x;\n"+
   "MUL_SAT result.color.xyz, R0, R0.w;\n"+
   "END\n";

int count = str.Length;

Gl.glEnable(Gl.GL_FRAGMENT_PROGRAM_ARB);
Gl.glGenProgramsARB(1, out mFragProg);            
Gl.glBindProgramARB(Gl.GL_FRAGMENT_PROGRAM_ARB, mFragProg);
Gl.glProgramStringARB(Gl.GL_FRAGMENT_PROGRAM_ARB,  Gl.GL_PROGRAM_FORMAT_ASCII_ARB, count, str);
GetGLError("glProgramStringARB");
Gl.glDisable(Gl.GL_FRAGMENT_PROGRAM_ARB);
Then to use it I do the following:
Gl.glEnable(Gl.GL_FRAGMENT_PROGRAM_ARB);
Gl.glBindProgramARB(Gl.GL_FRAGMENT_PROGRAM_ARB, mFragProg);
float max = (mMiddle + (mRange / 2.0f))/65535.0f;
float min = (mMiddle - (mRange / 2.0f))/65535.0f;
Gl.glMultiTexCoord1f(Gl.GL_TEXTURE1_ARB, min);
Gl.glMultiTexCoord1f(Gl.GL_TEXTURE2_ARB, max);
GetGLError("Enable Program for Drawing");

/* 
 * Drawing Code
 */

Gl.glDisable(Gl.GL_FRAGMENT_PROGRAM_ARB);

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement