aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/aniso.c16
-rw-r--r--tests/gl_ps.c40
-rw-r--r--tests/gl_ps_workaround.c42
-rw-r--r--tests/gl_ps_workaround2.c40
-rw-r--r--tests/glbegin_points.c44
-rw-r--r--tests/s3tc.c16
-rw-r--r--tests/s3tc_crunch.c16
-rw-r--r--tests/sdl_fog_density.c48
-rw-r--r--tests/sdl_fog_exp2.c48
-rw-r--r--tests/sdl_fog_linear.c48
-rw-r--r--tests/sdl_fog_negative.c48
-rw-r--r--tests/sdl_fog_simple.c51
-rw-r--r--tests/sdl_ogl.c48
-rw-r--r--tests/sdl_ogl_defaultMatrixMode.c46
-rw-r--r--tests/sdl_ogl_p.c44
15 files changed, 280 insertions, 315 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
index 1e2a5c41..268eaf22 100644
--- a/tests/gl_ps_workaround.c
+++ b/tests/gl_ps_workaround.c
@@ -99,11 +99,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
@@ -119,30 +119,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 );
@@ -153,25 +153,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
@@ -204,7 +204,7 @@ int main(int argc, char *argv[])
1, 1,
0, 1, };
- glEnableClientState(GL_TEXTURE_2D); // XXX should be GL_TEXTURE_COORD_ARRAY); // XXX
+ 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);
@@ -215,7 +215,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);
@@ -223,8 +223,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_workaround2.c b/tests/gl_ps_workaround2.c
index e5bd2fd1..55145fa6 100644
--- a/tests/gl_ps_workaround2.c
+++ b/tests/gl_ps_workaround2.c
@@ -99,11 +99,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
@@ -119,30 +119,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 );
@@ -153,25 +153,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
@@ -215,7 +215,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);
@@ -223,8 +223,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/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/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;
}