#include <GL/gl.h> #include <GL/glut.h> #include <glux.h> // declare GL_NV_vertex_program extension as required GLUX_REQUIRE(GL_NV_vertex_program); void main(int argc,char **argv) { GLuint vprog; // init openGL (with glut) glutInit(&argc, argv); glutInitWindowSize(640, 480); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH | GLUT_ALPHA); // init gluX gluxInit(); // if we are here, GL_NV_vertex_program is available ! // gluX has already stopped the execution if one of the required extensions // is not available. // let's call some vertex program stuff (just for example) cerr << "Calling glGenProgramsNV ..." << endl; glGenProgramsNV(1,&vprog); cerr << "Calling glBindProgramNV ..." << endl; glBindProgramNV(GL_VERTEX_PROGRAM_NV, vprog); cerr << "Done." << endl; }As the extensions are required, gluX will end the execution if one or more extensions are not available.
#include <GL/gl.h> #include <GL/glut.h> #include <glux.h> // declare extensions that you want to load GLUX_LOAD(GL_NV_vertex_program); GLUX_LOAD(GL_SUN_mesh_array); void main(int argc,char **argv) { // init openGL (with glut) glutInit(&argc, argv); glutInitWindowSize(640, 480); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH | GLUT_ALPHA); // init gluX gluxInit(); cerr << "gluX does not stop if a loaded extension is not available." << endl; if (GLUX_IS_AVAILABLE(GL_SUN_mesh_array) == GLUX_AVAILABLE) cerr << endl << "GL_SUN_mesh_array is available" << endl; else cerr << endl << "GL_SUN_mesh_array is *not* available" << endl; if (GLUX_IS_AVAILABLE(GL_NV_vertex_program) == GLUX_AVAILABLE) cerr << endl << "GL_NV_vertex_program is available" << endl; else cerr << endl << "GL_NV_vertex_program is *not* available" << endl; cerr << endl << "Done." << endl; }
[ OK ] GL_ARB_extensionExtension is available
[FAIL] GL_ARB_extensionExtension is not available
[DEVL] GL_ARB_extensionExtension seems to be available (functions are present but the extension is not declared as available by the driver). See DEVL extensions for more information.
[XXXX] GL_ARB_extensionExtension is available but has been disabled to emulate a profile. See gluX Extension Profiles for more information.
using namespace glux;. This can be disabled by defining GLUX_EXPLICIT_NAMESPACE before including <glux.h>. In this case, a function glDoSomethingCool should be called with glux::glDoSomethingCool.
Very often applications are developed on powerful graphics hardware but are designed to support less powerful hardware (well, the non-hardcore-gamer user :-).
Testing what your application will look like may not be easy: Deactivating extension loading mechanism by commenting some parts of the code is really not a good solution (well, anyone who released an application with his never-seen-before-effect disabled knows what I mean :-)
Therefore gluX now supports extension profiles. The idea is to ask gluX to emulate less powerful hardware by disabling some extensions. Since gluX cannot emulate extensions that your hardware doesn't support, this mechanism works only to emulate hardware whose extension set is included in the installed graphic card extension set (like emulating a GeForce3 with a GeForceFX).
Function or macro | Description | Calling context |
gluxInit() | gluX initialization. | It should be called once just after the OpenGL initialization |
gluxInit(int <flags>=0) | gluX initialization. | <flags> can be set to GLUX_DEVL to allow development extensions (see DEVL extensions). |
gluxInit(int <flags>=0,const char *<profile>=NULL) | gluX initialization. | <profile> can be set to the filename of a gluX extension profile (see Using a gluX profile). |
GLUX_REQUIRE(ext_name) | This macro declare that your program requires the ext_name extension to be executed. If the extension is not found, the program will be exited by gluX. | It should be called once in your main .cpp file, outside of any function declaration. |
GLUX_LOAD(ext_name) | This macro declare that your program should load the ext_name extension. The availability of the extension could be tested with gluxIsAvailable. | It should be called once in your main .cpp file, outside of any function declaration. |
GLUX_IS_AVAILABLE(ext_name) | This macro test if a loaded extension is available at runtime. It is faster than gluxIsAvailable (see below) because it does not use a string to reference the extension. The constraint is that a GLUX_LOAD or a GLUX_REQUIRE for the extension should be present in the same cpp file. | Call this every time you need to know if an extension is available. As extension availability is tested only once at startup, this macro is fast. This macro is a boolean. |
gluxIsAvailable(ext_name_string) | Test if a loaded extension is available on the running graphic hardware. | Call this every time you need to know if an extension is available. Extension name should be a null terminated string. For faster testing use GLUX_IS_AVAILABLE macro rather than this function. The function returns GLUX_AVAILABLE if the extension is available, GLUX_NOT_AVAILABLE if not, GLUX_NOT_LOADED if the extension was not loaded by gluX at startup. |
GLUX_IS_DEVL(ext_name) | This macro test if a loaded extension is in development (not officially available in the driver). It is faster than gluxIsDevl (see below) because it does not use a string to reference the extension. The constraint is that a GLUX_LOAD or a GLUX_REQUIRE for the extension should be present in the same cpp file. | Call this every time you need to know if an extension is in development. As extension status is tested only once at startup, this macro is fast. This macro is a boolean. |
gluxIsDevl(ext_name_string) | Test if a loaded extension is in development. | Call this every time you need to know if an extension is in development. Extension name should be a null terminated string. For faster testing use GLUX_IS_DEVL macro rather than this function. The function returns GLUX_DEVL if the extension is in development, GLUX_NOT_DEVL if not, GLUX_NOT_LOADED if the extension was not loaded by gluX at startup. |
If you forget to declare an extension with GLUX_REQUIRE or GLUX_LOAD, or simply forget to call gluxInit(), gluX will have a robust behavior: if you call one extension function, the execution will be stopped and gluX will print a message indicating witch function of witch extension failed to execute. (see sample/sample3.cpp).