Advertisement Jump to content
Sign in to follow this  

glProgramStringARB causing GL_INVALID_OPERATION...or Help with Fragment Programs

This topic is 3702 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 = 
   "TEMP R0;\n"+
   "MOV R0.x, fragment.texcoord[1];\n"+
   "ADD R0.w, fragment.texcoord[2].x, -R0.x;\n"+
   "TEX, fragment.texcoord[0], texture[0], 2D;\n"+
   "RCP R0.w, R0.w;\n"+
   "ADD, R0, -fragment.texcoord[1].x;\n"+
   "MUL_SAT, R0, R0.w;\n"+

int count = str.Length;

Gl.glGenProgramsARB(1, out mFragProg);            
Gl.glBindProgramARB(Gl.GL_FRAGMENT_PROGRAM_ARB, mFragProg);
Then to use it I do the following:
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


Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!