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:
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
.
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.
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.
void vgPrivContextDestroyMZT(void* context);
Destroy a previously created OpenVG context.
void* vgPrivSurfaceCreateMZT(VGint width,
VGint height,
VGboolean linearColorSpace,
VGboolean alphaPremultiplied,
VGboolean alphaMask);
Create and initialize a drawing surface. In the detail this function allocates:
a 32bit (i.e. each pixel is a 32bit integer value) drawing surface buffer (AmanithVG SRE), whose size is equal to width * height * 4
bytes.
an 8bit alpha mask buffer, if alphaMask
parameter is VG_TRUE
, whose size is equal to width * height
bytes.
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.
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:
pixels
parameter must be a non-NULL
4-bytes aligned pointer; it must point to a contiguous memory area of a size not less that width * height * 4
bytes.alphaMaskPixels
parameter, if non NULL
, specifies a pointer to the memory area that will store the 8bit alpha mask and it must point to a contiguous memory area of a size not less that width * height
bytes; if NULL, OpenVG alpha mask feature will be silently disabled at all.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.
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).
VGboolean vgPrivSurfaceResizeMZT(void* surface,
VGint width,
VGint height);
Resize the dimensions of the specified drawing surface. This function:
reallocates the drawing surface pixels buffer, according to new specified dimensions (AmanithVG SRE).
if the surface contains the alpha mask buffer, it reallocates that 8bit buffer according to new specified dimensions.
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.
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:
pixels
parameter must be a non-NULL
4-bytes aligned pointer; it must point to a contiguous memory area of a size not less that width * height * 4
bytes.alphaMaskPixels
parameter, if non NULL
, specifies a pointer to the memory area that will store the 8bit alpha mask and it must point to a contiguous memory area of a size not less that width * height
bytes; if NULL, OpenVG alpha mask feature will be silently disabled at all.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.
void vgPrivSurfaceDestroyMZT(void* surface);
Destroy a previously created drawing surface.
VGint vgPrivGetSurfaceWidthMZT(const void* surface);
Get the width (in pixels) of the given drawing surface.
VGint vgPrivGetSurfaceHeightMZT(const void* surface);
Get the height (in pixels) of the given drawing surface.
VGImageFormat vgPrivGetSurfaceFormatMZT(const void* surface);
Get the format of the given drawing surface.
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).
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.
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.
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.
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
.