diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-01-22 17:11:55 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-01-22 17:11:55 -0800 |
commit | db122ed09d76e9ea634c40fc8601e2b16c85f479 (patch) | |
tree | fe8c69b8af09c91d84894912464f08db94bf837a /tests | |
parent | ee3397080daddc7e07ff212da1f9ed4cb8a7f947 (diff) | |
parent | 3cd9b678c63f728ec2f4647dcd1fa4e5a5103194 (diff) |
Merge pull request #1905 from juj/glGetTexEnv
Gl get tex env
Diffstat (limited to 'tests')
-rw-r--r-- | tests/glgettexenv.c | 71 | ||||
-rw-r--r-- | tests/test_browser.py | 3 |
2 files changed, 74 insertions, 0 deletions
diff --git a/tests/glgettexenv.c b/tests/glgettexenv.c new file mode 100644 index 00000000..a051a690 --- /dev/null +++ b/tests/glgettexenv.c @@ -0,0 +1,71 @@ +/* +THIS WORK, INCLUDING THE SOURCE CODE, DOCUMENTATION +AND RELATED MEDIA AND DATA, IS PLACED INTO THE PUBLIC DOMAIN. + +THE ORIGINAL AUTHOR IS KYLE FOLEY. + +THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY +OF ANY KIND, NOT EVEN THE IMPLIED WARRANTY OF +MERCHANTABILITY. THE AUTHOR OF THIS SOFTWARE, +ASSUMES _NO_ RESPONSIBILITY FOR ANY CONSEQUENCE +RESULTING FROM THE USE, MODIFICATION, OR +REDISTRIBUTION OF THIS SOFTWARE. +*/ + +#if !EMSCRIPTEN +#define USE_GLEW 1 +#endif + +#if USE_GLEW +#include "GL/glew.h" +#endif + +#include "SDL/SDL.h" +#if !USE_GLEW +#include "SDL/SDL_opengl.h" +#endif + +#include <stdio.h> +#include <string.h> +#include <assert.h> + +int main(int argc, char *argv[]) +{ + SDL_Surface *screen; + if ( SDL_Init(SDL_INIT_VIDEO) != 0 ) { + printf("Unable to initialize SDL: %s\n", SDL_GetError()); + return 1; + } + + SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); + screen = SDL_SetVideoMode( 640, 480, 24, SDL_OPENGL ); + if ( !screen ) { + printf("Unable to set video mode: %s\n", SDL_GetError()); + return 1; + } + + GLint value = 0; + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND); + glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &value); + assert(value == GL_BLEND); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &value); + assert(value == GL_MODULATE); + + GLfloat colora[4] = { 0.2f, 0.3f, 0.4f, 0.5f }; + GLfloat colorb[4] = {}; + glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, colora); + glGetTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, colorb); + printf("%f %f %f %f\n", colorb[0], colorb[1], colorb[2], colorb[3]); + assert(colora[0] == colorb[0]); + assert(colora[1] == colorb[1]); + assert(colora[2] == colorb[2]); + assert(colora[3] == colorb[3]); + SDL_Quit(); + +#ifdef REPORT_RESULT + int result = 1; + REPORT_RESULT(); +#endif + return 0; +} diff --git a/tests/test_browser.py b/tests/test_browser.py index 8c75c861..02bcecbd 100644 --- a/tests/test_browser.py +++ b/tests/test_browser.py @@ -1546,6 +1546,9 @@ keydown(100);keyup(100); // trigger the end def test_cube_explosion(self): self.btest('cube_explosion.c', reference='cube_explosion.png', args=['-s', 'LEGACY_GL_EMULATION=1']) + def test_glgettexenv(self): + self.btest('glgettexenv.c', args=['-s', 'LEGACY_GL_EMULATION=1'], expected=['1']) + def test_sdl_canvas_blank(self): self.btest('sdl_canvas_blank.c', reference='sdl_canvas_blank.png') |