Difference between revisions of "Glloader/en"

From KlayGE
Jump to: navigation, search
m
Line 1: Line 1:
The [[glloader]], a subproject of [[KlayGE|Klay Game Engine]], is an OpenGL extension loading library. This project was started since 2004 (see '[[glloader's History]]'). It supports OpenGL core 1.0 to 4.2, OpenGL ES core 1.0 to 2.0, as well as WGL, GLX, and other GL extensions. There is a automatic code generater. All the things you want to do is to write a xml script if you have to support new extensions.
+
The [[glloader]], a subproject of [[KlayGE|Klay Game Engine]], is an OpenGL extension loading library. This project was started since 2004 (see '[[glloader's History]]'). It supports OpenGL core 1.0 to 4.2, OpenGL ES core 1.0 to 2.0, as well as WGL, GLX, EGL's extensions. There is a automatic code generator. All the things you want to do is to write a xml script if you have to support new extensions.
  
 
The [[glloader]]'s primary feature is that it offers a initializing path of an extension. So if an extension has promoted into the core, the loader will try to load it from the core before try the extension one.
 
The [[glloader]]'s primary feature is that it offers a initializing path of an extension. So if an extension has promoted into the core, the loader will try to load it from the core before try the extension one.

Revision as of 02:08, 18 December 2011

The glloader, a subproject of Klay Game Engine, is an OpenGL extension loading library. This project was started since 2004 (see 'glloader's History'). It supports OpenGL core 1.0 to 4.2, OpenGL ES core 1.0 to 2.0, as well as WGL, GLX, EGL's extensions. There is a automatic code generator. All the things you want to do is to write a xml script if you have to support new extensions.

The glloader's primary feature is that it offers a initializing path of an extension. So if an extension has promoted into the core, the loader will try to load it from the core before try the extension one.

After setting include and lib directories, all you need to do is add #include <glloader/glloader.h> into your code.

NOTE

Please don't put glloader into a folder with non-english name. Or else it's possible that autogen.py can't run normally.

When compiling glloader with Android NDK r6, a bug prevents a shared library without C++ uses the static library with STL. So if you encountering some linking error about std::string, please add a .cpp file to that shared library to work around this bug.

Interface

int glloader_is_supported(const char* name);

Find out if a particular feature is available on your platform. The parameter name is the name string. Returns non-zero means it's supported, or it'll return zero.

Note: You can use name string "GL_VERSION_x_y" to determine if the x.y core version of OpenGL is supported.


void* glloader_get_gl_proc_address(const char* name);

Load a OpenGL function. The parameter name is the function's name. The return value is the address of the extension function.

Note: When the function fails, there is NOT guarantee that the return value is NULL.


int glloader_num_features();

Get the number of supported features, including the core and the extensions.


const char* glloader_get_feature_name(int index);

Get the name of a feature. The parameter index's range is [0, glloader_num_features() - 1].


Automatic Code Generator

Because writing the loading code is very boring, I developed a automatic code generator to help writting the code. There are many xml files in the "./xml" directory. Each xml contains the typedefs, tokens, functions, and initializing path of an extension. Users can write their own xml scripts, the run "autogen.py". And it'll generate the loading code in src and include directories.

Dependency

Python 2.6 and up is required to run "autogen.py".