Cookies info

This website uses Google cookies to analyse traffic. Information about your use of our site is shared with Google for that purpose. See details.

EGL like interface

AmanithVG doesn’t depend on, nor include an EGL implementation. In order to supply some minimal EGL functionalities, some additional proprietary calls have been added to the API to accomplish the following tasks:


vgInitializeMZT

VGboolean vgInitializeMZT(void);

Initialize the library. After initialization, it is possible to create contexts and drawing surfaces. NB: in a multi-thread program it is recommended to initialize the library once before the creation of threads. VG_TRUE is returned on success, else VG_FALSE. Please note that initializing an already-initialized library is allowed, but the only effect of such a call is to return VG_TRUE.


vgTerminateMZT

void vgTerminateMZT(void);

Terminate the library. All “pending” resources (e.g. contexts and drawing surfaces) not yet destroyed are released and deallocated. NB: in a multi-thread program it is recommended to terminate the library once after the termination of all threads. Please note that terminating an already-terminated library is allowed: in this case nothing is done.


vgPrivContextCreateMZT

void* vgPrivContextCreateMZT(void* sharedContext);

Create and initialize an OpenVG context, specifying an optional shared context. All shareable data (OpenVG handles) will be shared by the given shared context, all other contexts shared context already shares with, and the newly created context.


vgPrivContextDestroyMZT

void vgPrivContextDestroyMZT(void* context);

Destroy a previously created OpenVG context.


vgPrivSurfaceCreateMZT

void* vgPrivSurfaceCreateMZT(VGint width,
                             VGint height,
                             VGboolean linearColorSpace,
                             VGboolean alphaPremultiplied,
                             VGboolean alphaMask);

Create and initialize a drawing surface. In the detail this function allocates:

AmanithVG GLE supports only premultiplied surface formats, so it ignores the value of alphaPremultiplied parameter. Specified surface width and height are silently clamped to the value returned by the vgConfigGetMZT(VG_CONFIG_MAX_SURFACE_DIMENSION_MZT) calling; the user should call vgPrivGetSurfaceWidthMZT, vgPrivGetSurfaceHeightMZT after vgPrivSurfaceCreateMZT in order to check real drawing surface dimensions.

For best performance use non-linear premultiplied color space.


vgPrivSurfaceCreateByPointerMZT

void* vgPrivSurfaceCreateByPointerMZT(VGint width,
                                      VGint height,
                                      VGboolean linearColorSpace,
                                      VGboolean alphaPremultiplied,
                                      void* pixels,
                                      VGubyte* alphaMaskPixels);

Create and initialize a drawing surface, specifying direct memory buffers for pixels and (optionally) alpha mask. In the detail:

Specified surface width and height are silently clamped to the value returned by the vgConfigGetMZT(VG_CONFIG_MAX_SURFACE_DIMENSION_MZT) calling; the user should call vgPrivGetSurfaceWidthMZT, vgPrivGetSurfaceHeightMZT after vgPrivSurfaceCreateByPointerMZT in order to check real drawing surface dimensions.

For best performance use non-linear premultiplied color space.

This function is available on AmanithVG SRE only.


vgPrivSurfaceCreateFromImageMZT

void* vgPrivSurfaceCreateFromImageMZT(VGImage image,
                                      VGboolean alphaMask);

Create a drawing surface, bound to the given VGImage. This function is implemented by AmanithVG SRE only (AmanithVG GLE always returns a NULL value).


vgPrivSurfaceResizeMZT

VGboolean vgPrivSurfaceResizeMZT(void* surface,
                                 VGint width,
                                 VGint height);

Resize the dimensions of the specified drawing surface. This function:

Specified surface width and height are silently clamped to the value returned by the vgConfigGetMZT(VG_CONFIG_MAX_SURFACE_DIMENSION_MZT) calling; the user should call vgPrivGetSurfaceWidthMZT, vgPrivGetSurfaceHeightMZT after vgPrivSurfaceResizeMZT in order to check real drawing surface dimensions. The specified surface must be valid (i.e. not destroyed); to be only referenced (e.g. made current but destroyed) it’s not enough.


vgPrivSurfaceResizeByPointerMZT

VGboolean vgPrivSurfaceResizeByPointerMZT(void* surface,
                                          VGint width,
                                          VGint height,
                                          void* pixels,
                                          VGubyte* alphaMaskPixels);

Resize the given drawing surface, specifying new memory buffers for pixels and (optionally) alpha mask. In the detail:

Specified surface width and height are silently clamped to the value returned by the vgConfigGetMZT(VG_CONFIG_MAX_SURFACE_DIMENSION_MZT) calling; the user should call vgPrivGetSurfaceWidthMZT, vgPrivGetSurfaceHeightMZT after vgPrivSurfaceResizeByPointerMZT in order to check real drawing surface dimensions. The specified surface must be valid (i.e. not destroyed); to be only referenced (e.g. made current but destroyed) it’s not enough.

This function is available on AmanithVG SRE only.


vgPrivSurfaceDestroyMZT

void vgPrivSurfaceDestroyMZT(void* surface);

Destroy a previously created drawing surface.


vgPrivGetSurfaceWidthMZT

VGint vgPrivGetSurfaceWidthMZT(const void* surface);

Get the width (in pixels) of the given drawing surface.


vgPrivGetSurfaceHeightMZT

VGint vgPrivGetSurfaceHeightMZT(const void* surface);

Get the height (in pixels) of the given drawing surface.


vgPrivGetSurfaceFormatMZT

VGImageFormat vgPrivGetSurfaceFormatMZT(const void* surface);

Get the format of the given drawing surface.


vgPrivGetSurfacePixelsMZT

const VGubyte* vgPrivGetSurfacePixelsMZT(const void* surface);

Get the direct access to the pixels of the given drawing surface. It should be used only to blit the surface on the screen, according to the platform graphic subsystem. This function is implemented by AmanithVG SRE only (GLE always returns a NULL value).


vgPrivMakeCurrentMZT

VGboolean vgPrivMakeCurrentMZT(void *context, void *surface);

Bind the specified context to the given drawing surface. When using AmanithVG GLE, an OpenGL / OpenGL ES rendering context must be opened and an OpenGL / OpenGL ES rendering surface (multisampled or not multisampled) must be created using the native platform graphics interface before to call vgPrivMakeCurrentMZT. AmanithVG GLE returns VG_FALSE if GL preconditions (e.g. the presence of depth or stencil buffer) are not satisfied.


vgPostSwapBuffersMZT

void vgPostSwapBuffersMZT(void);

Reset depth and stencil buffers to a valid state for the next frame (AmanithVG GLE): ensure a consistent state of depth/stencil buffers on GL Graphic System with non-persistent buffers. Please note that this function must be called after each SwapBuffers (Win) / CGLFlushDrawable (MacOS X) / glXSwapBuffers (Linux) / presentRenderbuffer (iOS) / onDrawFrame (Android GLSurfaceView.Renderer) / eglSwapBuffers. AmanithVG SRE implementation does nothing.


vgGetProcAddressMZT

typedef void (*__vgFunctionPtr)(void);
__vgFunctionPtr vgGetProcAddressMZT(const char* procname);

Return the address of the extension function named by procname parameter (it must be a null-terminated string). The pointer returned should be cast to a function pointer type matching the extension function’s definition in that extension specification. A return value of NULL indicates that the specific function does not exist for the OpenVG implementation.


Additional notes

AmanithVG SRE: it doesn’t provide functionality like eglSwapBuffers: all the rendering is performed in system memory. The user must write its own blitter in order to copy the content of an AmanithVG SRE drawing surface to the video memory (framebuffer). AmanithVG SRE drawing surfaces store each pixel as a 32bit integer value, whose format can be detected, at runtime, using vgGetSurfaceFormatMZT; the custom blitter must take care of eventual format conversion between drawing surface and framebuffer formats.

AmanithVG GLE: an OpenGL / OpenGL ES rendering context must be opened and an OpenGL / OpenGL ES rendering surface (multisampled or not multisampled) must be created using the native platform graphics interface before to call vgPrivMakeCurrentMZT.