Zer's picture

Overloads with differing meanings

GL.Color4(byte, byte, byte, byte) and (float, ...) really ought to have separate method names.
GL.Color4(1, 1, 1, 1) and GL.Color4(1, 1, 1, 1.0) have completely different behavior, and it's a non-obvious source of bugs...


Comment viewing options

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

This only happens if you don't use Vector structs or System.Drawing.Color.

Zer's picture

...and? Not using those is the best way to use one's own structures, and the most similar to normal OpenGL programming.

As for System.Drawing.Color, I intend to have no System.Drawing dependency. Not to mention System.Drawing.Color is a terrible piece of code.

the Fiddler's picture

You should always use the floating-point version of immediate-mode functions, such as GL.Color4. Everything else involves a transformation on the CPU (4 multiplications/casts) and is going to be slower. You can use OpenTK.Graphics.Color4 instead of System.Drawing.Color.

Note that immediate-mode has been removed from the latest OpenGL versions. The issue you mention is specific to GL.Color[34] and doesn't affect modern functionality such as vertex buffer objects. Even if this were possible to fix now, there would be little point.

(Note that OpenTK cannot work without System.Drawing.Color right now - this is definitely going to be fixed in a future version.)

jdomnitz's picture

I have a branched version of OpenTK for my project....and removed all references to System.Windows.Forms and System.Drawing (implementing my own version of System.Drawing.Graphics using just OpenGL).

Our System.Drawing.Color implementation:

...In case that helps anyone

Zer's picture

Honestly, probably the best way to remove the System.Drawing dependency would be to move all methods that depend on its types to extension methods in another assembly.. That way someone trying to have a minimal download won't need to include things like cornflower blue. :)

Also, http://openmobile.sourceforge.net/main/ suggests all of your source is GPLv3. I can't speak for anyone else but in my case that definitely puts a damper on trying that in my project. Thanks though :)