kanato's picture

New OpenTK version

I was just doing some work porting AgateLib to the new version of OpenTK, and there was a couple of things I noticed and I thought I would ask about.

Call to GL.ShadeModel gives a null reference exception before a context is created. I'm guessing this is correct behavior, but it didn't happen in the older version I was using, so I just thought I'd check to see if this change is intended or not.

I noticed some discussion in another topic about casing on names which contain 1D, 2D, etc. There seems to be some inconsistency in the way some things are named:
Enums.EnableCap.Texture2d
Enums.TextureTarget.Texture2d
Glu.Ortho2D
GL.TexImage2D
I guess it's maybe just the Enum values?

The override to GL.TexImage2D which takes a byte[] is missing, which means I have to manually marshal memory to an unmanaged buffer to call the function. It's no problem if this is the intended interface.

Also, I haven't tried it playing with it yet, but what's the status of framebuffer objects in 0.9? Are the supported?


Comments

Comment viewing options

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

Call to GL.ShadeModel gives a null reference exception before a context is created. I'm guessing this is correct behavior, but it didn't happen in the older version I was using, so I just thought I'd check to see if this change is intended or not.
Intended no; expected yes. Functions exported from opengl32.dll statically will silently fail, while ones that are exported dynamically will cause an NRE. Expect an update in the near future to make this behaviour more consistent (an InvalidOperationException will be thrown)

I noticed some discussion in another topic about casing on names which contain 1D, 2D, etc. There seems to be some inconsistency in the way some things are named:
[...]

Acknowledged, will fix in 0.9.1.

The override to GL.TexImage2D which takes a byte[] is missing, which means I have to manually marshal memory to an unmanaged buffer to call the function. It's no problem if this is the intended interface.
It's the intended interface, but there's no need to manually marshal memory. The 'object' overload will do that for you, albeit at a small performance penalty (up to ~300ns).

You can also use the following code:

unsafe
{
    fixed (byte* data_ptr = data)
    {
        GL.TexImage2D([...], (IntPtr)data_ptr);
    }
}

This also avoids the cost of copying to unmanaged memory.

Also, I haven't tried it playing with it yet, but what's the status of framebuffer objects in 0.9? Are the supported?
Supported, but the interface will be improved in the future (more type-safety).

Inertia's picture

[Shademodel]
An OpenGL/OpenAL Context can be understood as an instance of the state machine. Without a context there is no instance of state to apply the statechange to, so - like you said - this is the correct behaviour of the command.

[FBO]
They are currently available as GL.Ext.GenFramebuffer & Co. This Extension is on my todo list for 0.9.1, cleaning up the enums like I did for some other Extensions. (it isn't improved in 0.9.0 because it got overlooked, it works fine the way it is. I've mailed Fiddler an sample for the tutorial launcher using it's Render-To-Texture capabilities, expect to see it in 0.9.1 too)

Edit: Fiddler beat me to it ;)