Results 1 to 1 of 1

Thread: eglMakeCurrent for context only used for FBOs

  1. #1
    Newbie Newbie
    Join Date
    Jun 2013

    eglMakeCurrent for context only used for FBOs

    I'm having the following situation:

    In a cross platform rendering library for iOS and Android (written in c(++)), i have two threads that each need their own EGLContext:
    Thread A is the main thread; it renders to the Window.
    Thread B is a generator thread, that does various calculations and renders the results into textures that are later used by thread A.

    Since i can't use EGL on iOS, the library uses function pointers to static Obj.-C functions to create a new context and set it current.
    This already works, i create the context for thread A using
    Code :
    EAGLContext *contextA = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
    The context for thread B is created using
    Code :
    EAGLContext *contextB = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2 sharegroup:[contextA sharegroup]];
    I can then set either of the two current:
    Code :
    [EAGLContext setCurrentContext:context];

    To use the same logic (function pointers passed to the library) on Android, i want to do this in the C side of the JNI bindings, this time using real EGL instead of Apple's EAGL.
    I can easily create contextA using a WindowSurface and the native Window, i can create contextB and pass contextA to the shareContext parameter of the eglCreateContext call.

    But when i want to make contextB current, i have to pass a surface to the eglMakeCurrent call, and i'm trying to figure out what kind of surface to pass there.
    • I cannot use the WindowSurface i use for contextA as the spec [1] says in section 3.7 that "At most one context for each supported client API may be current to a particular thread at a given time, and at most one context may be bound to a particular surface at a given time."
    • I cannot specify EGL_NO_SURFACE, because that would result in an EGL_BAD_MATCH error in the eglMakeCurrent call.
    • It seems I could use a PBuffer surface, but I hesitate because I'd have to specify the width and height when I create such a surface, and thread B might want to create textures of different sizes. In addition to that, the "OpenGL ES 2.0 Programming Guide" [2] states in section 3.8 that "Pbuffers are most often used for generating texture maps. If all you want to do is render to a texture, we recommend using framebuffer objects [...] instead of pbuffers because they are more efficient", which is exactly what i want to do in thread B.

    I don't understand what Munshi, Ginsurg and Shreiner mean by that sentence, how would a framebuffer object be a replacement for a pbuffer surface? What if I create a very small (say 1x1px) pbuffer surface to make the context current - can i then still render into arbitrarily large FBOs? Are there any other possibilities I'm not yet aware of?

    Thanks a lot for your help!

    [1] eglspec.1.4.20130211.pdf - Unfortunately I cannot post a link to the Khronos website.
    [2] Aaftab Munshi, Dan Ginsburg, and Dave Shreiner. OpenGL ES 2.0 Programming Guide. Addison Wesley, 2009.
    Last edited by pontomedon; 06-08-2013 at 03:45 AM. Reason: Proper reference to the OpenGL ES 2.0 Programming Guide

Similar Threads

  1. Replies: 1
    Last Post: 06-22-2013, 09:31 PM
  2. eglMakeCurrent() failing with EGL_BAD_MATCH
    By glNick in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 12-26-2012, 04:47 PM
  3. Replies: 4
    Last Post: 04-15-2009, 08:02 AM
  4. EGL_BAD_ALLOC with eGLMakeCurrent on antoher window.
    By RungeKutta in forum OpenGL ES
    Replies: 1
    Last Post: 12-08-2008, 03:47 AM
  5. Replies: 1
    Last Post: 06-26-2003, 12:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean