Menu

Home

pet_cz

In the ancient ages of OpenGL 2.0, I had a very simple OpenGL wrapper by Lars Middendorf (many thanks). But the wrapper was getting old and wrapping new functions by hand was very slow...

I started to think about automatic generation of OpenGL wrapper and about the functionality of the wrapper itself. The way Lars made it was very cute - there was a lot of function overloads to simplify the .NET development and on the other hand the code looked very similar to C/C++ code.

That is the aim of the OpenGL4Net library: to provide an OpenGL wrapper with syntax that is as close as possible to the C code, while having a lot of overloaded functions to make .NET life easier. As there is a huge shift in the new OpenGL context in removing the fixed pipeline including the matrix operations, the library also provides some basic math classes for matrices and vectors. And finally, some functionality is encapsulated into helper classes (e.g., creating render context or building simple shaders).

And here is the result! Full featured OpenGL 4.3 wrapper:

  • Nicelooking function names:
    :::C#
    gl.WhateverFunc()
  • C-like constant names:

~~~~:::C#
GL.WHATEVER_CONSTANT

* Simple extension testing:

~~~~:::C#
    if(gl.Extension.isEXT_vertex_array)...

    // or using strings 
    string[] needExtensions = new string[] { "GL_EXT_bgra" ... }

    foreach(string extension in needExtensions) 
        if(gl.Extension.isSupported(extension))...
  • A lot of overloads:
    :::C#
    gl.TexImage2D(GL.TEXTURE_2D, 0, GL.RGBA, 0, "texture.png");
  • Simple context initialization for OpenGL 3 and higher:
    :::C#
    rc = RenderingContext.CreateContext(this, new RenderingContextSetting()
         {      
            majorVersion = 3,
            minorVersion = 2,
            profile = RenderingContextSetting.ProfileEnum.Core,
            context = RenderingContextSetting.ContextEnum.ForwardCompatible
         }
    );
  • Helper classes:
    :::C#    
    g_program = new Program("Basic", 
        File.ReadAllText("Vertex.vert"), 
        File.ReadAllText("Fragment.frag"), 
        File.ReadAllText("Geometry.geom")
    ); 
    Console.WriteLine(g_program.log);

    gl.UseProgram(g_program.id);    
  • Intellisense documentation:

Intellisense


Related

Wiki: Helper classes
Wiki: Tutorials