Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Porting OpenGL to GLESv2

  1. #1
    Newbie Newbie
    Join Date
    Dec 2017
    Posts
    1

    Porting OpenGL to GLESv2

    I'm trying to port an OpenGL program to GLESv2. The program uses the following code a texture to the default framebuffer (it also fails if I render it to an fbo which also works on OpenGL).

    Code :
            glBindFramebuffer(GL_FRAMEBUFFER, 0); 
            glVertexAttribPointer(bgra_texcoords, 2, GL_FLOAT, GL_FALSE, 0, display_texcoords);
            glEnableVertexAttribArray(bgra_texcoords);
            DEBUG_ERROR_CHECK();
     
            glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
            glUseProgram(bgra_program);
            glBindTexture(GL_TEXTURE_2D, inst->texture);
            glUniform1i(bgra_texture, 0); 
            glViewport(inst->x, root_surface->h - (inst->y + inst->h), inst->w, inst->h);
            DEBUG_ERROR_CHECK();
     
            glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); 
            DEBUG_ERROR_CHECK();
            glBindBuffer(GL_ARRAY_BUFFER, 0); 
            glFlush();

    This works fine with OpenGL but it fails on glDrawArrays() under GLESv2 with GL_INVALID_VALUE. I read this question: https://stackoverflow.com/questions/...id-value-error which is very similar to my problem but I can't figure out how to apply the solution to my code since I'm not using VertexArray and I'm very new to GL.

    inst->texture is a texture uploaded with glTexImage2D(). I created the vertex_buffer right after initializing EGL and compiling the shaders:

    Code :
            glGenBuffers(1, &vertex_buffer);
            glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
            glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), 
                    vertices, GL_STATIC_DRAW);
            glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
            glVertexAttribPointer(bgra_pos, 2, GL_FLOAT, GL_FALSE, 0, 0); 
            glEnableVertexAttribArray(bgra_pos);
            DEBUG_ERROR_CHECK();

    Edit: You can look at the whole source file here: https://github.com/fernando-rodrigue...video-opengl.c. The file is a video "driver" for a compositor, all it does is creates 2D surfaces and render them to the screen. If there is anything wrong with the question or am missing something please post a comment so I can fix it. Thanks.
    Last edited by frodzdev; 12-20-2017 at 12:11 PM.

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,425
    I didn't look pick through all your code. But here are a few thoughts.

    • I suspect your avbox_glTexImage2D() wrapper should actually call glTexImage2D on the GLES side.
    • Are you actually calling glCheckFramebufferStatus()? Your #if check before it looks backwards (says "#ifdef NDEBUG"; this is more commonly written #ifndef NDEBUG so that it only compiles in in debug builds).
    • If you haven't already, read up on the color renderable internal formats in the GLES 2.0 spec (and here). I think you'll be surprised at how constrained it is by default without extensions. Also check the internal format you're assigning to inst->texture. It's not one of those, right? Then check your extensions to see what the full set your implementation can support is.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •