Skip to content

GLFunBind is a header only, easy to use library made to make simple and safe use OpenGL.

License

Notifications You must be signed in to change notification settings

c30ra/GLFunBind

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GLFunBind v1.1

GLFunBind is a header only, easy to use library made to make simple and safe use OpenGL.

UPDATES:

  • added otpion to output enums as defines and not as "static const GLenum"
  • now gl_veriosn_profile.h headers are generated. This helper headers can be used to avoid inclusion of function, enums and types headers.

BUILDING:

The library it self doesn't need to be builded, but in order to generate the headers you need to build GLHeaderGen. This tool parse gl.xml (from OpenGL Registry) and generate the proper headers.

In order to build GLHeaderGen you need:

  • Qt5.4
  • TinyXML 2.0
  • MSVC 2013
  • other compiler with c++11 support should work

Steps:

  • Open files paths.pri and change the various TinyXML2 variable to the path of you TinyXML2 directory, the directory must contain "lib" and "include". If you plan to use debug builds be sure that debug build reside in same directory.

  • run qmake to generate the makefiles.

  • then run your make tool(jom, nmake, make)

  • make install to copy headers.

  • then go to "bin" directory (in the build tree) and lunch GLHeaderGen.exe from command line, with the path to your gl.xml file.

  • wait until it has finished.

  • the generated header will be put in the include directory under your build tree.

INSTALLING:

Just copy the "include" directory in your project tree or add an include path in your favorite IDE pointing to it.

USAGE:

Include tree:

 include
    |_gl/
      |_enums_GL_VERSION_n_n_profile.h
      |_functions_GL_VERSION_n_n_profile.h
    |_enum_undefs.h
    |_binds.h
    |_function.h
    |_glbinder.h
    |_types.h

Directory explanation: Inside include directory you find all headers required by the library to work:

  • function.h contains all the class templates used to bind OpenGL functions,

  • binds.h is auto-generated by GLFunBind and contains instances of Function class that hold the address of OpenGL functions. It also contain a vector of all Function object used for initializing all the functions one time with initialize().

  • glbinder.h is used if you want to initialize all the function at once.

  • types.h contain all the types used by OpenGL.

  • under gl directory, there are all the headers used to call the OpenGL functions with the corresponding enumerator.

In your source or header files, include one of the header according to the OpenGL version you want to use, for example:

 #include <gl/functions_GL_VERSION_3_2_core.h>

Differently from other OpenGL bindings, you don't need to be sure if you include the system "gl.h", before or after GLFunBind headers. But if you are using "gl.h"or other bindings, remember to include "enums_undef.h" before GLFunBind headers,in order to avoid name collision.

Later in your code just call any OpenGL function you need preceded by "gl::" namespace, for example:

	gl::glDrawArrays(gl::GL_TRIANGLES, 0,0);

Avoid to expand gl namespace, especially if you are using other OpenGL binds, because doing so you can create name collision with other library. If you are using only GLFunBind you can expand namespace gl safely.

Doing this way functions will be loaded the first time they are called. If you instead prefer to load all the functions when you initialize OpenGL, just include glbinder.h in your source and make a call to initialize(). initilaize() doesn't provide(at the moment) context management, so it's up to you make sure context is properly set and be current. Same thing apply to what said berfore.

About

GLFunBind is a header only, easy to use library made to make simple and safe use OpenGL.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published