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:


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.


vgPrivSurfaceMaxDimensionGetMZT

VGint vgPrivSurfaceMaxDimensionGetMZT(void);

Get the maximum dimension allowed for drawing surfaces. This is the maximum valid value that can be specified as width and height for the vgPrivSurfaceCreateMZT and vgPrivSurfaceResizeMZT functions. Bigger values are silently clamped to it.


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 vgPrivSurfaceMaxDimensionGetMZT function; 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.


vgPrivSurfaceCreateFromImageMZT

void* vgPrivSurfaceCreateFromImageMZT(VGImage image, VGboolean alphaMask);

Create a drawing surface, bound to the given VGImage. This function is implemented by AmanithVG SRE only (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 vgPrivSurfaceMaxDimensionGetMZT function; 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.


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.


VGImageFormat

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

No other EGL functionalities such as, but not limited to, thread safety and multi-thread support are provided.

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.