Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: OpenGL + OpenVG

  1. #1
    Junior Member
    Join Date
    Oct 2009
    Posts
    5

    OpenGL + OpenVG

    Hi all

    Is there a way to render both OpenGL (3D) and OpenVG (vector 2D) content onto the same context?

    Since both utilize EGL to render, will the two fight over the who gets the context? Or can they coexist without problems?

    Here's one suggestion I have heard:
    1. create EGL context
    2. render OpenVG to a back-buffer
    3. render OpenGL to EGL context created in step 1.
    4. render OpenVG back-buffer on top of EGL context (containing OpenGL renderings)

    Will this work? Will the final context contain BOTH the OpenGL & OpenVG content?

    Furthermore... can someone point me to how to get my desktop environment set up with both OpenVG and OpenGL?

    Your help is much appreciated! Thanks in advance!

  2. #2
    Senior Member
    Join Date
    Feb 2006
    Posts
    115

    Re: OpenGL + OpenVG

    A context, by it's very nature, is either Open VG, Open GL ES [or most recently Open GL], but not a combination of them.
    A context is, if you will pardon OOP lingo, an instance of a single rendering API.

    That said, it's perfectly valid to create multiple contexts - one for each API you wish to render with, and simply use eglMakeCurrent() to switch between them (re-using the same drawing surface). This will get you the effect you seem to be looking for.

    The only public implementation I am aware of that implements both OpenVG and OpenGL ES is hybrid's old Rasteroid implementation (if you fail to find that [the hybrid.fi has been down for a long time now], see if the Mesa implementation supports both at the same time - don't know if it does).

  3. #3
    Junior Member
    Join Date
    Oct 2009
    Posts
    5

    Re: OpenGL + OpenVG

    Thanks Ivo for your reply!

    My application would require OpenVG content to be displayed on top of the OpenGL content. Would this be possible via switching contexts using eglMakeCurrent()?

    Thanks in advance for your help

  4. #4
    Senior Member
    Join Date
    Feb 2006
    Posts
    115

    Re: OpenGL + OpenVG

    Yes - if the EGL layer supports both VG and GL ES, then it will.
    The problem is only a few drivers support both.

  5. #5
    Junior Member
    Join Date
    Oct 2009
    Posts
    5

    Re: OpenGL + OpenVG

    Hi Ivo, sorry to be a bother, but here's another question.

    After reading through the OpenVG specs I found nothing on whether or not you could render OpenVG content to texture.

    - Is this possible by specifications?
    - If so, will the OpenVG texture be compatible/interchangeable with the OpenGL texture?

  6. #6
    Senior Member
    Join Date
    Feb 2006
    Posts
    115

    Re: OpenGL + OpenVG

    If you have EGL and want to render to a VG texture - sure.
    Use eglCreatePbufferFromClientBuffer() to create your surface.
    If intending to draw to a GL texture, you could try eglBindTexImage() and see if it works [I have not used it]
    Word of warning: these functions are often not implemented in many EGL implementations.

    If they are not implemented, try looking for one OpenVG/OpenGL ES extensions that do something similar. I could have sworn I've seen something on the topic while browsing the extension registry.

    If all else fails, you're stuck with vgReadPixels() from a regular pbuffer [but you'll have to suffer performance penalty of reading and writing textures from main memory to GPU memory of course].

  7. #7

    Re: OpenGL + OpenVG

    The set of EGLImage extensions provide this kind of capabilities I believe.

    You can create an EGLImage from a VGImage with this extension:

    http://www.khronos.org/registry/egl/ext ... _image.txt

    You can then create a texture from your EGLImage with:

    http://www.khronos.org/registry/gles/ex ... _image.txt


    I think the extension is become popular enough that it's possible your platform/GLES implementation may support this set of extensions.

  8. #8
    Junior Member
    Join Date
    Oct 2009
    Posts
    5

    Re: OpenGL + OpenVG

    Thanks jpilon, I went over the documentation on those extensions, and they seem like they're just what I was looking for. Unfortunately, I'm pretty sure our device doesn't have support for these extensions. Do you think there exist ways to convert the OpenVG context/surface into a Texture2D using just standard EGL methods?

    At this time I'd also like to discuss another possibility: overlaying the OpenVG & OpenGL surfaces onto the same display. Here's the pseudo-code:

    (in creation)
    create ovg surface
    create ovg context
    create ogl surface
    create ogl context

    (in main-loop)
    1. set ovg as the current context
    2. bindAPI ovg
    3. clear screen using ovg (vgClear)
    4. render ovg stuff
    5. swap buffer (display, ovg)
    6. set ogl as the current context
    7. bindAPI ogl
    8. (DO NOT clear screen, screen is left dirty intentionally)
    9. render ogl stuff
    10. swap buffer (display, ogl)

    Would this work to render OpenVG & OpenGL onto the same display? The only red-flag I see here is if swapbuffer actually replaces the entire display with the surface. If that's the case, we'd probably only see the OpenGL content... which is not the desired result.

    What are your thoughts?

  9. #9
    Senior Member
    Join Date
    Feb 2006
    Posts
    115

    Re: OpenGL + OpenVG

    If all you care about is compositing the image like that, and not storing it in a texture, then the normal way to do that is:
    - create only one surface
    - use it for both ovg and ogl rendering
    - use vgFinish() instead of eglSwapBuffers when you finish the ovg rendering
    - makecurrent the ogl context with the same surface (you may need to makecurrent() with NULL parameters first, depending on implementation)
    - use the eglSwapBuffers() after finishing the ogl rendering.

    Normally though, I imagine you'd probably want to render ogl first, and ovg second.

  10. #10
    Junior Member
    Join Date
    Oct 2009
    Posts
    5

    Re: OpenGL + OpenVG

    I was under the impression the surfaces couldn't be 'shared' by both ogl & ovg? Are they actually share-able assuming they have the same config attributes? This would be great!

    Ivo, could you explain further what you meant by this:

    - makecurrent the ogl context with the same surface (you may need to makecurrent() with NULL parameters first, depending on implementation)
    What's the reason for using eglMakeCurrent() with the NULL parameters first?

    Thanks.

Page 1 of 2 12 LastLast

Similar Threads

  1. Using OpenGL, ON, OpenVG
    By Zamaster in forum OpenGL ES general technical discussions
    Replies: 1
    Last Post: 01-06-2012, 08:09 PM
  2. Using OpenGL ES with OpenVG
    By jrabbani in forum OpenGL ES general technical discussions
    Replies: 0
    Last Post: 11-29-2010, 12:29 AM
  3. OpenGL ES 2.0 + OpenVG 1.1
    By jrabbani in forum OpenVG and VGU
    Replies: 0
    Last Post: 11-24-2010, 10:44 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
  •