diff options
Diffstat (limited to 'src/vg/Api.cpp.tg')
-rw-r--r-- | src/vg/Api.cpp.tg | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/vg/Api.cpp.tg b/src/vg/Api.cpp.tg new file mode 100644 index 0000000..4f8a94f --- /dev/null +++ b/src/vg/Api.cpp.tg @@ -0,0 +1,37 @@ + +#include <stdio.h> +#include <stdlib.h> +#include "egl.h" +#include "openvg.h" + +namespace tgOpenVG { + +VGPaint RI_APIENTRY vgCreatePaint(void) { + + RI_GET_CONTEXT(VG_INVALID_HANDLE); + Paint* paint = NULL; + try + { + paint = RI_NEW(Paint, ()); //throws bad_alloc + RI_ASSERT(paint); + context->m_paintManager->addResource(paint, context); //throws bad_alloc + RI_RETURN((VGPaint)paint); + } + catch(std::bad_alloc) + { + RI_DELETE(paint); + context->setError(VG_OUT_OF_MEMORY_ERROR); + RI_RETURN(VG_INVALID_HANDLE); + } +} + +void RI_APIENTRY vgDestroyPaint(VGPaint paint) { + RI_GET_CONTEXT(RI_NO_RETVAL); + RI_IF_ERROR(!context->isValidPaint(paint), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid paint handle + + context->m_paintManager->removeResource((Paint*)paint); + + RI_RETURN(RI_NO_RETVAL); +} + +} |