aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library_gl.js36
-rw-r--r--tests/cubegeom_pre.c2
-rwxr-xr-xtests/runner.py5
-rw-r--r--tools/clean_webconsole.py4
4 files changed, 31 insertions, 16 deletions
diff --git a/src/library_gl.js b/src/library_gl.js
index 4de6a0d6..998982af 100644
--- a/src/library_gl.js
+++ b/src/library_gl.js
@@ -1286,6 +1286,7 @@ var LibraryGL = {
}
} else {
console.log('Warning: Ignoring renderer attribute ' + which);
+ size = parseInt(renderer[i+1]);
}
vertexSize += size * 4; // XXX assuming float
}
@@ -1346,17 +1347,17 @@ var LibraryGL = {
},
prepare: function() {
- if (this.hasTexture) {
- Module.ctx.vertexAttribPointer(this.texCoordLocation, textureSize, Module.ctx.FLOAT, false,
- vertexSize, textureOffset);
- }
+ if (this.modelViewLocation) Module.ctx.uniformMatrix4fv(this.modelViewLocation, false, GL.immediate.matrix['m']);
+ if (this.projectionLocation) Module.ctx.uniformMatrix4fv(this.projectionLocation, false, GL.immediate.matrix['p']);
+
Module.ctx.vertexAttribPointer(this.positionLocation, positionSize, Module.ctx.FLOAT, false,
vertexSize, positionOffset);
-
+ Module.ctx.enableVertexAttribArray(this.positionLocation);
if (this.hasTexture) {
+ Module.ctx.vertexAttribPointer(this.texCoordLocation, textureSize, Module.ctx.FLOAT, false,
+ vertexSize, textureOffset);
Module.ctx.enableVertexAttribArray(this.texCoordLocation);
}
- Module.ctx.enableVertexAttribArray(this.positionLocation);
if (!useCurrProgram) { // otherwise, the user program will set the sampler2D binding and uniform itself
var texture = Module.ctx.getParameter(Module.ctx.TEXTURE_BINDING_2D);
@@ -1364,9 +1365,6 @@ var LibraryGL = {
Module.ctx.bindTexture(Module.ctx.TEXTURE_2D, texture);
Module.ctx.uniform1i(this.textureLocation, 0);
}
-
- if (this.modelViewLocation) Module.ctx.uniformMatrix4fv(this.modelViewLocation, false, GL.immediate.matrix['m']);
- if (this.projectionLocation) Module.ctx.uniformMatrix4fv(this.projectionLocation, false, GL.immediate.matrix['p']);
}
};
ret.init();
@@ -1415,7 +1413,7 @@ var LibraryGL = {
prepareClientAttributes: function(count) {
// Client attributes are to be used here, emulate that
- var stride = 0, bytes = 0, attributes = [], start, renderer = '';
+ var stride = 0, attributes = [], start;
for (var i = 0; i < GL.immediate.NUM_ATTRIBUTES; i++) {
if (GL.immediate.enabledClientAttributes[i]) attributes.push(GL.immediate.clientAttributes[i]);
}
@@ -1429,18 +1427,32 @@ var LibraryGL = {
assert(stride == 0 || stride == attribute.stride); // must all be in the same buffer
#endif
stride = attribute.stride;
- bytes += attribute.size * 4 * count; // XXX assuming float
- renderer += attribute.name;
}
+
+ var renderer = '', bytes = 0;
for (var i = 0; i < attributes.length; i++) {
var attribute = attributes[i];
if (!attribute) break;
attribute.offset = attribute.pointer - start;
+ if (attribute.offset > bytes) { // ensure we start where we should
+ assert((attribute.offset - bytes)%4 == 0); // assuming float
+ renderer += '?' + ((attribute.offset - bytes)/4);
+ bytes += attribute.offset - bytes; // XXX assuming float
+ }
+ renderer += attribute.name;
+ bytes += attribute.size * 4; // XXX assuming float
#if ASSERTIONS
assert(0 <= attribute.offset && attribute.offset < stride); // must all be in the same buffer
#endif
}
+ if (bytes < stride) { // ensure the size is that of the stride
+ assert((stride - bytes)%4 == 0); // assuming float
+ renderer += '?' + ((stride-bytes)/4);
+ bytes = stride;
+ }
+
+ bytes *= count;
GL.immediate.vertexData = {{{ makeHEAPView('F32', 'start', 'start + bytes') }}}; // XXX assuming float
GL.immediate.vertexCounter = bytes / 4; // XXX assuming float
diff --git a/tests/cubegeom_pre.c b/tests/cubegeom_pre.c
index bafead25..8001a2b8 100644
--- a/tests/cubegeom_pre.c
+++ b/tests/cubegeom_pre.c
@@ -282,7 +282,7 @@ int main(int argc, char *argv[])
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 32, (void*)0);
glEnableVertexAttribArray(0);
- glBindAttribLocation(program, 1, "v_texCoord0");
+ glBindAttribLocation(program, 1, "a_texCoord0");
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 32, (void*)16);
glEnableVertexAttribArray(1);
diff --git a/tests/runner.py b/tests/runner.py
index c43b283e..8598284d 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -7230,7 +7230,10 @@ elif 'browser' in str(sys.argv):
self.btest('gl_ps.c', reference='gl_ps.png', args=['--preload-file', 'screenshot.png'])
def test_cubegeom_pre(self):
- self.btest('cubegeom_pre.c', expected='-1472804742')
+ self.btest('cubegeom_pre.c', expected='-1472804742', args=['-s', 'GL_DEBUG=1'])
+
+ def zzztest_cubegeom_pre2(self):
+ self.btest('cubegeom_pre2.c', expected='-1472804742', args=['-s', 'GL_DEBUG=1'])
def zzztest_cubegeom(self):
self.btest('cubegeom.c', reference='sdlglshader.png', args=['-s', 'GL_DEBUG=1'])
diff --git a/tools/clean_webconsole.py b/tools/clean_webconsole.py
index 919bd547..43694179 100644
--- a/tools/clean_webconsole.py
+++ b/tools/clean_webconsole.py
@@ -29,6 +29,6 @@ for line in lines:
line = re.sub('(0x[\dabcdef]+)', lambda hexx: reps[nice(hexx.group(0))] if nice(hexx.group(0)) in reps else nice(hexx.group(0)), line)
print line
-for i in range(100):
- print
+#for i in range(100):
+# print