diff options
author | Jari Vetoniemi <mailroxas@gmail.com> | 2014-01-14 17:04:58 +0200 |
---|---|---|
committer | Jari Vetoniemi <mailroxas@gmail.com> | 2014-01-14 17:04:58 +0200 |
commit | a39788f5020f726cbe6cfcc49de9cc669f445237 (patch) | |
tree | 221e61708bbbd3fcf95c1d964f48a3bb3333698e /tests | |
parent | 0e36f078d4a9666303340506638726d316096e07 (diff) |
Add GLEW 1.10.0 emulation
Includes library_glew.js that stubs the init functions, but also provides the
other functions.
GL/glew.h is now changed to work with GLEW_EXT_foo_bar constants,
some missing constants that are in GLEW 1.10.0 are also provided.
Otherwise it still uses SDL_opengl.h to provide function definitions and
other constants.
Linaro's GLEW (glew-oes) is also supported to some degree to make it
easier to get ES1 and ES2 software using it running.
What it lacks:
- Some constants and function declarations that are in GLEW 1.10.0
might be missing.
- The real glew-es fork also includes normal GL constants and
function pointers, this does not.
Tests ran:
- tests/runner.py browser
Real world example using this code (and upcomming glfw3 port) can be found here:
http://cloudef.eu/glhck
http://cloudef.eu/glhck/qb.html
Diffstat (limited to 'tests')
-rw-r--r-- | tests/glew.c | 51 | ||||
-rw-r--r-- | tests/test_browser.py | 6 |
2 files changed, 56 insertions, 1 deletions
diff --git a/tests/glew.c b/tests/glew.c new file mode 100644 index 00000000..3bf93fd9 --- /dev/null +++ b/tests/glew.c @@ -0,0 +1,51 @@ +#include <GL/glew.h> +#include <stdio.h> +#include <assert.h> +#include <string.h> + +/* for context creation */ +#include <SDL/SDL.h> + +int main() +{ + assert(SDL_Init(SDL_INIT_VIDEO) == 0); + assert(SDL_SetVideoMode(640, 480, 16, SDL_OPENGL) != NULL); + + assert(glewInit() == GLEW_OK); + assert(glewGetString(0) == NULL); + assert(!strcmp((const char*)glewGetString(1), "1.10.0")); + assert(!strcmp((const char*)glewGetString(2), "1")); + assert(!strcmp((const char*)glewGetString(3), "10")); + assert(!strcmp((const char*)glewGetString(4), "0")); + + for (int i = 0; i < 8; ++i) { + assert(glewGetErrorString(i) != NULL); + } + + assert(glewGetExtension("EXT_unexistant") == 0); + assert(glewIsSupported("EXT_unexistant EXT_foobar") == 0); + + /* we can't be sure about which extension exists, so lets do test on + * some of the common ones */ + if (GLEW_EXT_texture_filter_anisotropic) { + assert(glewGetExtension("EXT_texture_filter_anisotropic") == 1); + assert(glewGetExtension("GL_EXT_texture_filter_anisotropic") == 1); + } + + if (GLEW_EXT_framebuffer_object) { + assert(glewGetExtension("EXT_framebuffer_object") == 1); + assert(glewGetExtension("GL_EXT_framebuffer_object") == 1); + } + + if (GLEW_EXT_texture_filter_anisotropic && + GLEW_EXT_framebuffer_object) { + assert(glewIsSupported("EXT_texture_filter_anisotropic EXT_framebuffer_object") == 1); + assert(glewIsSupported("GL_EXT_texture_filter_anisotropic GL_EXT_framebuffer_object") == 1); + } + +#ifdef REPORT_RESULT + int result = 1; + REPORT_RESULT(); +#endif + return 0; +} diff --git a/tests/test_browser.py b/tests/test_browser.py index c2eaabb6..23022604 100644 --- a/tests/test_browser.py +++ b/tests/test_browser.py @@ -1746,4 +1746,8 @@ keydown(100);keyup(100); // trigger the end # Now run test in browser self.btest(path_from_root('tests', 'uuid', 'test.c'), '1') - + def test_glew(self): + self.btest(path_from_root('tests', 'glew.c'), expected='1') + self.btest(path_from_root('tests', 'glew.c'), args=['-s', 'LEGACY_GL_EMULATION=1'], expected='1') + self.btest(path_from_root('tests', 'glew.c'), args=['-DGLEW_MX'], expected='1') + self.btest(path_from_root('tests', 'glew.c'), args=['-s', 'LEGACY_GL_EMULATION=1', '-DGLEW_MX'], expected='1') |