NAVTOR SDK  v.3.0
Software Development Kit for fast and efficient development of ECDIS, ECS and generic marine applications
os_specific_types.h
Go to the documentation of this file.
1 
10 #ifndef SDK_OS_SPECIFIC_TYPES_H_
11 #define SDK_OS_SPECIFIC_TYPES_H_
12 #pragma once
13 
14 #include <base/inc/platform.h>
15 #include <base/inc/base_types.h>
16 #include <base/inc/sdk_pshpack1.h>
17 
18 // To enable the Direct2D/DirectX 10.1 support, use SDK_GRAPHICS_USE_DIRECTX_10_1 macros
19 
20 // Direct2D/OpenGL support
21 #if defined(SDK_OS_WIN) // Windows
22 # include <Windows.h>
23 # include <GL/GL.h>
24 # if defined(SDK_GRAPHICS_USE_DIRECTX_10_1)
25 # include <D2D1.h> // Direct2D is available on Windows only
26 # include <DWrite.h> // DirectWrite is available on Windows only
27 # if defined ERROR
28 # undef ERROR // ERROR macros definition intersects with google ERROR definition
29 # endif //ERROR
30 # endif // SDK_GRAPHICS_USE_DIRECTX_10_1
31 #elif defined(SDK_OS_LINUX) // Linux
32 # if defined(SDK_DONT_USE_X11)
33 # undef SDK_USE_X11
34 # elif !defined(SDK_USE_X11)
35 # define SDK_USE_X11
36 # endif // SDK_DONT_USE_X11
37 # ifdef SDK_USE_X11
38 # include <X11/Xlib.h>
39 # include <GL/glx.h>
40 # else
41 # define LINUX
42 # define EGL_API_FB
43 # include <GLES2/gl2.h>
44 # include <EGL/egl.h>
45 # endif // SDK_USE_X11
46 #elif defined(SDK_OS_ANDROID) // Android
47 // Nothing, not implemented for Android platform,
48 // only empty stubs are in use
49 #else
50 # error Specific includes for given platform should be defined
51 #endif
52 
53 #include <base/inc/sdk_pshpack1.h>
54 
55 namespace sdk {
56 namespace gfx {
57 
60 #if defined(SDK_OS_WIN)
61 // Windows specific window
62 SDK_PACK(struct OSWindow
63 {
64  HWND hwnd; // Window handle
65 });
66 #elif defined(SDK_OS_LINUX)
67 
68 # ifdef SDK_USE_X11
69 // Linux specific window
70 SDK_PACK(struct OSWindow
71 {
72  Display* display; // Display to use
73  Window window; // Window to use
74  XVisualInfo* visual_info; // Visual info, which was used to create given window
75 });
76 # else
77 class DummyWindow
78 {
79 public:
80  DummyWindow(int x, int y, int width, int height) {}
81  virtual ~DummyWindow() {}
82  virtual int PutBitmapToWindow(int x, int y, const void* bits, int width,
83  int height, int stride, int format) { return 0; }
84  virtual int getSize(unsigned long int* width,
85  unsigned long int* height) { return 0; }
86 };
87 typedef DummyWindow* OSWindow;
88 # endif // SDK_USE_X11
89 
90 #elif defined(SDK_OS_ANDROID)
91 // Not implemented for Android platform, using empty
92 // OSWindow structure definition
93 SDK_PACK(struct OSWindow
94 {
95  int not_implemented_for_android;
96 });
97 
98 #else
99 # error Definition of OSWindow required
100 #endif
101 
107 #if defined(SDK_OS_WIN)
108 // Windows specific device contexts
109 SDK_PACK(struct OpenGLGraphicsDeviceContext
110 {
111  HDC device_context; // HDC device context
112  HGLRC opengl_context; // OpenGL context
113 });
114 #elif defined(SDK_OS_LINUX)
115 
116 # ifdef SDK_USE_X11
117 // Linux specific device contexts
118 SDK_PACK(struct OpenGLGraphicsDeviceContext
119 {
120  OSWindow os_window; // Linux window
121  GLXContext opengl_context; // OpenGL context
122 });
123 # else
124 class DummyGraphicsDeviceContext
125 {
126 public:
127  DummyGraphicsDeviceContext(DummyWindow* window = NULL);
128  DummyGraphicsDeviceContext(const DummyGraphicsDeviceContext& other);
129  DummyGraphicsDeviceContext& operator=(const DummyGraphicsDeviceContext& rhs);
130  ~DummyGraphicsDeviceContext();
131  static bool isNoneCurrent();
132  bool isCurrent();
133  void makeCurrent();
134  void release();
135  bool isValid();
136 
137  EGLDisplay fDisplay;
138  EGLSurface fSurface;
139  EGLContext fContext;
140 };
141 typedef DummyGraphicsDeviceContext* OpenGLGraphicsDeviceContext;
142 # endif // SDK_USE_X11
143 
144 #elif defined(SDK_OS_ANDROID)
145 // Not implemented for Android platform, using empty
146 // OpenGLGraphicsDeviceContext structure definition
147 SDK_PACK(struct OpenGLGraphicsDeviceContext
148 {
149  int not_implemented_for_android;
150 });
151 
152 #else
153 # error Definition of OpenGLGraphicsDeviceContext required
154 #endif
155 
156 } // namespace gfx
157 } // namespace sdk
158 
159 #include <base/inc/sdk_poppack.h>
160 
161 #endif // SDK_OS_SPECIFIC_TYPES_H_
base_types.h
SDK base types.
platform.h
Describes the platform constants.