1 #ifndef SDK_GL2D_OBJECTS_H_
11 #define SDK_GL2D_OBJECTS_H_
15 #include <visualizationlayer/inc/vis_const.h>
19 SDK_GL2D_BEGIN_NAMESPACE
23 #if defined(SDK_GL2D_USE_WGL) // WGL based OpenGL implementation
24 __pragma(pack(push, 1))
32 : wnd(NULL), dc(NULL), ctx(NULL)
34 GlCtx(
const HWND& wnd_,
const HDC& dc_,
const HGLRC& ctx_)
35 : wnd(wnd_), dc(dc_), ctx(ctx_)
38 : wnd(context.wnd), dc(context.dc), ctx(context.ctx)
41 inline bool IsReady()
const
42 { return ::IsWindow(wnd) && NULL != dc && NULL != ctx; }
45 { wnd = NULL; dc = NULL; ctx = NULL; }
48 #elif defined(SDK_GL2D_USE_IMX6_EGL) // EGL based OpenGL implementation for iMX6
51 NativeDisplayType fb_disp;
58 : fb_disp(NULL), disp(EGL_NO_DISPLAY), ctx(EGL_NO_CONTEXT), surf(EGL_NO_SURFACE)
60 GlCtx(
const NativeDisplayType& fb_disp_,
const EGLDisplay& disp_,
61 const EGLContext& ctx_,
const EGLSurface& surf_)
62 : fb_disp(fb_disp_), disp(disp_), ctx(ctx_), surf(surf_)
65 : fb_disp(context.fb_disp), disp(context.disp), ctx(context.ctx), surf(context.surf)
68 inline bool IsReady()
const
70 return NULL != fb_disp && EGL_NO_DISPLAY != disp
71 && EGL_NO_CONTEXT != ctx && EGL_NO_SURFACE != surf;
75 fb_disp = NULL; disp = EGL_NO_DISPLAY;
76 ctx = EGL_NO_CONTEXT; surf = EGL_NO_SURFACE;
78 } __attribute__((packed));
79 #elif defined(SDK_GL2D_USE_ANDROID_EGL) // EGL based OpenGL implementation for Android
87 : disp(EGL_NO_DISPLAY), ctx(EGL_NO_CONTEXT), surf(EGL_NO_SURFACE)
89 GlCtx(
const EGLDisplay& disp_,
const EGLContext& ctx_,
const EGLSurface& surf_)
90 : disp(disp_), ctx(ctx_), surf(surf_)
93 : disp(context.disp), ctx(context.ctx), surf(context.surf)
96 inline bool IsReady()
const
97 {
return EGL_NO_DISPLAY != disp && EGL_NO_CONTEXT != ctx && EGL_NO_SURFACE != surf; }
100 { disp = EGL_NO_DISPLAY; ctx = EGL_NO_CONTEXT; surf = EGL_NO_SURFACE; }
101 } __attribute__((packed));
102 #elif defined(SDK_GL2D_USE_EGL) // EGL based OpenGL implementation
110 : disp(EGL_NO_DISPLAY), ctx(EGL_NO_CONTEXT), surf(EGL_NO_SURFACE)
112 GlCtx(
const EGLDisplay& disp_,
const EGLContext& ctx_,
const EGLSurface& surf_)
113 : disp(disp_), ctx(ctx_), surf(surf_)
116 : disp(context.disp), ctx(context.ctx), surf(context.surf)
119 inline bool IsReady()
const
120 {
return EGL_NO_DISPLAY != disp && EGL_NO_CONTEXT != ctx && EGL_NO_SURFACE != surf; }
122 inline void ClearUp()
123 { disp = EGL_NO_DISPLAY; ctx = EGL_NO_CONTEXT; surf = EGL_NO_SURFACE; }
124 } __attribute__((packed));
125 #elif defined(SDK_GL2D_USE_MESA) // Mesa based OpenGL implementation
133 GlCtx(
const OSMesaContext& ctx_)
140 inline bool IsReady()
const
141 {
return NULL != ctx; }
143 inline void ClearUp()
145 } __attribute__((packed));
146 #elif defined(SDK_GL2D_USE_GLX) // GLX based OpenGL implementation
154 : disp(NULL), ctx(NULL), pbuffer(0)
156 GlCtx(Display*
const disp_,
const GLXContext& ctx_,
const GLXPbuffer& pbuffer_)
157 : disp(disp_), ctx(ctx_), pbuffer(pbuffer_)
160 : disp(context.disp), ctx(context.ctx), pbuffer(context.pbuffer)
163 inline bool IsReady()
const
164 {
return NULL != disp && NULL != ctx && 0 != pbuffer; }
166 inline void ClearUp()
167 { disp = NULL; ctx = NULL; pbuffer = 0; }
168 } __attribute__((packed));
169 #else // Fake (unknown) OpenGL platform
172 const bool is_fake_opengl_platform_ready;
175 : is_fake_opengl_platform_ready(
false)
178 inline bool IsReady()
const
179 {
return is_fake_opengl_platform_ready; }
181 inline void ClearUp()
188 #if defined(SDK_GL2D_USE_WGL) // WGL based OpenGL implementation
189 __pragma(pack(push, 1))
199 inline bool IsReady()
const {
return NULL != ctx; }
202 #elif defined(SDK_GL2D_USE_IMX6_EGL) // EGL based OpenGL implementation for iMX6
205 NativeDisplayType fb_disp;
210 : fb_disp(NULL), disp(EGL_NO_DISPLAY), ctx(EGL_NO_CONTEXT)
213 const EGLDisplay& disp_,
const EGLContext& ctx_)
214 : fb_disp(fb_disp_), disp(disp_), ctx(ctx_)
217 : fb_disp(shared_context.fb_disp), disp(shared_context.disp), ctx(shared_context.ctx)
220 : fb_disp(context.fb_disp), disp(context.disp), ctx(context.ctx)
223 inline bool IsReady()
const
224 {
return NULL != fb_disp && EGL_NO_DISPLAY != disp && EGL_NO_CONTEXT != ctx; }
225 } __attribute__((packed));
226 #elif defined(SDK_GL2D_USE_ANDROID_EGL) // EGL based OpenGL implementation for Android
236 inline bool IsReady()
const {
return EGL_NO_CONTEXT != ctx; }
237 } __attribute__((packed));
238 #elif defined(SDK_GL2D_USE_EGL) // EGL based OpenGL implementation
248 inline bool IsReady()
const {
return EGL_NO_CONTEXT != ctx; }
249 } __attribute__((packed));
250 #elif defined(SDK_GL2D_USE_MESA) // Mesa based OpenGL implementation
256 GlSharedCtx(
const OSMesaContext& ctx_) : ctx(ctx_) {}
260 inline bool IsReady()
const {
return NULL != ctx; }
261 } __attribute__((packed));
262 #elif defined(SDK_GL2D_USE_GLX) // GLX based OpenGL implementation
272 inline bool IsReady()
const {
return NULL != ctx; }
273 } __attribute__((packed));
274 #else // Fake (unknown) OpenGL platform
277 const bool is_fake_opengl_shared_ctx_ready;
280 : is_fake_opengl_shared_ctx_ready(
false)
283 inline bool IsReady()
const
284 {
return is_fake_opengl_shared_ctx_ready; }
288 SDK_GL2D_END_NAMESPACE
290 #endif // SDK_GL2D_OBJECTS_H_