Re: [AD] [AL] OpenGL path for WebGL

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Tue, May 6, 2014 at 10:22 PM, Max Savenkov <max.savenkov@xxxxxxxxxx> wrote:
I finally got around to trying to create OpenGL path for WebGL
(Emscripten), and I have a few questions.


Please ask on the [AD] list (http://www.liballeg.org/maillist.html), not here. Developers are not usually subscribed to this list here (it was basically superceded by allegro.cc a decade or so ago :P). I'll be forwarding this to the correct list, and hopefully someone who knows more about OpenGL than me can answer in more detail.
 
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.

How did you test?


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?


Is this with or without removing the vertex buffer array code above? I can see this before calling setup_state:

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.

I can't really test myself right now though since I don't know how I can get an OpenGL ES 2 context (without an ios or android device).


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/