aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-05-13 15:13:18 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-05-13 15:13:18 -0700
commit6b9545c1d244b5509ee592cbc38988fdd8350b4f (patch)
tree5d2586ff6e266f7006339541084da3c405eb45d8
parentb90a590f024d12650112ee15fbbf24cdea082ed1 (diff)
fix order in gl_ModelViewProjectionMatrix and add working cube_explosion test
-rw-r--r--src/library_gl.js2
-rw-r--r--tests/cube_explosion.c18
-rwxr-xr-xtests/runner.py4
3 files changed, 11 insertions, 13 deletions
diff --git a/src/library_gl.js b/src/library_gl.js
index 209f2133..5b5f8e76 100644
--- a/src/library_gl.js
+++ b/src/library_gl.js
@@ -973,7 +973,7 @@ var LibraryGL = {
source = source.replace(/gl_Vertex/g, 'a_position');
if (old != source) need_pv = 1;
old = source;
- source = source.replace(/gl_ModelViewProjectionMatrix/g, '(u_modelView * u_projection)');
+ source = source.replace(/gl_ModelViewProjectionMatrix/g, '(u_projection * u_modelView)');
if (old != source) need_pm = need_mm = 1;
old = source;
source = source.replace(/gl_ModelViewMatrixTranspose\[2\]/g, 'vec3(u_modelView[0][0], u_modelView[1][0], u_modelView[2][0])'); // XXX extremely inefficient
diff --git a/tests/cube_explosion.c b/tests/cube_explosion.c
index 38088018..9a970c27 100644
--- a/tests/cube_explosion.c
+++ b/tests/cube_explosion.c
@@ -71,7 +71,7 @@ int main(int argc, char *argv[])
GLubyte textureData[16*16*4];
for (int x = 0; x < 16; x++) {
for (int y = 0; y < 16; y++) {
- *((int*)&textureData[(x*16 + y) * 4]) = x*16 + ((y*16) << 8) + ((x*16) << 16) + 0xff000000;
+ *((int*)&textureData[(x*16 + y) * 4]) = x*16 + ((y*16) << 8) + ((y*16) << 16) + 0xff331177;
}
}
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0,
@@ -182,9 +182,7 @@ int main(int argc, char *argv[])
glVertexPointer(3, GL_FLOAT, 20, 0);
glTexCoordPointer(2, GL_FLOAT, 20, (void*)12);
- glBindTexture(GL_TEXTURE_2D, texture);
-
- glPushMatrix(); // still modelview?
+ glPushMatrix();
glTranslated(484.50579833984375, 589.3919067382812, 528.0055541992188);
GLint texgenSLocation = glGetUniformLocation(program, "texgenS");
@@ -198,9 +196,10 @@ int main(int argc, char *argv[])
glUniform4fv(texgenTLocation, 1, texgenTData);
GLint centerLocation = glGetUniformLocation(program, "center");
- assert(centerLocation >= 0);
- GLfloat centerData[4] = { 484.50579833984375, 589.3919067382812, 528.0055541992188, 0 };
- glUniform4fv(centerLocation, 1, centerData);
+ if (centerLocation >= 0) {
+ GLfloat centerData[4] = { 484.50579833984375, 589.3919067382812, 528.0055541992188, 0 };
+ glUniform4fv(centerLocation, 1, centerData);
+ }
GLint animstateLocation = glGetUniformLocation(program, "animstate");
assert(animstateLocation >= 0);
@@ -209,11 +208,10 @@ int main(int argc, char *argv[])
glRotated(1529.857142857143, 0.5773502588272095, 0.5773502588272095, 0.5773502588272095);
glScaled(-55, 55, -55);
- glActiveTexture(GL_TEXTURE1);
+ glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture); // XXX this is after setting Pointers, do we miss it? Also, does it not need clientActiveTexture - should we have updated that?
glActiveTexture(GL_TEXTURE0);
- glColor4ub(-1,15 ,15, 255);
- glColor4f(1, 0.058823529411764705, 0.058823529411764705, 1); // seems unneeded to have two calls to color...
+ glColor4f(1, 0.158823529411764705, 0.058823529411764705, 1);
glDrawElements(GL_TRIANGLES, 432, GL_UNSIGNED_SHORT, 0);
diff --git a/tests/runner.py b/tests/runner.py
index 57d6379b..d25bd2d3 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -7315,8 +7315,8 @@ elif 'browser' in str(sys.argv):
def test_cubegeom_texturematrix(self):
self.btest('cubegeom_texturematrix.c', expected='1297500583')
- def zzztest_cube_explosion(self):
- self.btest('cube_explosion.c', expected='-1472804742')
+ def test_cube_explosion(self):
+ self.btest('cube_explosion.c', expected='667220544')
def test_pre_run_deps(self):
# Adding a dependency in preRun will delay run