Inertia's picture

OpenGL 3.0 bindings

Project:The Open Toolkit library
Category:feature request
Assigned:the Fiddler

Ati has done its homework and over half of the GL 3.0 extensions are supported.

This feature request does not cover forward compatible contexts. No remarks about deprecation either.

I'd really like to see this going in 0.9.2, so we have all gremlins hunted down by the time 0.9.3 is due.


Comment viewing options

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


Using new drivers, all works as expected.

GLX_EXT_visual_info GLX_EXT_visual_rating GLX_SGIX_fbconfig GLX_SGIX_pbuffer GLX_SGI_video_sync GLX_SGI_swap_control GLX_EXT_texture_from_pixmap GLX_ARB_create_context GLX_ARB_multisample GLX_NV_float_buffer GLX_ARB_fbconfig_float GLX_EXT_framebuffer_sRGB GLX_ARB_get_proc_address
Getting framebuffer config
Getting XVisualInfo
Creating colormap
Creating window
Mapping window
Creating context
Making context current

Small window flashing from blue to orange then closing.

the Fiddler's picture


Ah great, thanks! The code seems correct, then, which points to bug in the ati drivers.

Anyone else with new-ish graphics cards, please test - if the results are consistent, I'll commit the code to SVN.

JTalton's picture


I started going down the route of testing this with Ubuntu and a NVidia 8800GT, but was interrupted and never got back to it. Let me know if you still want it tested and I'll get to it.

the Fiddler's picture


Thanks. The issue and the test program has been forwarded to Ati, so it's a matter of time before it's solved.

The code seems to work fine on Nvidia cards, so I'll add it to SVN for testing when I get the chance.

the Fiddler's picture


I have committed initial GL3 support to trunk and will make a new release shortly. GL3 is far for complete, but it will be nice to get some testing, to fix bugs, oversights etc.


  1. GL3 contexts on Windows, if supported.
  2. Cleaned-up, typesafe specs for the following extensions:
    • ARB_framebuffer_object (this was huge!)
    • ARB_color_buffer_float
    • ARB_texture_rg
    • ARB_texture_ compression_rgtc
    • ARB_texture_float
    • EXT_texture_integer
    • EXT_texture_array
  3. Spiced up metadata in the GL class (entry points, extension categories, version numbers).
  4. New, sexy extension viewer that displays the above metadata (Tests/Extensions).

Missing stuff:

  1. No GL3 support on Linux.
  2. No support for forward compatible contexts.
  3. No support for selecting context version (3.0 is always used, if supported).

These will be addressed over the following weeks.

pokemoen's picture


I noticed something which I first thought might be a bug in the ATI driver, but then the same problem arose when I let someone with a nvidia test it.

The situation is this:
I have a fragment shader

uniform sampler2D baseMap;
uniform sampler2D lightMap;
void main( void )
    vec4 light = texture2D( lightMap, gl_TexCoord[1].xy);
    vec4 base = texture2D( baseMap, gl_TexCoord[0].xy);
    gl_FragColor = base * light;

and a vertex one:

void main( void )
	gl_Position = ftransform();
	gl_TexCoord[0] = gl_MultiTexCoord0;
	gl_TexCoord[1] = gl_MultiTexCoord1;

The uniforms are set like so:

shader.SetUniform("baseMap", 0);
shader.SetUniform("lightMap", 1);
// with SetUniform as
public void SetUniform(string name, int value) {
    int handle = GL.GetUniformLocation(currentTechnique.Program, name);
    GL.Uniform1(handle, value);

Now this worked perfectly with a GL2 context before gl3 branch was merged. But with a GL3 context (both trunk now and gl3 when that was first branched) the both sampler2Ds seem to have faulty value. In my application it looks both are 0.

Since this problem is reproducable on both ATI and NVidia cards, I am beginning to suspect that either my code is wrong or there is something else fishy going on.

(some time later... :)

Ok, I just made a minimal OpenTK example trying this out, and the fragments are rendered black. Both with trunk as is, and with the lines for the GL3 creating attempt commented out resulting in the creation of a GL2 context.

After copying OpenTK.*dll from an older build (r1488) and running Examples.exe again gives me the correct result.

I attached the failing code.

SamplerBug.cs6.09 KB
the Fiddler's picture


Thanks, I'll test it tomorrow on a GL3-capable machine. Btw, these shaders shaders don't seem valid GL3.0 (you are using builtin gl_* attributes), but I think they should still work. Will have to read the specs, though.

pokemoen's picture


If I parsed the specs correctly, this should work with the backward compatible contexts. But it fails, on my ati machine at least, when creating a gl2 context as well.

edit: Tried with varyings in stead of the gl_* built-ins, same result.

edit2: got it.

OpenGL spec page 101:
Sampler values need to be set by calling Uniform1i{v}.
Loading samplers with any of the other Uniform* entry points is not allowed and
will result in an INVALID OPERATION error.

Using your nice new extension viewer (with entrypoints added to table) showed me GL.Uniform1 is really glUniform1ui of version30. After changing my calls to GL.Arb.Uniform1 the sample works as expected.

This one and other unsigned versions are incorrectly generated: (param should be UInt32 v0)

        [AutoGenerated(Category = "Version30", Version = "3.0", EntryPoint = "glUniform1ui")]
        public static 
        void Uniform1(Int32 location, Int32 v0)
            Delegates.glUniform1ui((Int32)location, (UInt32)v0);

I searched the gl.spec file, but the Uniform1ui entry looks good and can not find why the Uniform1i(location, v0) of VERSION_2_0 is not generated into GL namespace

the Fiddler's picture


Thanks for catching that. This is a due to a shortcome in the binding generator - it's going to be a little hairy, but it should be fixable.

I think this might explain some abnormal behavior (borked samplers) I started seeing with 0.9.4. The conflict does not happen in older versions, which do not contain Uniform1ui (it's a 3.0 entry point).

the Fiddler's picture


Ok, I've found a solution to the GL3/Ati problem on Linux. It seems that you need to create a temporary context before taking the address of glXCreateContextAttribsARB, *even* if it seems to suceed without that.

I have committed the new code to SVN, along with several other improvements to context creation (support for forward-compatible and debug contexts, you can now choose which OpenGL version you want).