
ARB shaders
Posted Wednesday, 3 December, 2008 - 23:53 by himek inHave 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
Re: ARB shaders
Missing tokens can generally be located in the "All" enum. For instance,
GL_VERTEX_PROGRAM_ARBisAll.VertexProgram, whileGL_PROGRAM_ERROR_POSITION_ARBisAll.ProgramErrorPositionArb.Which methods are these used in? We have generally focused on cleaning up the GL core, instead of the extension functions.
Re: ARB shaders
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);
Re: ARB shaders
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:
Re: ARB shaders
OK, thanks.
Re: ARB shaders
Sorry if this is going off-topic, but do you have any tutorial/bookmarks you can recommend for learning about ARB assembly?