Menu

Home

pet_cz

About

OpenGL4NET is an automatic generator for OpenGL wrapper for .NET. The solution also contains a
project that produces a library from the generated source code and a set of examples.

Solution structure

Project OpenGLSpec

OpenGLSpec is the wrapper generator. It contains the main files for generator (in root directory)
and a set of supporting files.

Directories:

  • classes - contains definition of supporting classes
    Files *.class.cs are complete classes that are attached to the project.
    • Context.class.cs
      This class creates and manages an OpenGL context
    • GLEntry.class.cs
      An attribute for automatic import of opengl func address
    • Loader.class.cs
      Class for automatic import of opengl func address
    • LoadingProvider.class.cs
      Class that specifies a way to make the address import (depends on OS). Currently, only Windows is supported.
    • Shader.class.cs
      Classes Shader and Program simplifies the use of shaders.
    • Time.class.cs
      Timer
    • WGL.class.cs
      WGL constants definition. This class will be replaced by an automatic generator in future releases.
    • Windows.class.cs
      Set of windows structures and functions that are necessary for creating the gl context.
    • Matrix, Vector[2-4] - deprecated, replaced by templates
    • Files *.func.cs are parts of automatically generated classes.
      Part of class (w)gl.Extension, the rest of this class is generated
    • Files *.enum.cs defines enums
  • gloverloads - contains overloads of some opengl functions. These overloads should simplify the use of library (eg., TexImage2D(target, level, internalformat, border, filename)). Each file with overload methods must have a name corresponding to overloaded method.

    • autooverload.list is a list of fucntions where IntPtr is overloaded by pinned array (this is a subject to change, could be probably generated automatically - retained attribute?).
    • autooverload.rules contains rules to overload function with parameter: <type> in/out array[<count>]</count></type>
    • autooverload.spec contains new function specifications mainly to add Vector and Matrix datatypes.
    • Files .cs are complex overloads of OpenGL functions (e.g. TexImage...) (Gen.cs are subjects to remove, they are replaced by autooverload.rules).
  • glspec - contains opengl specification files from http://www.opengl.org/registry/. The files are:

    • enumext.spec: GL constants
    • gl.spec: GL functions headers
    • gl.tm: GL type mapping
    • wgl.spec: WGL functions headers
    • wglext.spec: WGL extensions functions headers
    • wgl.tm: WGL type mapping

    Additional files

    • native.tm file contains a type mapping between C and NET data types. The structure of native.tm is: C name \t NET type for single item \t NET type for array of items
    • Files *.manual.tm map missing typemaps in opengl specification (e.g. PIXELFORMATDESCRIPTOR) and add some new datatypes for overloaded functions (Vectors, Matrices etc.).
    • File gldelegates.cs adds delegates (e.g. for debugfuncs).
  • templates - contains templated classes.
    These classes has a similar structure as a generic class except the fact, that the concrete classes are generated offline. The teplate rules are in the comments in the begining of file, e.g.

    :::C#
    // template: f float 
    class Vector3<t> {
        T x, T y, T z;
    }
Concrete class is class Vector3f { float x, float y, float z; }

Versioning note

The versioning is generated in the following way (major.minor.revision.build) (This is subject to change):

  • major.minor - corresponds to OpenGL specification (defined in SpecConvert.cs)
  • revision - is the revision number of project in SVN repository (using tortois SubWCRev). As a pre-build action of OpenGLSpec project a version.bat file is called and if tortois cmd. utilities are installed, it generates bin/revision.no file. This file is used during the library generation process.
  • build - autoincrement build number. Last build number is stored in build.no file in OpenGLSpec project root. As a pre-build action of the project a version.bat is called, reads the contains of build.no, increments it by 1, stores it and make a copy in bin/build.no

Starting

To build the library and run the examples, it is neccesary to do the following steps:

  1. Build the OpenGLSpec and execute it
    Set the OpenGLSpec project as a startup. The wrapper generator has several command line
    arguments that can control the generation process:

    -s or -separate The classes will be generated to separate files.
    -d or -doc The gl function will be commented using the downloaded opengl documentation if available.
    -download Automatically downloads the documentation from opengl web site if available. As the documentation to OpenGL is not very good, some functions are only commented with some generic text. Furthermore, if the help is not available, the generator is trying more possibilities and it can take quite a long time. The time of building the wrapper using the download function is approaching one hour!
    -w or -wait Wait for ENTER after finished

    For your first build, you can just run the project and see, what's going on.

  2. Building the library
    After the OpenGLSpec is executed, an OpenGL4Net.cs file will be created in bin\output directory. Now you can generate the OpenGL4Net.dll just by building OpenGLnet project. This project has a Pre-Build event that copies the newly generated OpenGL4Net.cs file to the source directory of OpenGLnet project and build it. (This is a subject to change)

  3. Building SourceForge distribution
    In the OpenGLSpec/bin directory run the ForgeDistrib.bat. This batch file generates both versions of OpenGL4Net.cs files (doc/no doc), compiles it in x86 and x64 a produces the doxumentation .xml. All these files are created in _sourceforge/rev no./ directory.

Copyright

Copyright (c) 2013, Petr Vanecek
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this
    list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice,
    this list of conditions and the following disclaimer in the documentation
    and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.

Authors

Petr Vanecek (opengl4net@gmail.com)

Project Admins: