Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
titaniumnetwork-dev
GitHub Repository: titaniumnetwork-dev/Ludicrous
Path: blob/main/public/webretro/source/patches/emscripten.patch
1224 views
1
--- upstream/emscripten/src/library_webgl.js 2021-03-05 12:32:24.000000000 -0800
2
+++ upstream/emscripten/src/library_webgl.js 2022-05-02 10:19:02.461667100 -0700
3
@@ -3486,6 +3486,7 @@
4
glDrawElements: function(mode, count, type, indices) {
5
#if FULL_ES2
6
var buf;
7
+ var vertices = 0;
8
if (!GLctx.currentElementArrayBufferBinding) {
9
var size = GL.calcBufLength(1, type, 0, count);
10
buf = GL.getTempIndexBuffer(size);
11
@@ -3493,12 +3494,26 @@
12
GLctx.bufferSubData(0x8893 /*GL_ELEMENT_ARRAY_BUFFER*/,
13
0,
14
HEAPU8.subarray(indices, indices + size));
15
+
16
+ // Detecting vertex count if attributes' data should be loaded
17
+ var array_classes = {
18
+ '5121' /* GL_UNSIGNED_BYTE */: Uint8Array,
19
+ '5123' /* GL_UNSIGNED_SHORT */: Uint16Array,
20
+ '5125' /* GL_UNSIGNED_INT */: Uint32Array};
21
+ for (var i = 0; i < GL.currentContext.maxVertexAttribs; i++) {
22
+ var cb = GL.currentContext.clientBuffers[i];
23
+ if (cb.clientside && cb.enabled && array_classes[type]) {
24
+ vertices = Math.max.apply(null, new array_classes[type](HEAPU8.buffer, indices, count)) + 1;
25
+ break;
26
+ }
27
+ }
28
+
29
// the index is now 0
30
indices = 0;
31
}
32
33
// bind any client-side buffers
34
- GL.preDrawHandleClientVertexAttribBindings(count);
35
+ GL.preDrawHandleClientVertexAttribBindings(vertices);
36
#endif
37
38
GLctx.drawElements(mode, count, type, indices);
39
@@ -3716,7 +3731,7 @@
40
glMapBufferRange__deps: ['$emscriptenWebGLGetBufferBinding', '$emscriptenWebGLValidateMapBufferTarget'],
41
glMapBufferRange: function(target, offset, length, access) {
42
if (access != 0x1A && access != 0xA) {
43
- err("glMapBufferRange is only supported when access is MAP_WRITE|INVALIDATE_BUFFER");
44
+ warnOnce("glMapBufferRange is only supported when access is MAP_WRITE|INVALIDATE_BUFFER");
45
return 0;
46
}
47
48
49