diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-06-27 15:50:32 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-06-27 15:52:25 -0700 |
commit | 25ef30fdbeaf63217e8c61b4bca3b7dcce8a54ac (patch) | |
tree | 2f8bbfcf43352b4940a683923bd99afe4e2c1b70 | |
parent | 74a7e8e3e03d0c7efe987b1d667c951482655100 (diff) |
support for anisotropic filtering
-rw-r--r-- | tests/aniso.c | 39 | ||||
-rw-r--r-- | tests/aniso.png | bin | 0 -> 35041 bytes | |||
-rwxr-xr-x | tests/runner.py | 4 |
3 files changed, 32 insertions, 11 deletions
diff --git a/tests/aniso.c b/tests/aniso.c index f2735f49..e673e228 100644 --- a/tests/aniso.c +++ b/tests/aniso.c @@ -54,7 +54,7 @@ int main(int argc, char *argv[]) SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); // *new* - screen = SDL_SetVideoMode( 640, 480, 16, SDL_OPENGL ); // *changed* + screen = SDL_SetVideoMode( 600, 600, 16, SDL_OPENGL ); // *changed* if ( !screen ) { printf("Unable to set video mode: %s\n", SDL_GetError()); return 1; @@ -67,7 +67,7 @@ int main(int argc, char *argv[]) GLint aniso; glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &aniso); - printf("Max anisotropy: %d\n", aniso); + printf("Max anisotropy: %d (using that)\n", aniso); assert(aniso >= 4); // Set the OpenGL state after creating the context with SDL_SetVideoMode @@ -78,12 +78,12 @@ int main(int argc, char *argv[]) glEnable( GL_TEXTURE_2D ); // Need this to display a texture XXX unnecessary in OpenGL ES 2.0/WebGL #endif - glViewport( 0, 0, 800, 600 ); + glViewport( 0, 0, 600, 600 ); glMatrixMode( GL_PROJECTION ); - GLfloat matrixData[] = { 2.0/640, 0, 0, 0, - 0, -2.0/480, 0, 0, - 0, 0, -2.0/480, 0, + GLfloat matrixData[] = { 2.0/600, 0, 0, 0, + 0, -2.0/600, 0, 0, + 0, 0, -2.0/600, 0, -1, 1, 0, 1 }; glLoadMatrixf(matrixData); // test loadmatrix @@ -143,7 +143,7 @@ int main(int argc, char *argv[]) } glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 4); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso); } // Prepare and Render @@ -152,6 +152,27 @@ int main(int argc, char *argv[]) glClear( GL_COLOR_BUFFER_BIT ); // Bind the texture to which subsequent calls refer to + int w = 10; + int n = 15; + glBindTexture( GL_TEXTURE_2D, texture ); + for (int x = 0; x < n; x++) { + int start = x*w*2; + glBegin( GL_TRIANGLES ); + glTexCoord2i( 1, 0 ); glVertex3f( start , 0, 0 ); + glTexCoord2i( 0, 0 ); glVertex3f( start+w, 300, 0 ); + glTexCoord2i( 1, 1 ); glVertex3f( start-w, 300, 0 ); + glEnd(); + } + glBindTexture( GL_TEXTURE_2D, texture2 ); + for (int x = 0; x < n; x++) { + int start = n*w*2 + x*w*2; + glBegin( GL_TRIANGLES ); + glTexCoord2i( 1, 0 ); glVertex3f( start , 0, 0 ); + glTexCoord2i( 0, 0 ); glVertex3f( start+w, 300, 0 ); + glTexCoord2i( 1, 1 ); glVertex3f( start-w, 300, 0 ); + glEnd(); + } +/* int w = 8; int n = 20; for (int x = 0; x < n; x++) { @@ -172,12 +193,12 @@ 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(10000); + SDL_Delay(2000); #endif // Now we can delete the OpenGL texture and close down SDL diff --git a/tests/aniso.png b/tests/aniso.png Binary files differnew file mode 100644 index 00000000..5f5812d2 --- /dev/null +++ b/tests/aniso.png diff --git a/tests/runner.py b/tests/runner.py index 852928ef..44ede42c 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -7906,9 +7906,9 @@ elif 'browser' in str(sys.argv): shutil.move('water.dds', 'water.donotfindme.dds') # make sure we load from the compressed self.btest('s3tc_crunch.c', reference='s3tc_crunch.png', args=['--pre-js', 'pre.js']) - def zzztest_aniso(self): + def test_aniso(self): shutil.copyfile(path_from_root('tests', 'water.dds'), 'water.dds') - self.btest('aniso.c', reference='aniso.png', args=['--preload-file', 'water.dds', '-s', 'GL_DEBUG=1']) + self.btest('aniso.c', reference='aniso.png', args=['--preload-file', 'water.dds']) def test_pre_run_deps(self): # Adding a dependency in preRun will delay run |