Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 86189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:12:26+00:00 2026-05-10T22:12:26+00:00

I am trying to write a fragment program that will take a texture and

  • 0

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 why this is happening. 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); 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T22:12:26+00:00Added an answer on May 10, 2026 at 10:12 pm

    I haven’t really programed any shaders, but maybe the shader compiler doesn’t recognize the new line? have you tried putting ‘\n\r’?

    EDIT:

    Another question that you may ask yourself is what language are you using? Are strings in UNICODE, ie 16-bits/char? I just noticed that the format you are passing into the glProgramStringARB() is set to ASCII. If the string is really UNICODE, then it will cause problems.

    For example, JAVA and C# Strings are in UNICODE. not ASCII.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 380k
  • Answers 380k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try something like this: $output = array(); $result = -1;… May 14, 2026 at 9:49 pm
  • Editorial Team
    Editorial Team added an answer Try going to "Tools -> Options -> Environment -> Fonts… May 14, 2026 at 9:49 pm
  • Editorial Team
    Editorial Team added an answer I'm not sure why you would want to disable virtual… May 14, 2026 at 9:49 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.