Glloader/ru

From KlayGE
< Glloader
Revision as of 12:59, 5 July 2011 by Cin2000 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

glloader, под-проект Klay Game Engine, это библиотека загрузки расширений OpenGL. Этот проект был запущен в 2004 году(см. 'glloader's History'). Он поддерживает OpenGL от 1.0 до 4.1, OpenGL ES от 1.0 до 2.0, также хорошо как WGL, GLX, и другие расширения GL. Имеется автоматическая генерация кода. Если вам нужна поддержка новых расширений, то всё что вам нужно, это написать сценарий на XMLязыке.


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.

Заметки

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

Интерфейс

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".