himek's picture

ARB shaders

Have anyone ever used ARB shaders with OpenTK? There are some missing constant equivalents, unless I overlooked them somewhere. I'm filling the gap with Tao for now.

GL_VERTEX_PROGRAM_ARB,
GL_FRAGMENT_PROGRAM_ARB,
GL_PROGRAM_ERROR_POSITION_ARB,
GL_PROGRAM_ERROR_STRING_ARB

Oh, and could you make a string overload like the one GLSL has for this?

byte[] bytes = System.Text.Encoding.ASCII.GetBytes(vertShaderSrc);
IntPtr sourcePtr = Marshal.UnsafeAddrOfPinnedArrayElement(bytes, 0);
GL.Arb.ProgramString(AssemblyProgramTargetArb.VertexProgram, AssemblyProgramFormatArb.ProgramFormatAsciiArb, vertShaderSrc.Length, sourcePtr);

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

Missing tokens can generally be located in the "All" enum. For instance, GL_VERTEX_PROGRAM_ARB is All.VertexProgram, while GL_PROGRAM_ERROR_POSITION_ARB is All.ProgramErrorPositionArb.

Which methods are these used in? We have generally focused on cleaning up the GL core, instead of the extension functions.

himek's picture

Tao.OpenGl.Gl.glEnable(Tao.OpenGl.Gl.GL_VERTEX_PROGRAM_ARB);
Tao.OpenGl.Gl.glDisable(Tao.OpenGl.Gl.GL_VERTEX_PROGRAM_ARB);
Tao.OpenGl.Gl.glEnable(Tao.OpenGl.Gl.GL_FRAGMENT_PROGRAM_ARB);
Tao.OpenGl.Gl.glDisable(Tao.OpenGl.Gl.GL_FRAGMENT_PROGRAM_ARB);

Tao.OpenGl.Gl.glGetIntegerv(Tao.OpenGl.Gl.GL_PROGRAM_ERROR_POSITION_ARB, out err);

if (err >= 0)
MessageBox.Show(Tao.OpenGl.Gl.glGetString(Tao.OpenGl.Gl.GL_PROGRAM_ERROR_STRING_ARB)+" at line "+err+".", "Error in vertex shader", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

the Fiddler's picture

There was a decision made early on that we shouldn't modify core functions (like GL.Enable) to support extension tokens (like GL_VERTEX_PROGRAM_ARB). This would require rewriting a large part of the .spec files, which just isn't feasible right now.

In OpenTK, you can write these functions as follows:

GL.Enable((EnableCap)All.VertexProgram);
GL.Enable((EnableCap)All.FragmentProgram);
GL.GetInteger((GetPName)All.ProgramErrorPositionArb, out err);
GL.GetString((StringName)All.ProgamErrorStringArb);
himek's picture

OK, thanks.

Inertia's picture

Sorry if this is going off-topic, but do you have any tutorial/bookmarks you can recommend for learning about ARB assembly?