Re: [AD] [AL] OpenGL path for WebGL |
[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]
I finally got around to trying to create OpenGL path for WebGL
(Emscripten), and I have a few questions.
1) Why does Allegro uses Vertex Buffer Arrays? There is only one
Vertex Buffer Object, and every frame we bind it and enable its
attributes. I'm do not know much about OpenGL, but it seems to me that
we should either do all these things, OR use VBA, which saves state.
To test this, I disabled creation & usage of VBA, and everything
worked without any glitches.
2) I disabled emulation of WebGL's absent OpenGL ES 2 features in
Emscripten, and now, while the test is running, there are some
rendering errors. It seems they are related to Primitives addon.
Particularly this code inside setup_state function in prim_opengl.c
spews errors into console ("vertexAttribPointer: must have valid
GL_ARRAY_BUFFER binding"):
if (display->ogl_extras->varlocs.pos_loc >= 0) {
glVertexAttribPointer(display->ogl_extras->varlocs.pos_loc,
3, GL_FLOAT, false, sizeof(ALLEGRO_VERTEX), vtxs +
offsetof(ALLEGRO_VERTEX, x));
glEnableVertexAttribArray(display->ogl_extras->varlocs.pos_loc);
}
if (display->ogl_extras->varlocs.texcoord_loc >= 0) {
glVertexAttribPointer(display->ogl_extras->varlocs.texcoord_loc,
2, GL_FLOAT, false, sizeof(ALLEGRO_VERTEX), vtxs +
offsetof(ALLEGRO_VERTEX, u));
glEnableVertexAttribArray(display->ogl_extras->varlocs.texcoord_loc);
}
if (display->ogl_extras->varlocs.color_loc >= 0) {
glVertexAttribPointer(display->ogl_extras->varlocs.color_loc,
4, GL_FLOAT, true, sizeof(ALLEGRO_VERTEX), vtxs +
offsetof(ALLEGRO_VERTEX, color));
glEnableVertexAttribArray(display->ogl_extras->varlocs.color_loc);
}
. As I understand, the problem here is that OpenGL ES supports calling
glVertexAttribPointer without bound VBO, but WebGL doesn't. So could
someone help me with figuring out how to fix this? Do I need to bind
ogl_extras->vbo here?
if (vertex_buffer) { glBindBuffer(GL_ARRAY_BUFFER, (GLuint)vertex_buffer->common.handle); }So the vertex array buffer should be bound at the time glVertexAttribPointer is called.
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |