diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/aniso.c | 16 | ||||
-rw-r--r-- | tests/gl_ps.c | 40 | ||||
-rw-r--r-- | tests/gl_ps_workaround.c | 230 | ||||
-rw-r--r-- | tests/gl_ps_workaround2.c | 230 | ||||
-rw-r--r-- | tests/glbegin_points.c | 44 | ||||
-rwxr-xr-x | tests/runner.py | 168 | ||||
-rw-r--r-- | tests/s3tc.c | 16 | ||||
-rw-r--r-- | tests/s3tc_crunch.c | 16 | ||||
-rw-r--r-- | tests/sdl_fog_density.c | 48 | ||||
-rw-r--r-- | tests/sdl_fog_exp2.c | 48 | ||||
-rw-r--r-- | tests/sdl_fog_linear.c | 48 | ||||
-rw-r--r-- | tests/sdl_fog_negative.c | 48 | ||||
-rw-r--r-- | tests/sdl_fog_simple.c | 51 | ||||
-rw-r--r-- | tests/sdl_ogl.c | 48 | ||||
-rw-r--r-- | tests/sdl_ogl_defaultMatrixMode.c | 46 | ||||
-rw-r--r-- | tests/sdl_ogl_p.c | 44 |
16 files changed, 319 insertions, 822 deletions
diff --git a/tests/aniso.c b/tests/aniso.c index e02c20ac..1126265e 100644 --- a/tests/aniso.c +++ b/tests/aniso.c @@ -64,7 +64,7 @@ int main(int argc, char *argv[]) const char *exts = (const char *)glGetString(GL_EXTENSIONS); assert(hasext(exts, "GL_EXT_texture_filter_anisotropic")); - + GLint aniso; glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &aniso); printf("Max anisotropy: %d (using that)\n", aniso); @@ -73,10 +73,8 @@ int main(int argc, char *argv[]) // Set the OpenGL state after creating the context with SDL_SetVideoMode glClearColor( 0, 0, 0, 0 ); - -#if !EMSCRIPTEN - glEnable( GL_TEXTURE_2D ); // Need this to display a texture XXX unnecessary in OpenGL ES 2.0/WebGL -#endif + + glEnable( GL_TEXTURE_2D ); // Needed when we're using the fixed-function pipeline. glViewport( 0, 0, 600, 600 ); @@ -155,7 +153,7 @@ int main(int argc, char *argv[]) // Clear the screen before drawing glClear( GL_COLOR_BUFFER_BIT ); - + // Bind the texture to which subsequent calls refer to int w = 10; int n = 15; @@ -200,7 +198,7 @@ int main(int argc, char *argv[]) } */ SDL_GL_SwapBuffers(); - + #if !EMSCRIPTEN // Wait for 3 seconds to give us a chance to see the image SDL_Delay(2000); @@ -208,8 +206,8 @@ int main(int argc, char *argv[]) // Now we can delete the OpenGL texture and close down SDL glDeleteTextures( 1, &texture ); - + SDL_Quit(); - + return 0; } diff --git a/tests/gl_ps.c b/tests/gl_ps.c index 6ea0e3db..4fa79922 100644 --- a/tests/gl_ps.c +++ b/tests/gl_ps.c @@ -115,11 +115,11 @@ int main(int argc, char *argv[]) printf("Unable to set video mode: %s\n", SDL_GetError()); return 1; } - + // Set the OpenGL state after creating the context with SDL_SetVideoMode glClearColor( 0, 0, 0, 0 ); - + #if !EMSCRIPTEN glEnable( GL_TEXTURE_2D ); // Need this to display a texture XXX unnecessary in OpenGL ES 2.0/WebGL #endif @@ -135,30 +135,30 @@ int main(int argc, char *argv[]) glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); - + // Load the OpenGL texture GLuint texture; // Texture object handle SDL_Surface *surface; // Gives us the information to make the texture - - if ( (surface = IMG_Load("screenshot.png")) ) { - + + if ( (surface = IMG_Load("screenshot.png")) ) { + // Check that the image's width is a power of 2 if ( (surface->w & (surface->w - 1)) != 0 ) { printf("warning: image.bmp's width is not a power of 2\n"); } - + // Also check if the height is a power of 2 if ( (surface->h & (surface->h - 1)) != 0 ) { printf("warning: image.bmp's height is not a power of 2\n"); } - + // Have OpenGL generate a texture object handle for us glGenTextures( 1, &texture ); - + // Bind the texture object glBindTexture( GL_TEXTURE_2D, texture ); - + // Set the texture's stretching properties glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); @@ -169,25 +169,25 @@ int main(int argc, char *argv[]) memset(surface->pixels, 0x66, surface->w*surface->h); // Edit the texture object's image data using the information SDL_Surface gives us - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels ); //SDL_UnlockSurface(surface); - } + } else { printf("SDL could not load image.bmp: %s\n", SDL_GetError()); SDL_Quit(); return 1; - } - + } + // Free the SDL_Surface only if it was successfully created - if ( surface ) { + if ( surface ) { SDL_FreeSurface( surface ); } - + // Clear the screen before drawing glClear( GL_COLOR_BUFFER_BIT ); - + shaders(); // Bind the texture to which subsequent calls refer to @@ -218,7 +218,7 @@ int main(int argc, char *argv[]) glDisableClientState(GL_VERTEX_ARRAY); SDL_GL_SwapBuffers(); - + #if !EMSCRIPTEN // Wait for 3 seconds to give us a chance to see the image SDL_Delay(3000); @@ -226,8 +226,8 @@ int main(int argc, char *argv[]) // Now we can delete the OpenGL texture and close down SDL glDeleteTextures( 1, &texture ); - + SDL_Quit(); - + return 0; } diff --git a/tests/gl_ps_workaround.c b/tests/gl_ps_workaround.c deleted file mode 100644 index 1e2a5c41..00000000 --- a/tests/gl_ps_workaround.c +++ /dev/null @@ -1,230 +0,0 @@ -/******************************************************************* - * * - * Using SDL With OpenGL * - * * - * Tutorial by Kyle Foley (sdw) * - * * - * http://gpwiki.org/index.php/SDL:Tutorials:Using_SDL_with_OpenGL * - * * - *******************************************************************/ - -/* -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" -#include "SDL/SDL_image.h" -#if !USE_GLEW -#include "SDL/SDL_opengl.h" -#endif - -#include <stdio.h> -#include <string.h> -#include <assert.h> - -void shaders() { -#if USE_GLEW - glewInit(); -#endif - - GLint ok; - - const char *vertexShader = "void main(void) \n" - "{ \n" - " gl_Position = ftransform(); \n" - " gl_TexCoord[0] = gl_MultiTexCoord0; \n" - " gl_FrontColor = gl_Color; \n" - "} \n"; - const char *fragmentShader = "uniform sampler2D tex0; \n" - "void main(void) \n" - "{ \n" - " gl_FragColor = gl_Color * texture2D(tex0, gl_TexCoord[0].xy); \n" - "} \n"; - - GLuint vs = glCreateShader(GL_VERTEX_SHADER); - glShaderSource(vs, 1, &vertexShader, NULL); - glCompileShader(vs); - glGetShaderiv(vs, GL_COMPILE_STATUS, &ok); - assert(ok); - - GLuint fs = glCreateShader(GL_FRAGMENT_SHADER); - glShaderSource(fs, 1, &fragmentShader, NULL); - glCompileShader(fs); - glGetShaderiv(fs, GL_COMPILE_STATUS, &ok); - assert(ok); - - GLuint program = glCreateProgram(); - - glAttachShader(program, vs); - glAttachShader(program, fs); - glLinkProgram(program); - glGetProgramiv(program, GL_LINK_STATUS, &ok); - assert(ok); - - glUseProgram(program); -} - -int main(int argc, char *argv[]) -{ - SDL_Surface *screen; - - // Slightly different SDL initialization - 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 ); // *new* - - screen = SDL_SetVideoMode( 640, 480, 16, SDL_OPENGL ); // *changed* - if ( !screen ) { - printf("Unable to set video mode: %s\n", SDL_GetError()); - return 1; - } - - // Set the OpenGL state after creating the context with SDL_SetVideoMode - - glClearColor( 0, 0, 0, 0 ); - -#if !EMSCRIPTEN - glEnable( GL_TEXTURE_2D ); // Need this to display a texture XXX unnecessary in OpenGL ES 2.0/WebGL -#endif - - glViewport( 0, 0, 640, 480 ); - - glMatrixMode( GL_PROJECTION ); - GLfloat matrixData[] = { 2.0/640, 0, 0, 0, - 0, -2.0/480, 0, 0, - 0, 0, -1, 0, - -1, 1, 0, 1 }; - glLoadMatrixf(matrixData); // test loadmatrix - - glMatrixMode( GL_MODELVIEW ); - glLoadIdentity(); - - // Load the OpenGL texture - - GLuint texture; // Texture object handle - SDL_Surface *surface; // Gives us the information to make the texture - - if ( (surface = IMG_Load("screenshot.png")) ) { - - // Check that the image's width is a power of 2 - if ( (surface->w & (surface->w - 1)) != 0 ) { - printf("warning: image.bmp's width is not a power of 2\n"); - } - - // Also check if the height is a power of 2 - if ( (surface->h & (surface->h - 1)) != 0 ) { - printf("warning: image.bmp's height is not a power of 2\n"); - } - - // Have OpenGL generate a texture object handle for us - glGenTextures( 1, &texture ); - - // Bind the texture object - glBindTexture( GL_TEXTURE_2D, texture ); - - // Set the texture's stretching properties - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - - //SDL_LockSurface(surface); - - // Add some greyness - memset(surface->pixels, 0x66, surface->w*surface->h); - - // Edit the texture object's image data using the information SDL_Surface gives us - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, - GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels ); - - //SDL_UnlockSurface(surface); - } - else { - printf("SDL could not load image.bmp: %s\n", SDL_GetError()); - SDL_Quit(); - return 1; - } - - // Free the SDL_Surface only if it was successfully created - if ( surface ) { - SDL_FreeSurface( surface ); - } - - // Clear the screen before drawing - glClear( GL_COLOR_BUFFER_BIT ); - - shaders(); - - // Bind the texture to which subsequent calls refer to - glBindTexture( GL_TEXTURE_2D, texture ); - - // Use clientside vertex pointers to render two items. In this test we have each - // attribute in a separate buffer, packed (i.e. stride == 0) - GLfloat vertexData[] = { 10, 10, - 300, 10, - 300, 128, - 10, 128, - 410, 10, - 600, 10, - 630, 200, - 310, 250, - 100, 300, - 300, 300, - 300, 400, - 100, 400 }; - GLfloat textureData[] = { 0, 0, - 1, 0, - 1, 1, - 0, 1, - 0, 0.5, - 1, 0.5, - 1, 1, - 0.5, 1, - 0, 0, - 1, 0, - 1, 1, - 0, 1, }; - - glEnableClientState(GL_TEXTURE_2D); // XXX should be GL_TEXTURE_COORD_ARRAY); // XXX - glTexCoordPointer(2, GL_FLOAT, 0, textureData); - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(2, GL_FLOAT, 0, vertexData); - - glDrawArrays(GL_QUADS, 0, 12); - - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); - - SDL_GL_SwapBuffers(); - -#if !EMSCRIPTEN - // Wait for 3 seconds to give us a chance to see the image - SDL_Delay(3000); -#endif - - // Now we can delete the OpenGL texture and close down SDL - glDeleteTextures( 1, &texture ); - - SDL_Quit(); - - return 0; -} diff --git a/tests/gl_ps_workaround2.c b/tests/gl_ps_workaround2.c deleted file mode 100644 index e5bd2fd1..00000000 --- a/tests/gl_ps_workaround2.c +++ /dev/null @@ -1,230 +0,0 @@ -/******************************************************************* - * * - * Using SDL With OpenGL * - * * - * Tutorial by Kyle Foley (sdw) * - * * - * http://gpwiki.org/index.php/SDL:Tutorials:Using_SDL_with_OpenGL * - * * - *******************************************************************/ - -/* -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" -#include "SDL/SDL_image.h" -#if !USE_GLEW -#include "SDL/SDL_opengl.h" -#endif - -#include <stdio.h> -#include <string.h> -#include <assert.h> - -void shaders() { -#if USE_GLEW - glewInit(); -#endif - - GLint ok; - - const char *vertexShader = "void main(void) \n" - "{ \n" - " gl_Position = ftransform(); \n" - " gl_TexCoord[0] = gl_MultiTexCoord0; \n" - " gl_FrontColor = gl_Color; \n" - "} \n"; - const char *fragmentShader = "uniform sampler2D tex0; \n" - "void main(void) \n" - "{ \n" - " gl_FragColor = gl_Color * texture2D(tex0, gl_TexCoord[0].xy); \n" - "} \n"; - - GLuint vs = glCreateShader(GL_VERTEX_SHADER); - glShaderSource(vs, 1, &vertexShader, NULL); - glCompileShader(vs); - glGetShaderiv(vs, GL_COMPILE_STATUS, &ok); - assert(ok); - - GLuint fs = glCreateShader(GL_FRAGMENT_SHADER); - glShaderSource(fs, 1, &fragmentShader, NULL); - glCompileShader(fs); - glGetShaderiv(fs, GL_COMPILE_STATUS, &ok); - assert(ok); - - GLuint program = glCreateProgram(); - - glAttachShader(program, vs); - glAttachShader(program, fs); - glLinkProgram(program); - glGetProgramiv(program, GL_LINK_STATUS, &ok); - assert(ok); - - glUseProgram(program); -} - -int main(int argc, char *argv[]) -{ - SDL_Surface *screen; - - // Slightly different SDL initialization - 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 ); // *new* - - screen = SDL_SetVideoMode( 640, 480, 16, SDL_OPENGL ); // *changed* - if ( !screen ) { - printf("Unable to set video mode: %s\n", SDL_GetError()); - return 1; - } - - // Set the OpenGL state after creating the context with SDL_SetVideoMode - - glClearColor( 0, 0, 0, 0 ); - -#if !EMSCRIPTEN - glEnable( GL_TEXTURE_2D ); // Need this to display a texture XXX unnecessary in OpenGL ES 2.0/WebGL -#endif - - glViewport( 0, 0, 640, 480 ); - - glMatrixMode( GL_PROJECTION ); - GLfloat matrixData[] = { 2.0/640, 0, 0, 0, - 0, -2.0/480, 0, 0, - 0, 0, -1, 0, - -1, 1, 0, 1 }; - glLoadMatrixf(matrixData); // test loadmatrix - - glMatrixMode( GL_MODELVIEW ); - glLoadIdentity(); - - // Load the OpenGL texture - - GLuint texture; // Texture object handle - SDL_Surface *surface; // Gives us the information to make the texture - - if ( (surface = IMG_Load("screenshot.png")) ) { - - // Check that the image's width is a power of 2 - if ( (surface->w & (surface->w - 1)) != 0 ) { - printf("warning: image.bmp's width is not a power of 2\n"); - } - - // Also check if the height is a power of 2 - if ( (surface->h & (surface->h - 1)) != 0 ) { - printf("warning: image.bmp's height is not a power of 2\n"); - } - - // Have OpenGL generate a texture object handle for us - glGenTextures( 1, &texture ); - - // Bind the texture object - glBindTexture( GL_TEXTURE_2D, texture ); - - // Set the texture's stretching properties - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - - //SDL_LockSurface(surface); - - // Add some greyness - memset(surface->pixels, 0x66, surface->w*surface->h); - - // Edit the texture object's image data using the information SDL_Surface gives us - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, - GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels ); - - //SDL_UnlockSurface(surface); - } - else { - printf("SDL could not load image.bmp: %s\n", SDL_GetError()); - SDL_Quit(); - return 1; - } - - // Free the SDL_Surface only if it was successfully created - if ( surface ) { - SDL_FreeSurface( surface ); - } - - // Clear the screen before drawing - glClear( GL_COLOR_BUFFER_BIT ); - - shaders(); - - // Bind the texture to which subsequent calls refer to - glBindTexture( GL_TEXTURE_2D, texture ); - - // Use clientside vertex pointers to render two items. In this test we have each - // attribute in a separate buffer, packed (i.e. stride == 0) - GLfloat vertexData[] = { 10, 10, - 300, 10, - 300, 128, - 10, 128, - 410, 10, - 600, 10, - 630, 200, - 310, 250, - 100, 300, - 300, 300, - 300, 400, - 100, 400 }; - GLfloat textureData[] = { 0, 0, - 1, 0, - 1, 1, - 0, 1, - 0, 0.5, - 1, 0.5, - 1, 1, - 0.5, 1, - 0, 0, - 1, 0, - 1, 1, - 0, 1, }; - - glEnable(GL_TEXTURE_2D); // XXX should be GL_TEXTURE_COORD_ARRAY); and also glEnableClientState! XXX two workarounds here - glTexCoordPointer(2, GL_FLOAT, 0, textureData); - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(2, GL_FLOAT, 0, vertexData); - - glDrawArrays(GL_QUADS, 0, 12); - - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); - - SDL_GL_SwapBuffers(); - -#if !EMSCRIPTEN - // Wait for 3 seconds to give us a chance to see the image - SDL_Delay(3000); -#endif - - // Now we can delete the OpenGL texture and close down SDL - glDeleteTextures( 1, &texture ); - - SDL_Quit(); - - return 0; -} diff --git a/tests/glbegin_points.c b/tests/glbegin_points.c index b28cca4e..9128a4f5 100644 --- a/tests/glbegin_points.c +++ b/tests/glbegin_points.c @@ -46,14 +46,12 @@ int main(int argc, char *argv[]) printf("Unable to set video mode: %s\n", SDL_GetError()); return 1; } - + // Set the OpenGL state after creating the context with SDL_SetVideoMode glClearColor( 0, 0, 0, 0 ); - -#if !EMSCRIPTEN - glEnable( GL_TEXTURE_2D ); // Need this to display a texture XXX unnecessary in OpenGL ES 2.0/WebGL -#endif + + glEnable( GL_TEXTURE_2D ); // Needed when we're using the fixed-function pipeline. glViewport( 0, 0, 640, 480 ); @@ -66,30 +64,30 @@ int main(int argc, char *argv[]) glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); - + // Load the OpenGL texture GLuint texture; // Texture object handle SDL_Surface *surface; // Gives us the information to make the texture - - if ( (surface = IMG_Load("screenshot.png")) ) { - + + if ( (surface = IMG_Load("screenshot.png")) ) { + // Check that the image's width is a power of 2 if ( (surface->w & (surface->w - 1)) != 0 ) { printf("warning: image.bmp's width is not a power of 2\n"); } - + // Also check if the height is a power of 2 if ( (surface->h & (surface->h - 1)) != 0 ) { printf("warning: image.bmp's height is not a power of 2\n"); } - + // Have OpenGL generate a texture object handle for us glGenTextures( 1, &texture ); - + // Bind the texture object glBindTexture( GL_TEXTURE_2D, texture ); - + // Set the texture's stretching properties glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); @@ -100,25 +98,25 @@ int main(int argc, char *argv[]) memset(surface->pixels, 0x66, surface->w*surface->h); // Edit the texture object's image data using the information SDL_Surface gives us - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels ); //SDL_UnlockSurface(surface); - } + } else { printf("SDL could not load image.bmp: %s\n", SDL_GetError()); SDL_Quit(); return 1; - } - + } + // Free the SDL_Surface only if it was successfully created - if ( surface ) { + if ( surface ) { SDL_FreeSurface( surface ); } - + // Clear the screen before drawing glClear( GL_COLOR_BUFFER_BIT ); - + // Bind the texture to which subsequent calls refer to glBindTexture( GL_TEXTURE_2D, texture ); @@ -151,7 +149,7 @@ int main(int argc, char *argv[]) glEnd(); SDL_GL_SwapBuffers(); - + #if !EMSCRIPTEN // Wait for 3 seconds to give us a chance to see the image SDL_Delay(3000); @@ -159,8 +157,8 @@ int main(int argc, char *argv[]) // Now we can delete the OpenGL texture and close down SDL glDeleteTextures( 1, &texture ); - + SDL_Quit(); - + return 0; } diff --git a/tests/runner.py b/tests/runner.py index 720f434e..6e259f45 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -904,26 +904,26 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv) and 'brows void interface_clock_changed() { - UINT8 m_divshift; - INT32 m_divisor; + UINT8 m_divshift; + INT32 m_divisor; - //INT64 attos = m_attoseconds_per_cycle; - INT64 attos = 279365114840; - m_divshift = 0; - while (attos >= (1UL << 31)) - { - m_divshift++; - printf("m_divshift is %i, on %Ld >?= %lu\n", m_divshift, attos, 1UL << 31); - attos >>= 1; - } - m_divisor = attos; + //INT64 attos = m_attoseconds_per_cycle; + INT64 attos = 279365114840; + m_divshift = 0; + while (attos >= (1UL << 31)) + { + m_divshift++; + printf("m_divshift is %i, on %Ld >?= %lu\n", m_divshift, attos, 1UL << 31); + attos >>= 1; + } + m_divisor = attos; - printf("m_divisor is %i\n",m_divisor); + printf("m_divisor is %i\n",m_divisor); } int main() { - interface_clock_changed(); - return 0; + interface_clock_changed(); + return 0; } ''' self.do_run(src, '''m_divshift is 1, on 279365114840 >?= 2147483648 @@ -997,8 +997,8 @@ m_divisor is 1091269979 volatile UINT64 testu64a = 14746250828952703000U; while ((UINT64)testu32a * (UINT64)bigu32 < testu64a) { - printf("testu64a is %llu\n", testu64a); - testu64a /= 2; + printf("testu64a is %llu\n", testu64a); + testu64a /= 2; } return 0; @@ -1456,28 +1456,28 @@ c5,de,15,8a quint64 v = strtoull("4433ffeeddccbb00", NULL, 16); printf("%lld\n", v); - const string string64bitInt = "4433ffeeddccbb00"; - stringstream s(string64bitInt); - quint64 int64bitInt = 0; + const string string64bitInt = "4433ffeeddccbb00"; + stringstream s(string64bitInt); + quint64 int64bitInt = 0; printf("1\n"); - s >> hex >> int64bitInt; + s >> hex >> int64bitInt; printf("2\n"); - stringstream out; - out << hex << qbswap(int64bitInt); + stringstream out; + out << hex << qbswap(int64bitInt); - cout << out.str() << endl; - cout << hex << int64bitInt << endl; - cout << string64bitInt << endl; + cout << out.str() << endl; + cout << hex << int64bitInt << endl; + cout << string64bitInt << endl; - if (out.str() != "bbccddeeff3344") - { - cout << "Failed!" << endl; - } - else - { - cout << "Succeeded!" << endl; - } + if (out.str() != "bbccddeeff3344") + { + cout << "Failed!" << endl; + } + else + { + cout << "Succeeded!" << endl; + } return 0; } @@ -3613,36 +3613,36 @@ Exiting setjmp function, level: 0, prev_jmp: -1 src = open(path_from_root('tests', 'life.c'), 'r').read() self.do_run(src, '''-------------------------------- [] [] [][][] - [] [] [] [][] [] [] [] -[] [][] [][] [][][] [] + [] [] [] [][] [] [] [] +[] [][] [][] [][][] [] [] [] [] [] [][] [] [] [] [][] [] [] [] [] [][][][] - [][] [][] [] [][][] [] [] - [] [][] [][] [][] [][][] + [][] [][] [] [][][] [] [] + [] [][] [][] [][] [][][] [][] [][][] [] [] [][] [][] [] [][][] - [] - - - - - [][][] - [] [][] [][] - [][] [] [][] [][] - [][] [][] - [] - [][] + [] + + + + + [][][] + [] [][] [][] + [][] [] [][] [][] + [][] [][] + [] + [][] [][] [] [] [][] [] [][][] [] - [] [][] + [] [][] [] [] [] - [] + [] [] [] [] - [][][] - - [] + [][][] + + [] [][][] [] -------------------------------- ''', ['2'], force_c=True) @@ -4030,15 +4030,15 @@ def process(filename): // see related things in openjpeg typedef struct opj_mqc_state { - unsigned int qeval; - int mps; - struct opj_mqc_state *nmps; - struct opj_mqc_state *nlps; + unsigned int qeval; + int mps; + struct opj_mqc_state *nmps; + struct opj_mqc_state *nlps; } opj_mqc_state_t; static opj_mqc_state_t mqc_states[2] = { - {0x5600, 0, &mqc_states[2], &mqc_states[3]}, - {0x5602, 1, &mqc_states[3], &mqc_states[2]}, + {0x5600, 0, &mqc_states[2], &mqc_states[3]}, + {0x5602, 1, &mqc_states[3], &mqc_states[2]}, }; int main() { @@ -4807,25 +4807,25 @@ The current type of b is: 9 typedef struct { - int (*f)(void *); - void *d; - char s[16]; + int (*f)(void *); + void *d; + char s[16]; } LMEXFunctionStruct; int f(void *user) { - return 0; + return 0; } static LMEXFunctionStruct const a[] = { - {f, (void *)(int)'a', "aa"} + {f, (void *)(int)'a', "aa"} }; int main() { printf("ok\n"); - return a[0].f(a[0].d); + return a[0].f(a[0].d); } ''' self.do_run(src, 'ok\n') @@ -6210,13 +6210,13 @@ at function.:blag printf("|%s|\n", buffy); int numverts = -1; - printf("%d\n", sscanf(" numverts 1499\n", " numverts %d", &numverts)); // white space is the same, even if tab vs space + printf("%d\n", sscanf(" numverts 1499\n", " numverts %d", &numverts)); // white space is the same, even if tab vs space printf("%d\n", numverts); int index; float u, v; short start, count; - printf("%d\n", sscanf(" vert 87 ( 0.481565 0.059481 ) 0 1\n", " vert %d ( %f %f ) %hu %hu", &index, &u, &v, &start, &count)); + printf("%d\n", sscanf(" vert 87 ( 0.481565 0.059481 ) 0 1\n", " vert %d ( %f %f ) %hu %hu", &index, &u, &v, &start, &count)); printf("%d,%.6f,%.6f,%hu,%hu\n", index, u, v, start, count); int neg, neg2, neg3 = 0; @@ -10461,8 +10461,8 @@ f.close() #define _TESTA_H_ class TestA { - public: - TestA(); + public: + TestA(); }; #endif @@ -10472,8 +10472,8 @@ f.close() #define _TESTB_H_ class TestB { - public: - TestB(); + public: + TestB(); }; #endif @@ -10483,7 +10483,7 @@ f.close() #include <testa.h> TestA::TestA() { - printf("TestA\n"); + printf("TestA\n"); } ''') open('testb.cpp', 'w').write(r''' @@ -10493,8 +10493,8 @@ f.close() /* */ TestB::TestB() { - printf("TestB\n"); - TestA* testa = new TestA(); + printf("TestB\n"); + TestA* testa = new TestA(); } ''') open('main.cpp', 'w').write(r''' @@ -10505,9 +10505,9 @@ f.close() /* */ int main(int argc, char** argv) { - printf("Main\n"); - TestA* testa = new TestA(); - TestB* testb = new TestB(); + printf("Main\n"); + TestA* testa = new TestA(); + TestB* testb = new TestB(); } ''') @@ -11132,7 +11132,7 @@ f.close() output = Popen([os.path.join(self.get_dir(), 'files.o.run')], stdin=open(os.path.join(self.get_dir(), 'stdin')), stdout=PIPE, stderr=PIPE).communicate() self.assertContained('''size: 37 data: 119,97,107,97,32,119,97,107,97,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35 -loop: 119 97 107 97 32 119 97 107 97 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 +loop: 119 97 107 97 32 119 97 107 97 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 input:inter-active texto $ @@ -12549,14 +12549,6 @@ elif 'browser' in str(sys.argv): shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png')) self.btest('gl_ps_packed.c', reference='gl_ps.png', args=['--preload-file', 'screenshot.png']) - def test_gl_ps_workaround(self): - shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png')) - self.btest('gl_ps_workaround.c', reference='gl_ps.png', args=['--preload-file', 'screenshot.png']) - - def test_gl_ps_workaround2(self): - shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png')) - self.btest('gl_ps_workaround2.c', reference='gl_ps.png', args=['--preload-file', 'screenshot.png']) - def test_gl_ps_strides(self): shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png')) self.btest('gl_ps_strides.c', reference='gl_ps_strides.png', args=['--preload-file', 'screenshot.png']) @@ -14005,7 +13997,7 @@ if __name__ == '__main__': which = map(lambda mode: mode+'.'+test, test_modes) else: which = [which] - + print >> sys.stderr, ','.join(which) for test in which: print >> sys.stderr, 'will skip "%s"' % test diff --git a/tests/s3tc.c b/tests/s3tc.c index c2736feb..16ee783f 100644 --- a/tests/s3tc.c +++ b/tests/s3tc.c @@ -63,14 +63,12 @@ int main(int argc, char *argv[]) const char *exts = (const char *)glGetString(GL_EXTENSIONS); assert(hasext(exts, "GL_ARB_texture_compression")); assert(hasext(exts, "GL_EXT_texture_compression_s3tc")); - + // Set the OpenGL state after creating the context with SDL_SetVideoMode glClearColor( 0, 0, 0, 0 ); - -#if !EMSCRIPTEN - glEnable( GL_TEXTURE_2D ); // Need this to display a texture XXX unnecessary in OpenGL ES 2.0/WebGL -#endif + + glEnable( GL_TEXTURE_2D ); // Needed when we're using the fixed-function pipeline. glViewport( 0, 0, 640, 480 ); @@ -110,7 +108,7 @@ int main(int argc, char *argv[]) // Clear the screen before drawing glClear( GL_COLOR_BUFFER_BIT ); - + // Bind the texture to which subsequent calls refer to glBindTexture( GL_TEXTURE_2D, texture ); @@ -143,7 +141,7 @@ int main(int argc, char *argv[]) glEnd(); SDL_GL_SwapBuffers(); - + #if !EMSCRIPTEN // Wait for 3 seconds to give us a chance to see the image SDL_Delay(1500); @@ -151,8 +149,8 @@ int main(int argc, char *argv[]) // Now we can delete the OpenGL texture and close down SDL glDeleteTextures( 1, &texture ); - + SDL_Quit(); - + return 0; } diff --git a/tests/s3tc_crunch.c b/tests/s3tc_crunch.c index 57974109..90ed02d9 100644 --- a/tests/s3tc_crunch.c +++ b/tests/s3tc_crunch.c @@ -63,14 +63,12 @@ int main(int argc, char *argv[]) const char *exts = (const char *)glGetString(GL_EXTENSIONS); assert(hasext(exts, "GL_ARB_texture_compression")); assert(hasext(exts, "GL_EXT_texture_compression_s3tc")); - + // Set the OpenGL state after creating the context with SDL_SetVideoMode glClearColor( 0, 0, 0, 0 ); - -#if !EMSCRIPTEN - glEnable( GL_TEXTURE_2D ); // Need this to display a texture XXX unnecessary in OpenGL ES 2.0/WebGL -#endif + + glEnable( GL_TEXTURE_2D ); // Needed when we're using the fixed-function pipeline. glViewport( 0, 0, 640, 480 ); @@ -158,7 +156,7 @@ int main(int argc, char *argv[]) // Clear the screen before drawing glClear( GL_COLOR_BUFFER_BIT ); - + // Bind the texture to which subsequent calls refer to glBindTexture( GL_TEXTURE_2D, texture ); @@ -195,7 +193,7 @@ int main(int argc, char *argv[]) glEnd(); SDL_GL_SwapBuffers(); - + #if !EMSCRIPTEN // Wait for 3 seconds to give us a chance to see the image SDL_Delay(1500); @@ -203,8 +201,8 @@ int main(int argc, char *argv[]) // Now we can delete the OpenGL texture and close down SDL glDeleteTextures( 1, &texture ); - + SDL_Quit(); - + return 0; } diff --git a/tests/sdl_fog_density.c b/tests/sdl_fog_density.c index 95773419..cab6a4d2 100644 --- a/tests/sdl_fog_density.c +++ b/tests/sdl_fog_density.c @@ -47,14 +47,12 @@ int main(int argc, char *argv[]) printf("Unable to set video mode: %s\n", SDL_GetError()); return 1; } - + // Set the OpenGL state after creating the context with SDL_SetVideoMode glClearColor( 0, 0, 0, 0 ); - -#if !EMSCRIPTEN - glEnable( GL_TEXTURE_2D ); // Need this to display a texture XXX unnecessary in OpenGL ES 2.0/WebGL -#endif + + glEnable( GL_TEXTURE_2D ); // Needed when we're using the fixed-function pipeline. glViewport( 0, 0, 640, 480 ); @@ -63,33 +61,33 @@ int main(int argc, char *argv[]) glLoadIdentity(); glOrtho( 0, 640, 480, 0, -1000, 1000 ); - + glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); - + // Load the OpenGL texture GLuint texture; // Texture object handle SDL_Surface *surface; // Gives us the information to make the texture - - if ( (surface = IMG_Load("screenshot.png")) ) { - + + if ( (surface = IMG_Load("screenshot.png")) ) { + // Check that the image's width is a power of 2 if ( (surface->w & (surface->w - 1)) != 0 ) { printf("warning: image.bmp's width is not a power of 2\n"); } - + // Also check if the height is a power of 2 if ( (surface->h & (surface->h - 1)) != 0 ) { printf("warning: image.bmp's height is not a power of 2\n"); } - + // Have OpenGL generate a texture object handle for us glGenTextures( 1, &texture ); - + // Bind the texture object glBindTexture( GL_TEXTURE_2D, texture ); - + // Set the texture's stretching properties glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); @@ -100,25 +98,25 @@ int main(int argc, char *argv[]) memset(surface->pixels, 0x66, surface->w*surface->h); // Edit the texture object's image data using the information SDL_Surface gives us - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels ); //SDL_UnlockSurface(surface); - } + } else { printf("SDL could not load image.bmp: %s\n", SDL_GetError()); SDL_Quit(); return 1; - } - + } + // Free the SDL_Surface only if it was successfully created - if ( surface ) { + if ( surface ) { SDL_FreeSurface( surface ); } - + // Clear the screen before drawing glClear( GL_COLOR_BUFFER_BIT ); - + // Bind the texture to which subsequent calls refer to glBindTexture( GL_TEXTURE_2D, texture ); @@ -148,9 +146,7 @@ int main(int argc, char *argv[]) glTexCoord2i( 0, 1 ); glVertex3f( 500, 410, 1 ); glEnd(); -#if !EMSCRIPTEN glDisable(GL_TEXTURE_2D); -#endif glColor3ub(90, 255, 255); glBegin( GL_QUADS ); @@ -168,7 +164,7 @@ int main(int argc, char *argv[]) glEnd(); SDL_GL_SwapBuffers(); - + #if !EMSCRIPTEN // Wait for 3 seconds to give us a chance to see the image SDL_Delay(30000); @@ -176,8 +172,8 @@ int main(int argc, char *argv[]) // Now we can delete the OpenGL texture and close down SDL glDeleteTextures( 1, &texture ); - + SDL_Quit(); - + return 0; } diff --git a/tests/sdl_fog_exp2.c b/tests/sdl_fog_exp2.c index a09a5e3d..dba0c708 100644 --- a/tests/sdl_fog_exp2.c +++ b/tests/sdl_fog_exp2.c @@ -47,14 +47,12 @@ int main(int argc, char *argv[]) printf("Unable to set video mode: %s\n", SDL_GetError()); return 1; } - + // Set the OpenGL state after creating the context with SDL_SetVideoMode glClearColor( 0, 0, 0, 0 ); - -#if !EMSCRIPTEN - glEnable( GL_TEXTURE_2D ); // Need this to display a texture XXX unnecessary in OpenGL ES 2.0/WebGL -#endif + + glEnable( GL_TEXTURE_2D ); // Needed when we're using the fixed-function pipeline. glViewport( 0, 0, 640, 480 ); @@ -63,33 +61,33 @@ int main(int argc, char *argv[]) glLoadIdentity(); glOrtho( 0, 640, 480, 0, -1000, 1000 ); - + glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); - + // Load the OpenGL texture GLuint texture; // Texture object handle SDL_Surface *surface; // Gives us the information to make the texture - - if ( (surface = IMG_Load("screenshot.png")) ) { - + + if ( (surface = IMG_Load("screenshot.png")) ) { + // Check that the image's width is a power of 2 if ( (surface->w & (surface->w - 1)) != 0 ) { printf("warning: image.bmp's width is not a power of 2\n"); } - + // Also check if the height is a power of 2 if ( (surface->h & (surface->h - 1)) != 0 ) { printf("warning: image.bmp's height is not a power of 2\n"); } - + // Have OpenGL generate a texture object handle for us glGenTextures( 1, &texture ); - + // Bind the texture object glBindTexture( GL_TEXTURE_2D, texture ); - + // Set the texture's stretching properties glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); @@ -100,25 +98,25 @@ int main(int argc, char *argv[]) memset(surface->pixels, 0x66, surface->w*surface->h); // Edit the texture object's image data using the information SDL_Surface gives us - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels ); //SDL_UnlockSurface(surface); - } + } else { printf("SDL could not load image.bmp: %s\n", SDL_GetError()); SDL_Quit(); return 1; - } - + } + // Free the SDL_Surface only if it was successfully created - if ( surface ) { + if ( surface ) { SDL_FreeSurface( surface ); } - + // Clear the screen before drawing glClear( GL_COLOR_BUFFER_BIT ); - + // Bind the texture to which subsequent calls refer to glBindTexture( GL_TEXTURE_2D, texture ); @@ -149,9 +147,7 @@ int main(int argc, char *argv[]) glTexCoord2i( 0, 1 ); glVertex3f( 500, 410, 1 ); glEnd(); -#if !EMSCRIPTEN glDisable(GL_TEXTURE_2D); -#endif glColor3ub(90, 255, 255); glBegin( GL_QUADS ); @@ -169,7 +165,7 @@ int main(int argc, char *argv[]) glEnd(); SDL_GL_SwapBuffers(); - + #if !EMSCRIPTEN // Wait for 3 seconds to give us a chance to see the image SDL_Delay(30000); @@ -177,8 +173,8 @@ int main(int argc, char *argv[]) // Now we can delete the OpenGL texture and close down SDL glDeleteTextures( 1, &texture ); - + SDL_Quit(); - + return 0; } diff --git a/tests/sdl_fog_linear.c b/tests/sdl_fog_linear.c index 8fc18b7c..f0805650 100644 --- a/tests/sdl_fog_linear.c +++ b/tests/sdl_fog_linear.c @@ -47,14 +47,12 @@ int main(int argc, char *argv[]) printf("Unable to set video mode: %s\n", SDL_GetError()); return 1; } - + // Set the OpenGL state after creating the context with SDL_SetVideoMode glClearColor( 0, 0, 0, 0 ); - -#if !EMSCRIPTEN - glEnable( GL_TEXTURE_2D ); // Need this to display a texture XXX unnecessary in OpenGL ES 2.0/WebGL -#endif + + glEnable( GL_TEXTURE_2D ); // Needed when we're using the fixed-function pipeline. glViewport( 0, 0, 640, 480 ); @@ -63,33 +61,33 @@ int main(int argc, char *argv[]) glLoadIdentity(); glOrtho( 0, 640, 480, 0, -1000, 1000 ); - + glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); - + // Load the OpenGL texture GLuint texture; // Texture object handle SDL_Surface *surface; // Gives us the information to make the texture - - if ( (surface = IMG_Load("screenshot.png")) ) { - + + if ( (surface = IMG_Load("screenshot.png")) ) { + // Check that the image's width is a power of 2 if ( (surface->w & (surface->w - 1)) != 0 ) { printf("warning: image.bmp's width is not a power of 2\n"); } - + // Also check if the height is a power of 2 if ( (surface->h & (surface->h - 1)) != 0 ) { printf("warning: image.bmp's height is not a power of 2\n"); } - + // Have OpenGL generate a texture object handle for us glGenTextures( 1, &texture ); - + // Bind the texture object glBindTexture( GL_TEXTURE_2D, texture ); - + // Set the texture's stretching properties glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); @@ -100,25 +98,25 @@ int main(int argc, char *argv[]) memset(surface->pixels, 0x66, surface->w*surface->h); // Edit the texture object's image data using the information SDL_Surface gives us - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels ); //SDL_UnlockSurface(surface); - } + } else { printf("SDL could not load image.bmp: %s\n", SDL_GetError()); SDL_Quit(); return 1; - } - + } + // Free the SDL_Surface only if it was successfully created - if ( surface ) { + if ( surface ) { SDL_FreeSurface( surface ); } - + // Clear the screen before drawing glClear( GL_COLOR_BUFFER_BIT ); - + // Bind the texture to which subsequent calls refer to glBindTexture( GL_TEXTURE_2D, texture ); @@ -150,9 +148,7 @@ int main(int argc, char *argv[]) glTexCoord2i( 0, 1 ); glVertex3f( 500, 410, 1 ); glEnd(); -#if !EMSCRIPTEN glDisable(GL_TEXTURE_2D); -#endif glColor3ub(90, 255, 255); glBegin( GL_QUADS ); @@ -170,7 +166,7 @@ int main(int argc, char *argv[]) glEnd(); SDL_GL_SwapBuffers(); - + #if !EMSCRIPTEN // Wait for 3 seconds to give us a chance to see the image SDL_Delay(30000); @@ -178,8 +174,8 @@ int main(int argc, char *argv[]) // Now we can delete the OpenGL texture and close down SDL glDeleteTextures( 1, &texture ); - + SDL_Quit(); - + return 0; } diff --git a/tests/sdl_fog_negative.c b/tests/sdl_fog_negative.c index 2d589a47..1ede63a7 100644 --- a/tests/sdl_fog_negative.c +++ b/tests/sdl_fog_negative.c @@ -47,14 +47,12 @@ int main(int argc, char *argv[]) printf("Unable to set video mode: %s\n", SDL_GetError()); return 1; } - + // Set the OpenGL state after creating the context with SDL_SetVideoMode glClearColor( 0, 0, 0, 0 ); - -#if !EMSCRIPTEN - glEnable( GL_TEXTURE_2D ); // Need this to display a texture XXX unnecessary in OpenGL ES 2.0/WebGL -#endif + + glEnable( GL_TEXTURE_2D ); // Needed when we're using the fixed-function pipeline. glViewport( 0, 0, 640, 480 ); @@ -63,33 +61,33 @@ int main(int argc, char *argv[]) glLoadIdentity(); glOrtho( 0, 640, 480, 0, -1000, 1000 ); - + glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); - + // Load the OpenGL texture GLuint texture; // Texture object handle SDL_Surface *surface; // Gives us the information to make the texture - - if ( (surface = IMG_Load("screenshot.png")) ) { - + + if ( (surface = IMG_Load("screenshot.png")) ) { + // Check that the image's width is a power of 2 if ( (surface->w & (surface->w - 1)) != 0 ) { printf("warning: image.bmp's width is not a power of 2\n"); } - + // Also check if the height is a power of 2 if ( (surface->h & (surface->h - 1)) != 0 ) { printf("warning: image.bmp's height is not a power of 2\n"); } - + // Have OpenGL generate a texture object handle for us glGenTextures( 1, &texture ); - + // Bind the texture object glBindTexture( GL_TEXTURE_2D, texture ); - + // Set the texture's stretching properties glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); @@ -100,25 +98,25 @@ int main(int argc, char *argv[]) memset(surface->pixels, 0x66, surface->w*surface->h); // Edit the texture object's image data using the information SDL_Surface gives us - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels ); //SDL_UnlockSurface(surface); - } + } else { printf("SDL could not load image.bmp: %s\n", SDL_GetError()); SDL_Quit(); return 1; - } - + } + // Free the SDL_Surface only if it was successfully created - if ( surface ) { + if ( surface ) { SDL_FreeSurface( surface ); } - + // Clear the screen before drawing glClear( GL_COLOR_BUFFER_BIT ); - + // Bind the texture to which subsequent calls refer to glBindTexture( GL_TEXTURE_2D, texture ); @@ -147,9 +145,7 @@ int main(int argc, char *argv[]) glTexCoord2i( 0, 1 ); glVertex3f( 500, 410, -1 ); glEnd(); -#if !EMSCRIPTEN glDisable(GL_TEXTURE_2D); -#endif glColor3ub(90, 255, 255); glBegin( GL_QUADS ); @@ -167,7 +163,7 @@ int main(int argc, char *argv[]) glEnd(); SDL_GL_SwapBuffers(); - + #if !EMSCRIPTEN // Wait for 3 seconds to give us a chance to see the image SDL_Delay(30000); @@ -175,8 +171,8 @@ int main(int argc, char *argv[]) // Now we can delete the OpenGL texture and close down SDL glDeleteTextures( 1, &texture ); - + SDL_Quit(); - + return 0; } diff --git a/tests/sdl_fog_simple.c b/tests/sdl_fog_simple.c index be023593..6c052bf5 100644 --- a/tests/sdl_fog_simple.c +++ b/tests/sdl_fog_simple.c @@ -47,14 +47,10 @@ int main(int argc, char *argv[]) printf("Unable to set video mode: %s\n", SDL_GetError()); return 1; } - + // Set the OpenGL state after creating the context with SDL_SetVideoMode glClearColor( 0, 0, 0, 0 ); - -#if !EMSCRIPTEN - glEnable( GL_TEXTURE_2D ); // Need this to display a texture XXX unnecessary in OpenGL ES 2.0/WebGL -#endif glViewport( 0, 0, 640, 480 ); @@ -63,33 +59,38 @@ int main(int argc, char *argv[]) glLoadIdentity(); glOrtho( 0, 640, 480, 0, -1000, 1000 ); - + glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); - + + // Delay Enable to after MatrixMode to assure we've activated + // immediate mode. Otherwise, we don't properly record that + // TEXTURE_2D is enabled for imm mode emulation. + glEnable( GL_TEXTURE_2D ); // Needed when we're using the fixed-function pipeline. + // Load the OpenGL texture GLuint texture; // Texture object handle SDL_Surface *surface; // Gives us the information to make the texture - - if ( (surface = IMG_Load("screenshot.png")) ) { - + + if ( (surface = IMG_Load("screenshot.png")) ) { + // Check that the image's width is a power of 2 if ( (surface->w & (surface->w - 1)) != 0 ) { printf("warning: image.bmp's width is not a power of 2\n"); } - + // Also check if the height is a power of 2 if ( (surface->h & (surface->h - 1)) != 0 ) { printf("warning: image.bmp's height is not a power of 2\n"); } - + // Have OpenGL generate a texture object handle for us glGenTextures( 1, &texture ); - + // Bind the texture object glBindTexture( GL_TEXTURE_2D, texture ); - + // Set the texture's stretching properties glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); @@ -100,25 +101,25 @@ int main(int argc, char *argv[]) memset(surface->pixels, 0x66, surface->w*surface->h); // Edit the texture object's image data using the information SDL_Surface gives us - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels ); //SDL_UnlockSurface(surface); - } + } else { printf("SDL could not load image.bmp: %s\n", SDL_GetError()); SDL_Quit(); return 1; - } - + } + // Free the SDL_Surface only if it was successfully created - if ( surface ) { + if ( surface ) { SDL_FreeSurface( surface ); } - + // Clear the screen before drawing glClear( GL_COLOR_BUFFER_BIT ); - + // Bind the texture to which subsequent calls refer to glBindTexture( GL_TEXTURE_2D, texture ); @@ -147,9 +148,7 @@ int main(int argc, char *argv[]) glTexCoord2i( 0, 1 ); glVertex3f( 500, 410, 1 ); glEnd(); -#if !EMSCRIPTEN glDisable(GL_TEXTURE_2D); -#endif glColor3ub(90, 255, 255); glBegin( GL_QUADS ); @@ -167,7 +166,7 @@ int main(int argc, char *argv[]) glEnd(); SDL_GL_SwapBuffers(); - + #if !EMSCRIPTEN // Wait for 3 seconds to give us a chance to see the image SDL_Delay(30000); @@ -175,8 +174,8 @@ int main(int argc, char *argv[]) // Now we can delete the OpenGL texture and close down SDL glDeleteTextures( 1, &texture ); - + SDL_Quit(); - + return 0; } diff --git a/tests/sdl_ogl.c b/tests/sdl_ogl.c index 6b6a5b4a..e7071dcd 100644 --- a/tests/sdl_ogl.c +++ b/tests/sdl_ogl.c @@ -46,14 +46,12 @@ int main(int argc, char *argv[]) printf("Unable to set video mode: %s\n", SDL_GetError()); return 1; } - + // Set the OpenGL state after creating the context with SDL_SetVideoMode glClearColor( 0, 0, 0, 0 ); - -#if !EMSCRIPTEN - glEnable( GL_TEXTURE_2D ); // Need this to display a texture XXX unnecessary in OpenGL ES 2.0/WebGL -#endif + + glEnable( GL_TEXTURE_2D ); // Needed when we're using the fixed-function pipeline. glViewport( 0, 0, 640, 480 ); @@ -62,33 +60,33 @@ int main(int argc, char *argv[]) glLoadIdentity(); glOrtho( 0, 640, 480, 0, -1, 1 ); - + glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); - + // Load the OpenGL texture GLuint texture; // Texture object handle SDL_Surface *surface; // Gives us the information to make the texture - - if ( (surface = IMG_Load("screenshot.png")) ) { - + + if ( (surface = IMG_Load("screenshot.png")) ) { + // Check that the image's width is a power of 2 if ( (surface->w & (surface->w - 1)) != 0 ) { printf("warning: image.bmp's width is not a power of 2\n"); } - + // Also check if the height is a power of 2 if ( (surface->h & (surface->h - 1)) != 0 ) { printf("warning: image.bmp's height is not a power of 2\n"); } - + // Have OpenGL generate a texture object handle for us glGenTextures( 1, &texture ); - + // Bind the texture object glBindTexture( GL_TEXTURE_2D, texture ); - + // Set the texture's stretching properties glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); @@ -99,25 +97,25 @@ int main(int argc, char *argv[]) memset(surface->pixels, 0x66, surface->w*surface->h); // Edit the texture object's image data using the information SDL_Surface gives us - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels ); //SDL_UnlockSurface(surface); - } + } else { printf("SDL could not load image.bmp: %s\n", SDL_GetError()); SDL_Quit(); return 1; - } - + } + // Free the SDL_Surface only if it was successfully created - if ( surface ) { + if ( surface ) { SDL_FreeSurface( surface ); } - + // Clear the screen before drawing glClear( GL_COLOR_BUFFER_BIT ); - + // Bind the texture to which subsequent calls refer to glBindTexture( GL_TEXTURE_2D, texture ); @@ -140,9 +138,7 @@ int main(int argc, char *argv[]) glTexCoord2i( 0, 1 ); glVertex3f( 500, 410, 0 ); glEnd(); -#if !EMSCRIPTEN glDisable(GL_TEXTURE_2D); -#endif glColor3ub(90, 255, 255); glBegin( GL_QUADS ); @@ -160,7 +156,7 @@ int main(int argc, char *argv[]) glEnd(); SDL_GL_SwapBuffers(); - + #if !EMSCRIPTEN // Wait for 3 seconds to give us a chance to see the image SDL_Delay(3000); @@ -168,8 +164,8 @@ int main(int argc, char *argv[]) // Now we can delete the OpenGL texture and close down SDL glDeleteTextures( 1, &texture ); - + SDL_Quit(); - + return 0; } diff --git a/tests/sdl_ogl_defaultMatrixMode.c b/tests/sdl_ogl_defaultMatrixMode.c index 0da0a326..eec2a831 100644 --- a/tests/sdl_ogl_defaultMatrixMode.c +++ b/tests/sdl_ogl_defaultMatrixMode.c @@ -46,14 +46,12 @@ int main(int argc, char *argv[]) printf("Unable to set video mode: %s\n", SDL_GetError()); return 1; } - + // Set the OpenGL state after creating the context with SDL_SetVideoMode glClearColor( 0, 0, 0, 0 ); - -#if !EMSCRIPTEN - glEnable( GL_TEXTURE_2D ); // Need this to display a texture XXX unnecessary in OpenGL ES 2.0/WebGL -#endif + + glEnable( GL_TEXTURE_2D ); // Needed when we're using the fixed-function pipeline. glViewport( 0, 0, 640, 480 ); @@ -66,30 +64,30 @@ int main(int argc, char *argv[]) glLoadIdentity(); glOrtho( 0, 640, 480, 0, -1, 1 ); - + // Load the OpenGL texture GLuint texture; // Texture object handle SDL_Surface *surface; // Gives us the information to make the texture - - if ( (surface = IMG_Load("screenshot.png")) ) { - + + if ( (surface = IMG_Load("screenshot.png")) ) { + // Check that the image's width is a power of 2 if ( (surface->w & (surface->w - 1)) != 0 ) { printf("warning: image.bmp's width is not a power of 2\n"); } - + // Also check if the height is a power of 2 if ( (surface->h & (surface->h - 1)) != 0 ) { printf("warning: image.bmp's height is not a power of 2\n"); } - + // Have OpenGL generate a texture object handle for us glGenTextures( 1, &texture ); - + // Bind the texture object glBindTexture( GL_TEXTURE_2D, texture ); - + // Set the texture's stretching properties glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); @@ -100,25 +98,25 @@ int main(int argc, char *argv[]) memset(surface->pixels, 0x66, surface->w*surface->h); // Edit the texture object's image data using the information SDL_Surface gives us - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels ); //SDL_UnlockSurface(surface); - } + } else { printf("SDL could not load image.bmp: %s\n", SDL_GetError()); SDL_Quit(); return 1; - } - + } + // Free the SDL_Surface only if it was successfully created - if ( surface ) { + if ( surface ) { SDL_FreeSurface( surface ); } - + // Clear the screen before drawing glClear( GL_COLOR_BUFFER_BIT ); - + // Bind the texture to which subsequent calls refer to glBindTexture( GL_TEXTURE_2D, texture ); @@ -141,9 +139,7 @@ int main(int argc, char *argv[]) glTexCoord2i( 0, 1 ); glVertex3f( 500, 410, 0 ); glEnd(); -#if !EMSCRIPTEN glDisable(GL_TEXTURE_2D); -#endif glColor3ub(90, 255, 255); glBegin( GL_QUADS ); @@ -161,7 +157,7 @@ int main(int argc, char *argv[]) glEnd(); SDL_GL_SwapBuffers(); - + #if !EMSCRIPTEN // Wait for 3 seconds to give us a chance to see the image SDL_Delay(3000); @@ -169,8 +165,8 @@ int main(int argc, char *argv[]) // Now we can delete the OpenGL texture and close down SDL glDeleteTextures( 1, &texture ); - + SDL_Quit(); - + return 0; } diff --git a/tests/sdl_ogl_p.c b/tests/sdl_ogl_p.c index fcc53a40..1889d926 100644 --- a/tests/sdl_ogl_p.c +++ b/tests/sdl_ogl_p.c @@ -46,14 +46,12 @@ int main(int argc, char *argv[]) printf("Unable to set video mode: %s\n", SDL_GetError()); return 1; } - + // Set the OpenGL state after creating the context with SDL_SetVideoMode glClearColor( 0, 0, 0, 0 ); - -#if !EMSCRIPTEN - glEnable( GL_TEXTURE_2D ); // Need this to display a texture XXX unnecessary in OpenGL ES 2.0/WebGL -#endif + + glEnable( GL_TEXTURE_2D ); // Needed when we're using the fixed-function pipeline. glViewport( 0, 0, 640, 480 ); @@ -66,30 +64,30 @@ int main(int argc, char *argv[]) glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); - + // Load the OpenGL texture GLuint texture; // Texture object handle SDL_Surface *surface; // Gives us the information to make the texture - - if ( (surface = IMG_Load("screenshot.png")) ) { - + + if ( (surface = IMG_Load("screenshot.png")) ) { + // Check that the image's width is a power of 2 if ( (surface->w & (surface->w - 1)) != 0 ) { printf("warning: image.bmp's width is not a power of 2\n"); } - + // Also check if the height is a power of 2 if ( (surface->h & (surface->h - 1)) != 0 ) { printf("warning: image.bmp's height is not a power of 2\n"); } - + // Have OpenGL generate a texture object handle for us glGenTextures( 1, &texture ); - + // Bind the texture object glBindTexture( GL_TEXTURE_2D, texture ); - + // Set the texture's stretching properties glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); @@ -100,25 +98,25 @@ int main(int argc, char *argv[]) memset(surface->pixels, 0x66, surface->w*surface->h); // Edit the texture object's image data using the information SDL_Surface gives us - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels ); //SDL_UnlockSurface(surface); - } + } else { printf("SDL could not load image.bmp: %s\n", SDL_GetError()); SDL_Quit(); return 1; - } - + } + // Free the SDL_Surface only if it was successfully created - if ( surface ) { + if ( surface ) { SDL_FreeSurface( surface ); } - + // Clear the screen before drawing glClear( GL_COLOR_BUFFER_BIT ); - + // Bind the texture to which subsequent calls refer to glBindTexture( GL_TEXTURE_2D, texture ); @@ -151,7 +149,7 @@ int main(int argc, char *argv[]) glEnd(); SDL_GL_SwapBuffers(); - + #if !EMSCRIPTEN // Wait for 3 seconds to give us a chance to see the image SDL_Delay(3000); @@ -159,8 +157,8 @@ int main(int argc, char *argv[]) // Now we can delete the OpenGL texture and close down SDL glDeleteTextures( 1, &texture ); - + SDL_Quit(); - + return 0; } |