NAVTOR SDK  v.3.0
Software Development Kit for fast and efficient development of ECDIS, ECS and generic marine applications
scene_manager_gl_helper.h
Go to the documentation of this file.
1 
11 #ifndef SDK_VISMAN_SCENE_MANAGER_GL_HELPERS_H_
12 #define SDK_VISMAN_SCENE_MANAGER_GL_HELPERS_H_
13 #pragma once
14 
15 #include <base/inc/platform.h>
16 #include <base/inc/interfaces/parameters/parameters_impl.h>
17 #include <visualizationlayer/inc/vis_const.h>
20 #include <visualizationlayer/inc/gl2d/gl2d_thread_interface.h>
21 #include <visualizationlayer/inc/gl2d/gl2d_ext_created_ctx_interface.h>
23 
24 namespace sdk {
25 namespace visgl {
26 
30  const std::wstring& name,
31  SceneManagerGLType gl_type,
32  const ISDKParametersSP& sharable_context,
33  const sdk::gl2d::IGL2DExtCreatedGlCtxSP& ext_created_ctx,
34  const ISceneManagerGLSP& scene_manager_gl,
35  sdk::gl2d::GL2DTextureFormat texture_format,
36  SDKUInt32 scene_width,
37  SDKUInt32 scene_height,
38  double resolution_dpm,
39  SDKUInt64 flags,
40  ISDKParametersSP& init_params)
41 {
42  ISDKParametersSP parameters(new ParametersMap<ISDKParameters>());
43 
44  parameters->SetParameter(kSceneManagerGLInitialParameter_Name, SDKAnyHandler(name));
45  parameters->SetParameter(kSceneManagerGLInitialParameter_GLType, SDKAnyHandler(gl_type));
46 
47  if (sharable_context)
48  parameters->SetParameter(kSceneManagerGLInitialParameter_SharableContext,
49  SDKAnyHandler(sharable_context));
50  if (ext_created_ctx)
52  SDKAnyHandler(ext_created_ctx));
53  if (scene_manager_gl)
54  parameters->SetParameter(kSceneManagerGLInitialParameter_SceneManagerGL,
55  SDKAnyHandler(scene_manager_gl));
56 
57  parameters->SetParameter(kSceneManagerGLInitialParameter_TextureFormat, SDKAnyHandler(texture_format));
58  parameters->SetParameter(kSceneManagerGLInitialParameter_SceneWidth, SDKAnyHandler(scene_width));
59  parameters->SetParameter(kSceneManagerGLInitialParameter_SceneHeight, SDKAnyHandler(scene_height));
60  parameters->SetParameter(kSceneManagerGLInitialParameter_ResolutionDPM, SDKAnyHandler(resolution_dpm));
61  parameters->SetParameter(kSceneManagerGLInitialParameter_Flags, SDKAnyHandler(flags));
62 
63  init_params = parameters;
64 
65  return kSDKResult_Succeeded;
66 }
67 
69  const std::wstring& name,
70  SceneManagerGLType gl_type,
71  const ISDKParametersSP& sharable_context,
72  sdk::gl2d::GL2DTextureFormat texture_format,
73  SDKUInt32 scene_width,
74  SDKUInt32 scene_height,
75  double resolution_dpm,
76  SDKUInt64 flags,
77  ISDKParametersSP& init_params)
78 {
80  name, gl_type, sharable_context, sdk::gl2d::IGL2DExtCreatedGlCtxSP(),
81  ISceneManagerGLSP(), texture_format, scene_width, scene_height,
82  resolution_dpm, flags, init_params);
83 }
84 
90  const std::wstring& name,
91  SceneManagerGLType gl_type,
92  const sdk::gl2d::IGL2DThreadSP& gl2d_thread,
93  void* const get_gl_proc_addr,
94  void* const gl_lib_handle,
95  sdk::gl2d::GL2DTextureFormat texture_format,
96  SDKUInt32 scene_width,
97  SDKUInt32 scene_height,
98  double resolution_dpm,
99  SDKUInt64 flags,
100  ISDKParametersSP& init_params)
101 {
102  ISDKParametersSP parameters(new ParametersMap<ISDKParameters>());
103 
104  parameters->SetParameter(kSceneManagerGLInitialParameter_Name, SDKAnyHandler(name));
105  parameters->SetParameter(kSceneManagerGLInitialParameter_GLType, SDKAnyHandler(gl_type));
106 
107  if (gl2d_thread && get_gl_proc_addr && gl_lib_handle)
108  {
109  parameters->SetParameter(kSceneManagerGLInitialParameter_ExtCtx_GL2DThread, SDKAnyHandler(gl2d_thread));
110 
111  SDKAny get_gl_proc_addr_any;
112  get_gl_proc_addr_any.any_type = kSDKAnyType_UserPtr;
113  get_gl_proc_addr_any.vd = get_gl_proc_addr;
114  parameters->SetParameter(kSceneManagerGLInitialParameter_ExtCtx_xxxGetGlProcAddr, get_gl_proc_addr_any);
115 
116  SDKAny gl_lib_handle_any;
117  gl_lib_handle_any.any_type = kSDKAnyType_UserPtr;
118  gl_lib_handle_any.vd = gl_lib_handle;
119  parameters->SetParameter(kSceneManagerGLInitialParameter_ExtCtx_GlLibHandle, gl_lib_handle_any);
120  }
121 
122  parameters->SetParameter(kSceneManagerGLInitialParameter_TextureFormat, SDKAnyHandler(texture_format));
123  parameters->SetParameter(kSceneManagerGLInitialParameter_SceneWidth, SDKAnyHandler(scene_width));
124  parameters->SetParameter(kSceneManagerGLInitialParameter_SceneHeight, SDKAnyHandler(scene_height));
125  parameters->SetParameter(kSceneManagerGLInitialParameter_ResolutionDPM, SDKAnyHandler(resolution_dpm));
126  parameters->SetParameter(kSceneManagerGLInitialParameter_Flags, SDKAnyHandler(flags));
127 
128  init_params = parameters;
129 
130  return kSDKResult_Succeeded;
131 }
132 
133 #if defined(SDK_GL2D_USE_WGL) // WGL based OpenGL implementation
134 enum PlatformSpecificGLContextParameter
138 {
139  kPlatformSpecificGLContextParameter_HGLRC,
140 };
144 inline ISDKParametersSP WrapContext(
145  HGLRC sharable_context)
146 {
147  ISDKParametersSP context(new ParametersMap<>());
148  context->SetParameter(kPlatformSpecificGLContextParameter_HGLRC, SDKAnyHandler(reinterpret_cast<SDKUInt64>(sharable_context)));
149  return context;
150 }
151 #elif defined(SDK_GL2D_USE_IMX6_EGL) // EGL based OpenGL implementation for iMX6
152 enum PlatformSpecificGLContextParameter
153 {
154  kPlatformSpecificGLContextParameter_NativeDisplayType,
155  kPlatformSpecificGLContextParameter_EGLDisplay,
156  kPlatformSpecificGLContextParameter_EGLContext,
157 };
158 inline ISDKParametersSP WrapContexts(
159  NativeDisplayType fb_disp,
160  EGLDisplay disp,
161  EGLContext ctx)
162 {
163  ISDKParametersSP context(new ParametersMap<>());
164  context->SetParameter(kPlatformSpecificGLContextParameter_NativeDisplayType, SDKAnyHandler(reinterpret_cast<SDKUInt64>(fb_disp)));
165  context->SetParameter(kPlatformSpecificGLContextParameter_EGLDisplay, SDKAnyHandler(reinterpret_cast<SDKUInt64>(disp)));
166  context->SetParameter(kPlatformSpecificGLContextParameter_EGLContext, SDKAnyHandler(reinterpret_cast<SDKUInt64>(ctx)));
167  return context;
168 }
169 #elif defined(SDK_GL2D_USE_ANDROID_EGL) // EGL based OpenGL implementation for Android
170 enum PlatformSpecificGLContextParameter
171 {
172  kPlatformSpecificGLContextParameter_EGLContext,
173 };
174 inline ISDKParametersSP WrapContext(
175  EGLContext ctx)
176 {
177  ISDKParametersSP context(new ParametersMap<>());
178  context->SetParameter(kPlatformSpecificGLContextParameter_EGLContext, SDKAnyHandler(reinterpret_cast<SDKUInt64>(ctx)));
179  return context;
180 }
181 #elif defined(SDK_GL2D_USE_EGL) // EGL based OpenGL implementation
182 enum PlatformSpecificGLContextParameter
183 {
184  kPlatformSpecificGLContextParameter_EGLContext,
185 };
186 inline ISDKParametersSP WrapContext(
187  EGLContext ctx)
188 {
189  ISDKParametersSP context(new ParametersMap<>());
190  context->SetParameter(kPlatformSpecificGLContextParameter_EGLContext, SDKAnyHandler(reinterpret_cast<SDKUInt64>(ctx)));
191  return context;
192 }
193 #elif defined(SDK_GL2D_USE_MESA) // Mesa based OpenGL implementation
194 enum PlatformSpecificGLContextParameter
195 {
196  kPlatformSpecificGLContextParameter_OSMesaContext,
197 };
198 inline ISDKParametersSP WrapContext(
199  OSMesaContext ctx)
200 {
201  ISDKParametersSP context(new ParametersMap<>());
202  context->SetParameter(kPlatformSpecificGLContextParameter_OSMesaContext, SDKAnyHandler(reinterpret_cast<SDKUInt64>(ctx)));
203  return context;
204 }
205 #elif defined(SDK_GL2D_USE_GLX) // GLX based OpenGL implementation
206 enum PlatformSpecificGLContextParameter
207 {
208  kPlatformSpecificGLContextParameter_GLXContext,
209 };
210 inline ISDKParametersSP WrapContext(
211  GLXContext ctx)
212 {
213  ISDKParametersSP context(new ParametersMap<>());
214  context->SetParameter(kPlatformSpecificGLContextParameter_GLXContext, SDKAnyHandler(reinterpret_cast<SDKUInt64>(ctx)));
215  return context;
216 }
217 #else // Fake (unknown) OpenGL platform
218 enum PlatformSpecificGLContextParameter
219 {
220  kPlatformSpecificGLContextParameter_UnknownContext,
221 };
222 inline ISDKParametersSP WrapContext(
223  SDKUInt64 ctx)
224 {
225  ISDKParametersSP context(new ParametersMap<>());
226  context->SetParameter(kPlatformSpecificGLContextParameter_UnknownContext, SDKAnyHandler(ctx));
227  return context;
228 }
229 #endif
230 
231 } // namespace visgl
232 } // namespace sdk
233 
234 #endif // SDK_VISMAN_SCENE_MANAGER_GL_HELPERS_H_
kSceneManagerGLInitialParameter_Name
@ kSceneManagerGLInitialParameter_Name
Name of the scene manager.
Definition: scene_manager_gl_interface.h:65
SceneManagerGLType
SceneManagerGLType
Scene Manager graphic library type.
Definition: scene_manager_gl_interface.h:95
kSceneManagerGLInitialParameter_TextureFormat
@ kSceneManagerGLInitialParameter_TextureFormat
Format of the scene texture.
Definition: scene_manager_gl_interface.h:78
GL2DTextureFormat
GL2DTextureFormat
Texture pixel format.
Definition: gl2d_texture_interface.h:42
gl2d_objects.h
Platform-dependent GL objects.
kSceneManagerGLInitialParameter_ResolutionDPM
@ kSceneManagerGLInitialParameter_ResolutionDPM
Scene resolution DPM.
Definition: scene_manager_gl_interface.h:68
kSDKResult_Succeeded
static const SDKResult kSDKResult_Succeeded
Operation completed successfully.
Definition: sdk_results.h:22
kSceneManagerGLInitialParameter_ExtCreatedGlContext
@ kSceneManagerGLInitialParameter_ExtCreatedGlContext
Own implementation of IGL2DExtCreatedGlCtx to create GL context by using external application API.
Definition: scene_manager_gl_interface.h:76
kSceneManagerGLInitialParameter_SceneManagerGL
@ kSceneManagerGLInitialParameter_SceneManagerGL
Earlier created scene manager GL instance.
Definition: scene_manager_gl_interface.h:77
sdk::visgl::CreateSceneManagerGLInitialParameters
SDKResult CreateSceneManagerGLInitialParameters(const std::wstring &name, SceneManagerGLType gl_type, const ISDKParametersSP &sharable_context, const sdk::gl2d::IGL2DExtCreatedGlCtxSP &ext_created_ctx, const ISceneManagerGLSP &scene_manager_gl, sdk::gl2d::GL2DTextureFormat texture_format, SDKUInt32 scene_width, SDKUInt32 scene_height, double resolution_dpm, SDKUInt64 flags, ISDKParametersSP &init_params)
Places scene manager initialization parameters into container which should be passed to Initialize me...
Definition: scene_manager_gl_helper.h:29
SDKResult
SDKInt32 SDKResult
Type of all error or return codes which SDK functions can end with.
Definition: sdk_results.h:17
kSceneManagerGLInitialParameter_ExtCtx_GlLibHandle
@ kSceneManagerGLInitialParameter_ExtCtx_GlLibHandle
Handle to appropriate OpenGL library (::GetModuleHandleA("opengl32.dll") for Windows,...
Definition: scene_manager_gl_interface.h:75
kSceneManagerGLInitialParameter_SharableContext
@ kSceneManagerGLInitialParameter_SharableContext
Platform specific reference to an exiting GL context to share with.
Definition: scene_manager_gl_interface.h:72
kSDKAnyType_UserPtr
@ kSDKAnyType_UserPtr
user defined type of any size
Definition: base_types.h:163
kSceneManagerGLInitialParameter_ExtCtx_GL2DThread
@ kSceneManagerGLInitialParameter_ExtCtx_GL2DThread
Own implementation of IGL2DThread interface to execute tasks in GL thread.
Definition: scene_manager_gl_interface.h:73
kSceneManagerGLInitialParameter_SceneHeight
@ kSceneManagerGLInitialParameter_SceneHeight
Scene height.
Definition: scene_manager_gl_interface.h:67
kSceneManagerGLInitialParameter_GLType
@ kSceneManagerGLInitialParameter_GLType
see SceneManagerGLType.
Definition: scene_manager_gl_interface.h:71
kSceneManagerGLInitialParameter_ExtCtx_xxxGetGlProcAddr
@ kSceneManagerGLInitialParameter_ExtCtx_xxxGetGlProcAddr
Pointer to appropriate xxxGetProcAddress method (wglGetProcAddress/eglGetProcAddress/glXGetProcAddres...
Definition: scene_manager_gl_interface.h:74
sdk::visgl::WrapContext
ISDKParametersSP WrapContext(SDKUInt64 ctx)
Definition: scene_manager_gl_helper.h:222
platform.h
Describes the platform constants.
kSceneManagerGLInitialParameter_Flags
@ kSceneManagerGLInitialParameter_Flags
Flags.
Definition: scene_manager_gl_interface.h:69
sdk::SDKAnyHandler
This class wraps the SDKAny type.
Definition: sdk_any_handler.h:32
kSceneManagerGLInitialParameter_SceneWidth
@ kSceneManagerGLInitialParameter_SceneWidth
Scene width.
Definition: scene_manager_gl_interface.h:66
gl2d_texture_interface.h
GL2D Texture object.
scene_manager_gl_interface.h
Describes all interfaces for controlling visualization.