#include "EXGLNativeApi.h" #include "EXGLNativeContext.h" #include "EXGLContextManager.h" using namespace expo::gl_cpp; EXGLContextId EXGLContextCreate() { return ContextCreate(); } void EXGLContextPrepare(void *jsiPtr, EXGLContextId exglCtxId, std::function flushMethod) { auto [exglCtx, lock] = ContextGet(exglCtxId); if (exglCtx) { exglCtx->prepareContext(*reinterpret_cast(jsiPtr), flushMethod); } } bool EXGLContextNeedsRedraw(EXGLContextId exglCtxId) { auto [exglCtx, lock] = ContextGet(exglCtxId); if (exglCtx) { return exglCtx->needsRedraw; } return false; } void EXGLContextDrawEnded(EXGLContextId exglCtxId) { auto [exglCtx, lock] = ContextGet(exglCtxId); if (exglCtx) { exglCtx->needsRedraw = false; } } void EXGLContextDestroy(EXGLContextId exglCtxId) { ContextDestroy(exglCtxId); } void EXGLContextFlush(EXGLContextId exglCtxId) { auto [exglCtx, lock] = ContextGet(exglCtxId); if (exglCtx) { exglCtx->flush(); } } void EXGLContextSetDefaultFramebuffer(EXGLContextId exglCtxId, GLint framebuffer) { auto [exglCtx, lock] = ContextGet(exglCtxId); if (exglCtx) { exglCtx->defaultFramebuffer = framebuffer; } } EXGLObjectId EXGLContextCreateObject(EXGLContextId exglCtxId) { auto [exglCtx, lock] = ContextGet(exglCtxId); if (exglCtx) { return exglCtx->createObject(); } return 0; } void EXGLContextDestroyObject(EXGLContextId exglCtxId, EXGLObjectId exglObjId) { auto [exglCtx, lock] = ContextGet(exglCtxId); if (exglCtx) { exglCtx->destroyObject(exglObjId); } } void EXGLContextMapObject(EXGLContextId exglCtxId, EXGLObjectId exglObjId, GLuint glObj) { auto [exglCtx, lock] = ContextGet(exglCtxId); if (exglCtx) { exglCtx->mapObject(exglObjId, glObj); } } GLuint EXGLContextGetObject(EXGLContextId exglCtxId, EXGLObjectId exglObjId) { auto [exglCtx, lock] = ContextGet(exglCtxId); if (exglCtx) { return exglCtx->lookupObject(exglObjId); } return 0; }