PDA

View Full Version : How interchangeable is OpenGL and OpenVG



chrispepper1989
11-04-2011, 04:55 AM
Hi Everyone,
I am relatively new to OpenVG and I am just experimenting with some code. The following code is what prompted me to ask this question:

glPixelStorei(GL_PACK_ALIGNMENT,1);
vgReadPixels(buf1, WINDSIZEX*4, VG_sRGBA_8888, 0, 0, WINDSIZEX, WINDSIZEY);

Is this valid? I would assume not because i'm guessing vg has its own statemachine? Is there a vg equivalent for most / all OpenGL functions? e.g.

vgPixelStorei(GL_PACK_ALIGNMENT, 1);

Are there any good resources you could point me to?

I appreciate any information you can give me!

chrispepper1989
11-04-2011, 07:01 AM
Ok so for the example posted:

glPixelStorei(GL_PACK_ALIGNMENT,1);
vgReadPixels(buf1, WINDSIZEX*4, VG_sRGBA_8888, 0, 0, WINDSIZEX, WINDSIZEY);

I now see that readpixels takes the equivalent data so i assume:

vgReadPixels(buf1, WINDSIZEX , VG_sRGBA_8888, 0, 0, WINDSIZEX, WINDSIZEY);

would give me the same alignment?

Ivo Moravec
11-04-2011, 03:08 PM
It wont work because, as you say, it is a separate state machine. Both Open GL and Open VG need to have their own contexts, and 2 contexts cannot be active at the same time. In GL contexts you can only use GL commands, and VG contexts only VG commands. There are various mechanisms for sharing things between Open GL and Open VG and most of them are located in the surface management standard EGL (calls like eglCreateSurfaceFromClientBuffer() - I think that's what it's called if I recall correctly [there are others too]).

Otherwise, yes, vgReadPixels() and glReadPixels() work pretty much in the exact same way. Transferring data from one APi to the other via ReadPixels should be used only as your last resort though (if the other functions are nor present or work correctly), as it typically transfers data from video memory to CPU memory and back again.

chrispepper1989
11-06-2011, 03:57 PM
Thank you for confirming that, its very helpful to have it clarified and also thank you for the information on how they do work together. I Appreciate it.

-Thanks,
Chris