
Differences between ES20.GL and OpenGL.GL
Posted Monday, 19 October, 2009 - 00:37 by krisnye inI am using the same source code file to handle my OpenGL rendering and my ES 2.0 rendering.
I just use some conditional compilation at the top, and the rest of the code in the page just refers to GL.SomeMethod.
#if ES20
using OpenTK.Graphics.ES20
#else
using OpenTK.Graphics.OpenGL
#endif
GL.VertexAttribArray(...) etc.
This works very well since I am basically sticking to the ES20 subset of functionality which is also supported by standard OpenGL.
The only pain is the instances of the ES20 API that are unnecessarily different from the OpenGL api's . These are often minor things like using REF for a parameter instead of OUT, or using the ALL enumeration instead of a more specific enumeration such as ProgramParameters.
Is there a plan to try to keep the methods as consistent as possible, and to provide the more specific OpenGL enumerations in the ES20 namespace?
I wouldn't mind helping with this effort, since I'm basically merging the differences anyways on my side.
For the lack of enumerations in ES20, I have to use using statements that alias OpenTK.Graphics.ES20.All enumeration. This is all very manageable for me, but it might be nice to merge the two more in order to simplify allowing others to use the same code with a small conditional at the top to compile against both OpenGL and ES20.
Here are some of the differences between the classes that don't seem necessary:
ES20 is missing all of the following Enumerations, so I have to alias them to the ALL enumeration:
using TextureTarget = OpenTK.Graphics.ES20.All;
using TextureParameterName = OpenTK.Graphics.ES20.All;
using EnableCap = OpenTK.Graphics.ES20.All;
using BlendingFactorSrc = OpenTK.Graphics.ES20.All;
using BlendingFactorDest = OpenTK.Graphics.ES20.All;
using PixelStoreParameter = OpenTK.Graphics.ES20.All;
using VertexPointerType = OpenTK.Graphics.ES20.All;
using ColorPointerType = OpenTK.Graphics.ES20.All;
using TexCoordPointerType = OpenTK.Graphics.ES20.All;
using BeginMode = OpenTK.Graphics.ES20.All;
using MatrixMode = OpenTK.Graphics.ES20.All;
using PixelInternalFormat = OpenTK.Graphics.ES20.All;
using PixelFormat = OpenTK.Graphics.ES20.All;
using PixelType = OpenTK.Graphics.ES20.All;
using ShaderType = OpenTK.Graphics.ES20.All;
using VertexAttribPointerType = OpenTK.Graphics.ES20.All;
using ProgramParameter = OpenTK.Graphics.ES20.All;
using ShaderParameter = OpenTK.Graphics.ES20.All;
ES20 GetProgramInfoLog is broken because it uses a string as it's last parameter.
ES20 GetShaderInfoLog is broken because it uses a string as it's last parameter.
Es20 GetProgram method uses a 'ref', opengl uses 'out'.
Es20 GetShader method uses a 'ref', opengl uses 'out'.
Es20 ShaderSource uses different parameters from OpenGL
ES20 GenTextures uses a 'ref', opengl uses 'out'.
ES20 UniformMatrix4 uses different parameters from OpenGL.


Comments
Re: Differences between ES20.GL and OpenGL.GL
Yes, the plan is to make the APIs as consistent as possible.
Please post all other differences you come across. With the 1.0 quickly approaching, the sooner we can fix those the better!
Re: Differences between ES20.GL and OpenGL.GL
Additional Methods that have the 'ref'/'out' difference:
GenBuffers => 'out' in opengl, 'ref' in es20
GenFrameBuffers => 'out' in opengl, 'ref' in es20
GenRenderBuffers => 'out' in opengl, 'ref' in es20
Thanks for the good news. This is the class I use right now to abstract the differences. I listed all of the ones I'm currently aware of in my previous post though, I will add any more that I come across. It is very cool using the same source code for Windows and for iPhone rendering... and I did get the AMD ES2.0 emulator running on windows, which really helps.
Btw- how long does it take for changes you make to get propagated to Monotouch builds?
Re: Differences between ES20.GL and OpenGL.GL
Starting with rev. 2382, ES 2.0 bindings should have the same API and helper methods as regular OpenGL. For the largest part, porting between ES and GL should be a matter of
#if ES20in the using directives.I would appreciate it if you could download the es20 branch and double-check that the API works as intended. You'll need TortoiseSVN, if you don't already have it, and then you can checkout the code from https://opentk.svn.sourceforge.net/svnroot/opentk/branches/es20. Simply run Build.exe and open OpenTK.sln to build.
Re: Differences between ES20.GL and OpenGL.GL
I will test that they work. I also build my classes for the iPhone Simulator using #ES20. How long will it be before these changes make it into the Monotouch project?
Re: Differences between ES20.GL and OpenGL.GL
Ok, here's what I've found:
Different Enum names:
(OpenGL Enum => ES20 Enum)
VertexAttribPointerType => VertexAttribType
BeginMode => PrimitiveMode
StencilOp => StencilOperation
BlendEquationMode => BlendMode
BlendingFactorSrc/BlendingFactorDst => BlendFactor
Also:
ES20.GL.GetAttribLocation is wrongly using a StringBuffer parameter instead of a String.
Re: Differences between ES20.GL and OpenGL.GL
Thanks, I will fix those issues.
I'm afraid I cannot answer your question, you will have to ask the MonoTouch developers about this. I have sent an email about the updated bindings, but there are some additional matters to be sorted before they can be brought to MonoTouch (ABI issues regarding
refvsoutparameters).Re: Differences between ES20.GL and OpenGL.GL
These issues are fixed now. Please post if you encounter anything else!
Re: Differences between ES20.GL and OpenGL.GL
2 Remaining Issues I have found:
BlendingFactorDest used in OpenGL, BlendingFactorDst used in ES20. (ES20 contains a BlendingFactorDst enum AND a BlendingFactorDest enum, but uses the former.)
Als0 Since BlendingFactorSrc and BlendingFactorDst are identical enumerations, why aren't they merged? or is that planned for later?
ES20 GetUniformLocation incorrectly uses a StringBuilder where it should use a String.
Re: Differences between ES20.GL and OpenGL.GL
Actually it should be
void BlendFunc( BlendFactor sfactor, BlendFactor dfactor )it appears the changes did not make it in time.I've renamed enums quite a lot in the cleanup, e.g. GL's BeginMode should be PrimitiveMode in ES. This was mostly done so the enums read more intuitive and less technical. (PrimitiveMode.TriangleStrip sure beats BeginMode.TriangleStrip, especially because ES 2.0 does not support Begin/End-block drawing)
BlendingFactorDst enum AND a BlendingFactorDest enum
This is by design, the generator does not remove unused enums.
Re: Differences between ES20.GL and OpenGL.GL
Let me know when complete and I'll test again.