summaryrefslogtreecommitdiff
path: root/src/vg/EGLAddOn.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/vg/EGLAddOn.cpp')
-rw-r--r--src/vg/EGLAddOn.cpp39
1 files changed, 35 insertions, 4 deletions
diff --git a/src/vg/EGLAddOn.cpp b/src/vg/EGLAddOn.cpp
index e8da666..f8d25bc 100644
--- a/src/vg/EGLAddOn.cpp
+++ b/src/vg/EGLAddOn.cpp
@@ -306,7 +306,9 @@ public:
int getNumConfigs() const { return EGL_NUMCONFIGS; }
const RIEGLConfig& getConfig(int i) const { RI_ASSERT(i >= 0 && i < EGL_NUMCONFIGS); return m_configs[i]; }
- const RIEGLConfig& getConfig(const EGLConfig config) const { for(int i=0;i<EGL_NUMCONFIGS;i++) { if(m_configs[i].m_config == config) return m_configs[i]; } RI_ASSERT(0); return m_configs[0]; }
+ const RIEGLConfig& getConfig(const EGLConfig config) const { for(int i=0;i<EGL_NUMCONFIGS;i++) { if(m_configs[i].m_config == config) return m_configs[i]; }
+ // RI_ASSERT(0);
+ return m_configs[0]; }
const EGLDisplay getID() const { return m_id; }
@@ -838,19 +840,48 @@ extern "C"
void tgOpenVGCreateContext(ESContext *esContext) {
EGL* egl = getEGL();
+ RIEGLSurface *riSurfaceDraw;
+ RIEGLDisplay *riD;
+ RIEGLContext *riC;
+ Drawable *d;
RIEGLThread* thread = egl->getThread();
- tgOpenVG::VGContext* vgctx = NULL;
- RIEGLContext* c = NULL;
+ if (!thread) {
+ thread = RI_NEW(RIEGLThread, (OSGetCurrentThreadID() ));
+ }
+
+ /* sane defaults */
+ int colorSpace = EGL_VG_COLORSPACE_sRGB;
+ int alphaFormat = EGL_VG_ALPHA_FORMAT_NONPRE;
+ tgOpenVG::VGContext* vgctx = NULL;
try {
vgctx = RI_NEW(tgOpenVG::VGContext, (NULL)); //throws bad_alloc
- c = RI_NEW(RIEGLContext, (vgctx, esContext->eglConfig)); //throws bad_alloc
+ riC = RI_NEW(RIEGLContext, (vgctx, esContext->eglConfig)); //throws bad_alloc
+
esContext->vgContext = vgctx;
+ riD=RI_NEW(RIEGLDisplay, (esContext->eglDisplay));
+ riD->addContext(riC);
+
+ d = RI_NEW(Drawable, (riD->getConfig(esContext->eglConfig).configToDescriptor((colorSpace == EGL_VG_COLORSPACE_LINEAR) ? false : true, (alphaFormat == EGL_VG_ALPHA_FORMAT_PRE) ? true : false), esContext->width, esContext->height, riD->getConfig(esContext->eglConfig).m_samples, riD->getConfig(esContext->eglConfig).m_maskBits));
+
+ riSurfaceDraw=RI_NEW(RIEGLSurface, (esContext->eglContext, esContext->eglConfig, d, false , EGL_BACK_BUFFER));
+ riD->addSurface(riSurfaceDraw);
+
+ thread->makeCurrent(riC, riSurfaceDraw);
+ riC->getVGContext()->setDefaultDrawable(riSurfaceDraw->getDrawable());
+
+ egl->addCurrentThread(thread);
}
catch (std::bad_alloc) {
}
+
+ riC->addReference();
+ riSurfaceDraw->addReference();
+ esContext->rieglSurface=riSurfaceDraw;
+ esContext->rieglDisplay=riD;
+ esContext->rieglContext=riC;
}