1 #ifndef B3_USE_GLFW
2 #ifdef __APPLE__
3
4 #include "MacOpenGLWindow.h"
5
6 #include "OpenGLInclude.h"
7 #include "MacOpenGLWindowObjC.h"
8
9 #include <stdlib.h>
10 #include <stdio.h>
11 #include <stddef.h>
12 #include <string.h>
13
MacOpenGLWindow()14 MacOpenGLWindow::MacOpenGLWindow()
15 : m_internalData(0)
16 {
17 m_internalData = Mac_createData();
18 }
19
~MacOpenGLWindow()20 MacOpenGLWindow::~MacOpenGLWindow()
21 {
22 Mac_destroyData(m_internalData);
23 }
24
closeWindow()25 void MacOpenGLWindow::closeWindow()
26 {
27 Mac_destroyData(m_internalData);
28 m_internalData = Mac_createData();
29 }
30
isModifierKeyPressed(int key)31 bool MacOpenGLWindow::isModifierKeyPressed(int key)
32 {
33 return Mac_isModifierKeyPressed(m_internalData, key);
34 }
35
getTimeInSeconds()36 float MacOpenGLWindow::getTimeInSeconds()
37 {
38 return 0.f;
39 }
40
setRenderCallback(b3RenderCallback renderCallback)41 void MacOpenGLWindow::setRenderCallback(b3RenderCallback renderCallback)
42 {
43 }
44
setWindowTitle(const char * windowTitle)45 void MacOpenGLWindow::setWindowTitle(const char* windowTitle)
46 {
47 Mac_setWindowTitle(m_internalData, windowTitle);
48 }
49
createWindow(const b3gWindowConstructionInfo & ci)50 void MacOpenGLWindow::createWindow(const b3gWindowConstructionInfo& ci)
51 {
52 MacWindowConstructionInfo windowCI;
53 windowCI.m_width = ci.m_width;
54 windowCI.m_height = ci.m_height;
55 windowCI.m_fullscreen = ci.m_fullscreen;
56 windowCI.m_colorBitsPerPixel = ci.m_colorBitsPerPixel;
57 windowCI.m_windowHandle = ci.m_windowHandle;
58 windowCI.m_title = ci.m_title;
59 windowCI.m_openglVersion = ci.m_openglVersion;
60 windowCI.m_allowRetina = true;
61
62 Mac_createWindow(m_internalData, &windowCI);
63 }
64
runMainLoop()65 void MacOpenGLWindow::runMainLoop()
66 {
67 }
68
startRendering()69 void MacOpenGLWindow::startRendering()
70 {
71 Mac_updateWindow(m_internalData);
72 }
73
endRendering()74 void MacOpenGLWindow::endRendering()
75 {
76 Mac_swapBuffer(m_internalData);
77 }
78
requestedExit() const79 bool MacOpenGLWindow::requestedExit() const
80 {
81 return Mac_requestedExit(m_internalData);
82 }
83
setRequestExit()84 void MacOpenGLWindow::setRequestExit()
85 {
86 Mac_setRequestExit(m_internalData);
87 }
88
fileOpenDialog(char * filename,int maxNameLength)89 int MacOpenGLWindow::fileOpenDialog(char* filename, int maxNameLength)
90 {
91 return Mac_fileOpenDialog(filename, maxNameLength);
92 }
93
getMouseCoordinates(int & x,int & y)94 void MacOpenGLWindow::getMouseCoordinates(int& x, int& y)
95 {
96 int* xPtr = &x;
97 int* yPtr = &y;
98
99 Mac_getMouseCoordinates(m_internalData, xPtr, yPtr);
100 }
101
getWidth() const102 int MacOpenGLWindow::getWidth() const
103 {
104 return Mac_getWidth(m_internalData);
105 }
106
getHeight() const107 int MacOpenGLWindow::getHeight() const
108 {
109 return Mac_getHeight(m_internalData);
110 }
111
setResizeCallback(b3ResizeCallback resizeCallback)112 void MacOpenGLWindow::setResizeCallback(b3ResizeCallback resizeCallback)
113 {
114 Mac_setResizeCallback(m_internalData, resizeCallback);
115 }
116
getResizeCallback()117 b3ResizeCallback MacOpenGLWindow::getResizeCallback()
118 {
119 return Mac_getResizeCallback(m_internalData);
120 }
121
setMouseButtonCallback(b3MouseButtonCallback mouseCallback)122 void MacOpenGLWindow::setMouseButtonCallback(b3MouseButtonCallback mouseCallback)
123 {
124 Mac_setMouseButtonCallback(m_internalData, mouseCallback);
125 }
126
setMouseMoveCallback(b3MouseMoveCallback mouseCallback)127 void MacOpenGLWindow::setMouseMoveCallback(b3MouseMoveCallback mouseCallback)
128 {
129 Mac_setMouseMoveCallback(m_internalData, mouseCallback);
130 }
131
setKeyboardCallback(b3KeyboardCallback keyboardCallback)132 void MacOpenGLWindow::setKeyboardCallback(b3KeyboardCallback keyboardCallback)
133 {
134 Mac_setKeyboardCallback(m_internalData, keyboardCallback);
135 }
136
getMouseMoveCallback()137 b3MouseMoveCallback MacOpenGLWindow::getMouseMoveCallback()
138 {
139 return Mac_getMouseMoveCallback(m_internalData);
140 }
141
getMouseButtonCallback()142 b3MouseButtonCallback MacOpenGLWindow::getMouseButtonCallback()
143 {
144 return Mac_getMouseButtonCallback(m_internalData);
145 }
146
setWheelCallback(b3WheelCallback wheelCallback)147 void MacOpenGLWindow::setWheelCallback(b3WheelCallback wheelCallback)
148 {
149 Mac_setWheelCallback(m_internalData, wheelCallback);
150 }
151
getWheelCallback()152 b3WheelCallback MacOpenGLWindow::getWheelCallback()
153 {
154 return Mac_getWheelCallback(m_internalData);
155 }
156
getKeyboardCallback()157 b3KeyboardCallback MacOpenGLWindow::getKeyboardCallback()
158 {
159 return Mac_getKeyboardCallback(m_internalData);
160 }
161
getRetinaScale() const162 float MacOpenGLWindow::getRetinaScale() const
163 {
164 return Mac_getRetinaScale(m_internalData);
165 }
166
setAllowRetina(bool allow)167 void MacOpenGLWindow::setAllowRetina(bool allow)
168 {
169 Mac_setAllowRetina(m_internalData, allow);
170 }
171
172 #endif //__APPLE__
173 #endif //B3_USE_GLFW
174