testgles2: Use vertex buffer objects instead of client-side arrays. GLES2 always has them, and they work without hacks on Emscripten, unlike client-side arrays. I cleaned it up slightly, but this patch was mostly written by @bing2008. Fixes #5258.
diff --git a/test/testgles2.c b/test/testgles2.c
index b6180ae..153ebe4 100644
--- a/test/testgles2.c
+++ b/test/testgles2.c
@@ -372,6 +372,8 @@ typedef struct shader_data
int angle_x, angle_y, angle_z;
+ GLuint position_buffer;
+ GLuint color_buffer;
} shader_data;
static void
@@ -688,8 +690,18 @@ main(int argc, char *argv[])
GL_CHECK(ctx.glEnableVertexAttribArray(data->attr_color));
/* Populate attributes for position, color and texture coordinates etc. */
- GL_CHECK(ctx.glVertexAttribPointer(data->attr_position, 3, GL_FLOAT, GL_FALSE, 0, _vertices));
- GL_CHECK(ctx.glVertexAttribPointer(data->attr_color, 3, GL_FLOAT, GL_FALSE, 0, _colors));
+
+ GL_CHECK(ctx.glGenBuffers(1, &data->position_buffer));
+ GL_CHECK(ctx.glBindBuffer(GL_ARRAY_BUFFER, data->position_buffer));
+ GL_CHECK(ctx.glBufferData(GL_ARRAY_BUFFER, sizeof(_vertices) * 4, _vertices, GL_STATIC_DRAW));
+ GL_CHECK(ctx.glVertexAttribPointer(data->attr_position, 3, GL_FLOAT, GL_FALSE, 0, 0));
+ GL_CHECK(ctx.glBindBuffer(GL_ARRAY_BUFFER, 0));
+
+ GL_CHECK(ctx.glGenBuffers(1, &data->color_buffer));
+ GL_CHECK(ctx.glBindBuffer(GL_ARRAY_BUFFER, data->color_buffer));
+ GL_CHECK(ctx.glBufferData(GL_ARRAY_BUFFER, sizeof(_colors) * 4, _colors, GL_STATIC_DRAW));
+ GL_CHECK(ctx.glVertexAttribPointer(data->attr_color, 3, GL_FLOAT, GL_FALSE, 0, 0));
+ GL_CHECK(ctx.glBindBuffer(GL_ARRAY_BUFFER, 0));
GL_CHECK(ctx.glEnable(GL_CULL_FACE));
GL_CHECK(ctx.glEnable(GL_DEPTH_TEST));