diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-02-27 22:04:03 -0500 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-02-27 22:04:03 -0500 |
commit | dd61bf0a31c9b4367fab0c8868b64c4377f3f16f (patch) | |
tree | fe8f66b4e609516238fb1ce5c57fccb40ef758f5 /tests | |
parent | de3cbc986cdf32e71b57b01766324d7cac68bda6 (diff) |
fix and enable gles2 tests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/glbook/Chapter_13/ParticleSystem/ParticleSystem_orig.c | 48 | ||||
-rw-r--r-- | tests/glbook/Chapter_9/TextureWrap/TextureWrap_orig.c | 2 | ||||
-rwxr-xr-x | tests/runner.py | 21 |
3 files changed, 46 insertions, 25 deletions
diff --git a/tests/glbook/Chapter_13/ParticleSystem/ParticleSystem_orig.c b/tests/glbook/Chapter_13/ParticleSystem/ParticleSystem_orig.c index 378d05a7..02fddd9c 100644 --- a/tests/glbook/Chapter_13/ParticleSystem/ParticleSystem_orig.c +++ b/tests/glbook/Chapter_13/ParticleSystem/ParticleSystem_orig.c @@ -17,9 +17,16 @@ #include <math.h>
#include "esUtil.h"
-#define NUM_PARTICLES 1000
+#define NUM_PARTICLES 2000
#define PARTICLE_SIZE 7
+int randomTemp = 8765;
+float myrandom() {
+ int curr = randomTemp;
+ randomTemp = (1140671485 * randomTemp + 12820163) % 4294967296;
+ return ((float)curr) / 4294967296;
+}
+
typedef struct
{
// Handle to a program object
@@ -145,17 +152,17 @@ int Init ( ESContext *esContext ) float *particleData = &userData->particleData[i * PARTICLE_SIZE];
// Lifetime of particle
- (*particleData++) = ( (float)(rand() % 10000) / 10000.0f );
+ (*particleData++) = myrandom();
// End position of particle
- (*particleData++) = ( (float)(rand() % 10000) / 5000.0f ) - 1.0f;
- (*particleData++) = ( (float)(rand() % 10000) / 5000.0f ) - 1.0f;
- (*particleData++) = ( (float)(rand() % 10000) / 5000.0f ) - 1.0f;
+ (*particleData++) = myrandom() * 2 - 1.0f;
+ (*particleData++) = myrandom() * 2 - 1.0f;
+ (*particleData++) = myrandom() * 2 - 1.0f;
// Start position of particle
- (*particleData++) = ( (float)(rand() % 10000) / 40000.0f ) - 0.125f;
- (*particleData++) = ( (float)(rand() % 10000) / 40000.0f ) - 0.125f;
- (*particleData++) = ( (float)(rand() % 10000) / 40000.0f ) - 0.125f;
+ (*particleData++) = myrandom() * 0.25 - 0.125f;
+ (*particleData++) = myrandom() * 0.25 - 0.125f;
+ (*particleData++) = myrandom() * 0.25 - 0.125f;
}
@@ -188,17 +195,17 @@ void Update ( ESContext *esContext, float deltaTime ) userData->time = 0.0f;
// Pick a new start location and color
- centerPos[0] = ( (float)(rand() % 10000) / 10000.0f ) - 0.5f;
- centerPos[1] = ( (float)(rand() % 10000) / 10000.0f ) - 0.5f;
- centerPos[2] = ( (float)(rand() % 10000) / 10000.0f ) - 0.5f;
+ centerPos[0] = myrandom() - 0.5f;
+ centerPos[1] = myrandom() - 0.5f;
+ centerPos[2] = myrandom() - 0.5f;
glUniform3fv ( userData->centerPositionLoc, 1, ¢erPos[0] );
// Random color
- color[0] = ( (float)(rand() % 10000) / 20000.0f ) + 0.5f;
- color[1] = ( (float)(rand() % 10000) / 20000.0f ) + 0.5f;
- color[2] = ( (float)(rand() % 10000) / 20000.0f ) + 0.5f;
- color[3] = 0.5;
+ color[0] = myrandom() * 0.5 + 0.5f;
+ color[1] = myrandom() * 0.5 + 0.5f;
+ color[2] = myrandom() * 0.5 + 0.5f;
+ color[3] = 1.0;
glUniform4fv ( userData->colorLoc, 1, &color[0] );
}
@@ -252,6 +259,8 @@ void Draw ( ESContext *esContext ) // Set the sampler texture unit to 0
glUniform1i ( userData->samplerLoc, 0 );
+ Update ( esContext, 133 * 0.001125 );
+
glDrawArrays( GL_POINTS, 0, NUM_PARTICLES );
eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface );
@@ -280,15 +289,18 @@ int main ( int argc, char *argv[] ) esInitContext ( &esContext );
esContext.userData = &userData;
- esCreateWindow ( &esContext, "ParticleSystem", 640, 480, ES_WINDOW_RGB );
+ esCreateWindow ( &esContext, "ParticleSystem", 320, 240, ES_WINDOW_RGB );
if ( !Init ( &esContext ) )
return 0;
esRegisterDrawFunc ( &esContext, Draw );
- esRegisterUpdateFunc ( &esContext, Update );
+ //esRegisterUpdateFunc ( &esContext, Update );
- esMainLoop ( &esContext );
+ Draw (&esContext);
+ Draw (&esContext);
+
+ //esMainLoop ( &esContext );
ShutDown ( &esContext );
}
diff --git a/tests/glbook/Chapter_9/TextureWrap/TextureWrap_orig.c b/tests/glbook/Chapter_9/TextureWrap/TextureWrap_orig.c index fe22282f..e3531f04 100644 --- a/tests/glbook/Chapter_9/TextureWrap/TextureWrap_orig.c +++ b/tests/glbook/Chapter_9/TextureWrap/TextureWrap_orig.c @@ -243,7 +243,7 @@ int main ( int argc, char *argv[] ) esInitContext ( &esContext ); esContext.userData = &userData; - esCreateWindow ( &esContext, "MipMap 2D", 640, 480, ES_WINDOW_RGB ); + esCreateWindow ( &esContext, "MipMap 2D", 320, 240, ES_WINDOW_RGB ); if ( !Init ( &esContext ) ) return 0; diff --git a/tests/runner.py b/tests/runner.py index 5e704c2e..eb7d3c2d 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -10717,21 +10717,30 @@ elif 'browser' in str(sys.argv): if type(expected) is str: expected = [expected] self.run_browser('test.html', '.', ['/report_result?' + e for e in expected]) - def zzztest_gles2_emulation(self): + def test_gles2_emulation(self): + shutil.copyfile(path_from_root('tests', 'glbook', 'Chapter_10', 'MultiTexture', 'basemap.tga'), self.in_dir('basemap.tga')) + shutil.copyfile(path_from_root('tests', 'glbook', 'Chapter_10', 'MultiTexture', 'lightmap.tga'), self.in_dir('lightmap.tga')) + shutil.copyfile(path_from_root('tests', 'glbook', 'Chapter_13', 'ParticleSystem', 'smoke.tga'), self.in_dir('smoke.tga')) + for source, reference in [ (os.path.join('glbook', 'Chapter_2', 'Hello_Triangle', 'Hello_Triangle_orig.c'), path_from_root('tests', 'glbook', 'CH02_HelloTriangle.png')), - (os.path.join('glbook', 'Chapter_8', 'Simple_VertexShader', 'Simple_VertexShader_orig.c'), path_from_root('tests', 'glbook', 'CH08_SimpleVertexShader.png')), - (os.path.join('glbook', 'Chapter_9', 'TextureWrap', 'TextureWrap_orig.c'), path_from_root('tests', 'glbook', 'CH09_TextureWrap')), - (os.path.join('glbook', 'Chapter_9', 'Simple_TextureCubemap', 'Simple_TextureCubemap_orig.c'), path_from_root('tests', 'glbook', 'CH09_TextureCubemap.png')), + #(os.path.join('glbook', 'Chapter_8', 'Simple_VertexShader', 'Simple_VertexShader_orig.c'), path_from_root('tests', 'glbook', 'CH08_SimpleVertexShader.png')), # XXX needs INT extension in WebGL + (os.path.join('glbook', 'Chapter_9', 'TextureWrap', 'TextureWrap_orig.c'), path_from_root('tests', 'glbook', 'CH09_TextureWrap.png')), + #(os.path.join('glbook', 'Chapter_9', 'Simple_TextureCubemap', 'Simple_TextureCubemap_orig.c'), path_from_root('tests', 'glbook', 'CH09_TextureCubemap.png')), # XXX needs INT extension in WebGL (os.path.join('glbook', 'Chapter_9', 'Simple_Texture2D', 'Simple_Texture2D_orig.c'), path_from_root('tests', 'glbook', 'CH09_SimpleTexture2D.png')), - (os.path.join('glbook', 'Chapter_10', 'MultiTexture', 'MultiTexture_orig.c'), path_from_root('tests', 'glbook', 'CH10_Multitexture.png')), + (os.path.join('glbook', 'Chapter_10', 'MultiTexture', 'MultiTexture_orig.c'), path_from_root('tests', 'glbook', 'CH10_MultiTexture.png')), (os.path.join('glbook', 'Chapter_13', 'ParticleSystem', 'ParticleSystem_orig.c'), path_from_root('tests', 'glbook', 'CH13_ParticleSystem.png')), ]: print source self.btest(source, reference=reference, args=['-I' + path_from_root('tests', 'glbook', 'Common'), - path_from_root('tests', 'glbook', 'Common', 'esUtil.c')]) + path_from_root('tests', 'glbook', 'Common', 'esUtil.c'), + path_from_root('tests', 'glbook', 'Common', 'esShader.c'), + path_from_root('tests', 'glbook', 'Common', 'esShapes.c'), + path_from_root('tests', 'glbook', 'Common', 'esTransform.c'), + '-s', 'FULL_ES2=1', + '--preload-file', 'basemap.tga', '--preload-file', 'lightmap.tga', '--preload-file', 'smoke.tga']) def test_emscripten_api(self): self.btest('emscripten_api_browser.cpp', '1', args=['-s', '''EXPORTED_FUNCTIONS=['_main', '_third']''']) |