branches/osd/src/lib/bgfx/glcontext_egl.cpp
| r31763 | r31764 | |
| 5 | 5 | |
| 6 | 6 | #include "bgfx_p.h" |
| 7 | 7 | |
| 8 | | #if (BGFX_CONFIG_RENDERER_OPENGLES|BGFX_CONFIG_RENDERER_OPENGL) |
| 8 | #if (BGFX_CONFIG_RENDERER_OPENGLES || BGFX_CONFIG_RENDERER_OPENGL) |
| 9 | 9 | # include "renderer_gl.h" |
| 10 | 10 | |
| 11 | 11 | # if BGFX_USE_EGL |
| 12 | 12 | |
| 13 | # if BX_PLATFORM_RPI |
| 14 | # include <bcm_host.h> |
| 15 | # endif // BX_PLATFORM_RPI |
| 16 | |
| 13 | 17 | #ifndef EGL_CONTEXT_MAJOR_VERSION_KHR |
| 14 | 18 | # define EGL_CONTEXT_MAJOR_VERSION_KHR EGL_CONTEXT_CLIENT_VERSION |
| 15 | 19 | #endif // EGL_CONTEXT_MAJOR_VERSION_KHR |
| r31763 | r31764 | |
| 94 | 98 | # define GL_IMPORT(_optional, _proto, _func, _import) _proto _func = NULL |
| 95 | 99 | # include "glimports.h" |
| 96 | 100 | |
| 101 | # if BX_PLATFORM_RPI |
| 102 | static EGL_DISPMANX_WINDOW_T s_dispmanWindow; |
| 103 | |
| 104 | void x11SetDisplayWindow(::Display* _display, ::Window _window) |
| 105 | { |
| 106 | // Noop for now... |
| 107 | BX_UNUSED(_display, _window); |
| 108 | } |
| 109 | # endif // BX_PLATFORM_RPI |
| 110 | |
| 97 | 111 | void GlContext::create(uint32_t _width, uint32_t _height) |
| 98 | 112 | { |
| 113 | # if BX_PLATFORM_RPI |
| 114 | bcm_host_init(); |
| 115 | # endif // BX_PLATFORM_RPI |
| 116 | |
| 99 | 117 | m_eglLibrary = eglOpen(); |
| 100 | 118 | |
| 101 | 119 | BX_UNUSED(_width, _height); |
| r31763 | r31764 | |
| 137 | 155 | eglGetConfigAttrib(m_display, config, EGL_NATIVE_VISUAL_ID, &format); |
| 138 | 156 | ANativeWindow_setBuffersGeometry(g_bgfxAndroidWindow, _width, _height, format); |
| 139 | 157 | nwt = g_bgfxAndroidWindow; |
| 158 | # elif BX_PLATFORM_RPI |
| 159 | DISPMANX_DISPLAY_HANDLE_T dispmanDisplay = vc_dispmanx_display_open(0); |
| 160 | DISPMANX_UPDATE_HANDLE_T dispmanUpdate = vc_dispmanx_update_start(0); |
| 161 | |
| 162 | VC_RECT_T dstRect = { 0, 0, _width, _height }; |
| 163 | VC_RECT_T srcRect = { 0, 0, _width << 16, _height << 16 }; |
| 164 | |
| 165 | DISPMANX_ELEMENT_HANDLE_T dispmanElement = vc_dispmanx_element_add(dispmanUpdate |
| 166 | , dispmanDisplay |
| 167 | , 0 |
| 168 | , &dstRect |
| 169 | , 0 |
| 170 | , &srcRect |
| 171 | , DISPMANX_PROTECTION_NONE |
| 172 | , NULL |
| 173 | , NULL |
| 174 | , DISPMANX_NO_ROTATE |
| 175 | ); |
| 176 | |
| 177 | s_dispmanWindow.element = dispmanElement; |
| 178 | s_dispmanWindow.width = _width; |
| 179 | s_dispmanWindow.height = _height; |
| 180 | nwt = &s_dispmanWindow; |
| 181 | |
| 182 | vc_dispmanx_update_submit_sync(dispmanUpdate); |
| 140 | 183 | # endif // BX_PLATFORM_ANDROID |
| 141 | 184 | |
| 142 | 185 | m_surface = eglCreateWindowSurface(m_display, config, nwt, NULL); |
| r31763 | r31764 | |
| 183 | 226 | m_context = NULL; |
| 184 | 227 | |
| 185 | 228 | eglClose(m_eglLibrary); |
| 229 | |
| 230 | # if BX_PLATFORM_RPI |
| 231 | bcm_host_deinit(); |
| 232 | # endif // BX_PLATFORM_RPI |
| 186 | 233 | } |
| 187 | 234 | |
| 188 | 235 | void GlContext::resize(uint32_t /*_width*/, uint32_t /*_height*/, bool _vsync) |
| r31763 | r31764 | |
| 227 | 274 | } // namespace bgfx |
| 228 | 275 | |
| 229 | 276 | # endif // BGFX_USE_EGL |
| 230 | | #endif // (BGFX_CONFIG_RENDERER_OPENGLES|BGFX_CONFIG_RENDERER_OPENGL) |
| 277 | #endif // (BGFX_CONFIG_RENDERER_OPENGLES || BGFX_CONFIG_RENDERER_OPENGL) |
branches/osd/src/lib/bgfx/common/entry/entry_ios.mm
| r31763 | r31764 | |
| 65 | 65 | chdir(path); |
| 66 | 66 | } |
| 67 | 67 | CFRelease(resourcesURL); |
| 68 | | |
| 68 | |
| 69 | 69 | MainThreadEntry* self = (MainThreadEntry*)_userData; |
| 70 | 70 | int32_t result = main(self->m_argc, self->m_argv); |
| 71 | 71 | return result; |
| r31763 | r31764 | |
| 140 | 140 | m_displayLink = [self.window.screen displayLinkWithTarget:self selector:@selector(renderFrame)]; |
| 141 | 141 | //[m_displayLink setFrameInterval:1]; |
| 142 | 142 | //[m_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; |
| 143 | | // [m_displayLink addToRunLoop:[NSRunLoop currentRunLoop]]; |
| 143 | // [m_displayLink addToRunLoop:[NSRunLoop currentRunLoop]]; |
| 144 | 144 | [m_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; |
| 145 | 145 | } |
| 146 | 146 | } |
| r31763 | r31764 | |
| 161 | 161 | |
| 162 | 162 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event |
| 163 | 163 | { |
| 164 | | UITouch *touch = [[event allTouches] anyObject]; |
| 165 | | CGPoint touchLocation = [touch locationInView:self]; |
| 166 | | |
| 167 | | s_ctx->m_eventQueue.postMouseEvent(touchLocation.x, touchLocation.y); |
| 168 | | s_ctx->m_eventQueue.postMouseEvent(touchLocation.x, touchLocation.y, MouseButton::Left, true); |
| 164 | BX_UNUSED(touches); |
| 165 | UITouch *touch = [[event allTouches] anyObject]; |
| 166 | CGPoint touchLocation = [touch locationInView:self]; |
| 167 | |
| 168 | s_ctx->m_eventQueue.postMouseEvent(touchLocation.x, touchLocation.y, 0); |
| 169 | s_ctx->m_eventQueue.postMouseEvent(touchLocation.x, touchLocation.y, 0, MouseButton::Left, true); |
| 169 | 170 | } |
| 170 | 171 | |
| 171 | 172 | - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event |
| 172 | 173 | { |
| 173 | | UITouch *touch = [[event allTouches] anyObject]; |
| 174 | | CGPoint touchLocation = [touch locationInView:self]; |
| 175 | | s_ctx->m_eventQueue.postMouseEvent(touchLocation.x, touchLocation.y, MouseButton::Left, false); |
| 174 | BX_UNUSED(touches); |
| 175 | UITouch *touch = [[event allTouches] anyObject]; |
| 176 | CGPoint touchLocation = [touch locationInView:self]; |
| 177 | s_ctx->m_eventQueue.postMouseEvent(touchLocation.x, touchLocation.y, 0, MouseButton::Left, false); |
| 176 | 178 | } |
| 177 | 179 | |
| 178 | 180 | - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event |
| 179 | 181 | { |
| 180 | | UITouch *touch = [[event allTouches] anyObject]; |
| 181 | | CGPoint touchLocation = [touch locationInView:self]; |
| 182 | | s_ctx->m_eventQueue.postMouseEvent(touchLocation.x, touchLocation.y); |
| 182 | BX_UNUSED(touches); |
| 183 | UITouch *touch = [[event allTouches] anyObject]; |
| 184 | CGPoint touchLocation = [touch locationInView:self]; |
| 185 | s_ctx->m_eventQueue.postMouseEvent(touchLocation.x, touchLocation.y, 0); |
| 183 | 186 | } |
| 184 | 187 | |
| 185 | 188 | - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event |
| 186 | 189 | { |
| 187 | | UITouch *touch = [[event allTouches] anyObject]; |
| 188 | | CGPoint touchLocation = [touch locationInView:self]; |
| 189 | | s_ctx->m_eventQueue.postMouseEvent(touchLocation.x, touchLocation.y, MouseButton::Left, false); |
| 190 | BX_UNUSED(touches); |
| 191 | UITouch *touch = [[event allTouches] anyObject]; |
| 192 | CGPoint touchLocation = [touch locationInView:self]; |
| 193 | s_ctx->m_eventQueue.postMouseEvent(touchLocation.x, touchLocation.y, 0, MouseButton::Left, false); |
| 190 | 194 | } |
| 191 | 195 | |
| 192 | 196 | @end |
| r31763 | r31764 | |
| 217 | 221 | |
| 218 | 222 | [m_window addSubview: m_view]; |
| 219 | 223 | [m_window makeKeyAndVisible]; |
| 220 | | |
| 221 | | //float scaleFactor = [[UIScreen mainScreen] scale]; // should use this, but ui is too small on ipad retina |
| 222 | | float scaleFactor = 1.0f; |
| 223 | | [m_view setContentScaleFactor: scaleFactor ]; |
| 224 | 224 | |
| 225 | //float scaleFactor = [[UIScreen mainScreen] scale]; // should use this, but ui is too small on ipad retina |
| 226 | float scaleFactor = 1.0f; |
| 227 | [m_view setContentScaleFactor: scaleFactor ]; |
| 228 | |
| 225 | 229 | s_ctx = new Context((uint32_t)(scaleFactor*rect.size.width), (uint32_t)(scaleFactor*rect.size.height)); |
| 226 | 230 | return YES; |
| 227 | 231 | } |
branches/osd/src/lib/bgfx/common/entry/entry_x11.cpp
| r0 | r31764 | |
| 1 | /* |
| 2 | * Copyright 2011-2014 Branimir Karadzic. All rights reserved. |
| 3 | * License: http://www.opensource.org/licenses/BSD-2-Clause |
| 4 | */ |
| 5 | |
| 6 | #include "entry_p.h" |
| 7 | |
| 8 | #if ENTRY_CONFIG_USE_NATIVE && (BX_PLATFORM_FREEBSD || BX_PLATFORM_LINUX || BX_PLATFORM_RPI) |
| 9 | |
| 10 | #define XK_MISCELLANY |
| 11 | #define XK_LATIN1 |
| 12 | #include <X11/keysymdef.h> |
| 13 | #include <bgfxplatform.h> // will include X11 which #defines None... Don't mess with order of includes. |
| 14 | |
| 15 | #undef None |
| 16 | #include <bx/thread.h> |
| 17 | #include <bx/os.h> |
| 18 | #include <string.h> // memset |
| 19 | |
| 20 | namespace entry |
| 21 | { |
| 22 | static uint8_t s_translateKey[512]; |
| 23 | |
| 24 | static void initTranslateKey(uint16_t _xk, Key::Enum _key) |
| 25 | { |
| 26 | _xk += 256; |
| 27 | BX_CHECK(_xk < BX_COUNTOF(s_translateKey), "Out of bounds %d.", _xk); |
| 28 | s_translateKey[_xk&0x1ff] = (uint8_t)_key; |
| 29 | } |
| 30 | |
| 31 | Key::Enum fromXk(uint16_t _xk) |
| 32 | { |
| 33 | _xk += 256; |
| 34 | return 512 > _xk ? (Key::Enum)s_translateKey[_xk] : Key::None; |
| 35 | } |
| 36 | |
| 37 | struct MainThreadEntry |
| 38 | { |
| 39 | int m_argc; |
| 40 | char** m_argv; |
| 41 | |
| 42 | static int32_t threadFunc(void* _userData); |
| 43 | }; |
| 44 | |
| 45 | struct Context |
| 46 | { |
| 47 | Context() |
| 48 | : m_modifiers(Modifier::None) |
| 49 | , m_exit(false) |
| 50 | { |
| 51 | memset(s_translateKey, 0, sizeof(s_translateKey) ); |
| 52 | initTranslateKey(XK_Escape, Key::Esc); |
| 53 | initTranslateKey(XK_Return, Key::Return); |
| 54 | initTranslateKey(XK_Tab, Key::Tab); |
| 55 | initTranslateKey(XK_BackSpace, Key::Backspace); |
| 56 | initTranslateKey(XK_space, Key::Space); |
| 57 | initTranslateKey(XK_Up, Key::Up); |
| 58 | initTranslateKey(XK_Down, Key::Down); |
| 59 | initTranslateKey(XK_Left, Key::Left); |
| 60 | initTranslateKey(XK_Right, Key::Right); |
| 61 | initTranslateKey(XK_Page_Up, Key::PageUp); |
| 62 | initTranslateKey(XK_Page_Down, Key::PageUp); |
| 63 | initTranslateKey(XK_Home, Key::Home); |
| 64 | initTranslateKey(XK_KP_End, Key::End); |
| 65 | initTranslateKey(XK_Print, Key::Print); |
| 66 | initTranslateKey(XK_equal, Key::Plus); |
| 67 | initTranslateKey(XK_minus, Key::Minus); |
| 68 | initTranslateKey(XK_F1, Key::F1); |
| 69 | initTranslateKey(XK_F2, Key::F2); |
| 70 | initTranslateKey(XK_F3, Key::F3); |
| 71 | initTranslateKey(XK_F4, Key::F4); |
| 72 | initTranslateKey(XK_F5, Key::F5); |
| 73 | initTranslateKey(XK_F6, Key::F6); |
| 74 | initTranslateKey(XK_F7, Key::F7); |
| 75 | initTranslateKey(XK_F8, Key::F8); |
| 76 | initTranslateKey(XK_F9, Key::F9); |
| 77 | initTranslateKey(XK_F10, Key::F10); |
| 78 | initTranslateKey(XK_F11, Key::F11); |
| 79 | initTranslateKey(XK_F12, Key::F12); |
| 80 | initTranslateKey(XK_KP_Insert, Key::NumPad0); |
| 81 | initTranslateKey(XK_KP_End, Key::NumPad1); |
| 82 | initTranslateKey(XK_KP_Down, Key::NumPad2); |
| 83 | initTranslateKey(XK_KP_Page_Down, Key::NumPad3); |
| 84 | initTranslateKey(XK_KP_Left, Key::NumPad4); |
| 85 | initTranslateKey(XK_KP_Begin, Key::NumPad5); |
| 86 | initTranslateKey(XK_KP_Right, Key::NumPad6); |
| 87 | initTranslateKey(XK_KP_Home, Key::NumPad7); |
| 88 | initTranslateKey(XK_KP_Up, Key::NumPad8); |
| 89 | initTranslateKey(XK_KP_Page_Up, Key::NumPad9); |
| 90 | initTranslateKey('0', Key::Key0); |
| 91 | initTranslateKey('1', Key::Key1); |
| 92 | initTranslateKey('2', Key::Key2); |
| 93 | initTranslateKey('3', Key::Key3); |
| 94 | initTranslateKey('4', Key::Key4); |
| 95 | initTranslateKey('5', Key::Key5); |
| 96 | initTranslateKey('6', Key::Key6); |
| 97 | initTranslateKey('7', Key::Key7); |
| 98 | initTranslateKey('8', Key::Key8); |
| 99 | initTranslateKey('9', Key::Key9); |
| 100 | initTranslateKey('a', Key::KeyA); |
| 101 | initTranslateKey('b', Key::KeyB); |
| 102 | initTranslateKey('c', Key::KeyC); |
| 103 | initTranslateKey('d', Key::KeyD); |
| 104 | initTranslateKey('e', Key::KeyE); |
| 105 | initTranslateKey('f', Key::KeyF); |
| 106 | initTranslateKey('g', Key::KeyG); |
| 107 | initTranslateKey('h', Key::KeyH); |
| 108 | initTranslateKey('i', Key::KeyI); |
| 109 | initTranslateKey('j', Key::KeyJ); |
| 110 | initTranslateKey('k', Key::KeyK); |
| 111 | initTranslateKey('l', Key::KeyL); |
| 112 | initTranslateKey('m', Key::KeyM); |
| 113 | initTranslateKey('n', Key::KeyN); |
| 114 | initTranslateKey('o', Key::KeyO); |
| 115 | initTranslateKey('p', Key::KeyP); |
| 116 | initTranslateKey('q', Key::KeyQ); |
| 117 | initTranslateKey('r', Key::KeyR); |
| 118 | initTranslateKey('s', Key::KeyS); |
| 119 | initTranslateKey('t', Key::KeyT); |
| 120 | initTranslateKey('u', Key::KeyU); |
| 121 | initTranslateKey('v', Key::KeyV); |
| 122 | initTranslateKey('w', Key::KeyW); |
| 123 | initTranslateKey('x', Key::KeyX); |
| 124 | initTranslateKey('y', Key::KeyY); |
| 125 | initTranslateKey('z', Key::KeyZ); |
| 126 | } |
| 127 | |
| 128 | int32_t run(int _argc, char** _argv) |
| 129 | { |
| 130 | XInitThreads(); |
| 131 | m_display = XOpenDisplay(0); |
| 132 | |
| 133 | int32_t screen = DefaultScreen(m_display); |
| 134 | int32_t depth = DefaultDepth(m_display, screen); |
| 135 | Visual* visual = DefaultVisual(m_display, screen); |
| 136 | Window root = RootWindow(m_display, screen); |
| 137 | |
| 138 | XSetWindowAttributes windowAttrs; |
| 139 | memset(&windowAttrs, 0, sizeof(windowAttrs) ); |
| 140 | windowAttrs.background_pixmap = 0; |
| 141 | windowAttrs.border_pixel = 0; |
| 142 | windowAttrs.event_mask = 0 |
| 143 | | ButtonPressMask |
| 144 | | ButtonReleaseMask |
| 145 | | ExposureMask |
| 146 | | KeyPressMask |
| 147 | | KeyReleaseMask |
| 148 | | PointerMotionMask |
| 149 | | ResizeRedirectMask |
| 150 | | StructureNotifyMask |
| 151 | ; |
| 152 | |
| 153 | m_window = XCreateWindow(m_display |
| 154 | , root |
| 155 | , 0, 0 |
| 156 | , ENTRY_DEFAULT_WIDTH, ENTRY_DEFAULT_HEIGHT, 0, depth |
| 157 | , InputOutput |
| 158 | , visual |
| 159 | , CWBorderPixel|CWEventMask |
| 160 | , &windowAttrs |
| 161 | ); |
| 162 | |
| 163 | const char *wmDeleteWindowName = "WM_DELETE_WINDOW"; |
| 164 | Atom wmDeleteWindow; |
| 165 | XInternAtoms(m_display, (char **)&wmDeleteWindowName, 1, False, &wmDeleteWindow); |
| 166 | XSetWMProtocols(m_display, m_window, &wmDeleteWindow, 1); |
| 167 | |
| 168 | XMapWindow(m_display, m_window); |
| 169 | XStoreName(m_display, m_window, "BGFX"); |
| 170 | |
| 171 | bgfx::x11SetDisplayWindow(m_display, m_window); |
| 172 | |
| 173 | MainThreadEntry mte; |
| 174 | mte.m_argc = _argc; |
| 175 | mte.m_argv = _argv; |
| 176 | |
| 177 | bx::Thread thread; |
| 178 | thread.init(mte.threadFunc, &mte); |
| 179 | |
| 180 | while (!m_exit) |
| 181 | { |
| 182 | if (XPending(m_display) ) |
| 183 | { |
| 184 | XEvent event; |
| 185 | XNextEvent(m_display, &event); |
| 186 | |
| 187 | switch (event.type) |
| 188 | { |
| 189 | case Expose: |
| 190 | break; |
| 191 | |
| 192 | case ConfigureNotify: |
| 193 | break; |
| 194 | |
| 195 | case ClientMessage: |
| 196 | if((Atom)event.xclient.data.l[0] == wmDeleteWindow) |
| 197 | { |
| 198 | m_eventQueue.postExitEvent(); |
| 199 | } |
| 200 | break; |
| 201 | |
| 202 | case ButtonPress: |
| 203 | case ButtonRelease: |
| 204 | { |
| 205 | const XButtonEvent& xbutton = event.xbutton; |
| 206 | MouseButton::Enum mb; |
| 207 | switch (xbutton.button) |
| 208 | { |
| 209 | case Button1: mb = MouseButton::Left; break; |
| 210 | case Button2: mb = MouseButton::Middle; break; |
| 211 | case Button3: mb = MouseButton::Right; break; |
| 212 | default: mb = MouseButton::None; break; |
| 213 | } |
| 214 | |
| 215 | if (MouseButton::None != mb) |
| 216 | { |
| 217 | m_eventQueue.postMouseEvent(xbutton.x |
| 218 | , xbutton.y |
| 219 | , 0 |
| 220 | , mb |
| 221 | , event.type == ButtonPress |
| 222 | ); |
| 223 | } |
| 224 | } |
| 225 | break; |
| 226 | |
| 227 | case MotionNotify: |
| 228 | { |
| 229 | const XMotionEvent& xmotion = event.xmotion; |
| 230 | m_eventQueue.postMouseEvent(xmotion.x |
| 231 | , xmotion.y |
| 232 | , 0 |
| 233 | ); |
| 234 | } |
| 235 | break; |
| 236 | |
| 237 | case KeyPress: |
| 238 | case KeyRelease: |
| 239 | { |
| 240 | XKeyEvent& xkey = event.xkey; |
| 241 | KeySym keysym = XLookupKeysym(&xkey, 0); |
| 242 | switch (keysym) |
| 243 | { |
| 244 | case XK_Meta_L: setModifier(Modifier::LeftMeta, KeyPress == event.type); break; |
| 245 | case XK_Meta_R: setModifier(Modifier::RightMeta, KeyPress == event.type); break; |
| 246 | case XK_Control_L: setModifier(Modifier::LeftCtrl, KeyPress == event.type); break; |
| 247 | case XK_Control_R: setModifier(Modifier::RightCtrl, KeyPress == event.type); break; |
| 248 | case XK_Shift_L: setModifier(Modifier::LeftShift, KeyPress == event.type); break; |
| 249 | case XK_Shift_R: setModifier(Modifier::RightShift, KeyPress == event.type); break; |
| 250 | case XK_Alt_L: setModifier(Modifier::LeftAlt, KeyPress == event.type); break; |
| 251 | case XK_Alt_R: setModifier(Modifier::RightAlt, KeyPress == event.type); break; |
| 252 | |
| 253 | default: |
| 254 | { |
| 255 | Key::Enum key = fromXk(keysym); |
| 256 | if (Key::None != key) |
| 257 | { |
| 258 | m_eventQueue.postKeyEvent(key, m_modifiers, KeyPress == event.type); |
| 259 | } |
| 260 | } |
| 261 | break; |
| 262 | } |
| 263 | } |
| 264 | break; |
| 265 | |
| 266 | case ResizeRequest: |
| 267 | { |
| 268 | const XResizeRequestEvent& xresize = event.xresizerequest; |
| 269 | XResizeWindow(m_display, m_window, xresize.width, xresize.height); |
| 270 | } |
| 271 | break; |
| 272 | } |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | thread.shutdown(); |
| 277 | |
| 278 | XUnmapWindow(m_display, m_window); |
| 279 | XDestroyWindow(m_display, m_window); |
| 280 | |
| 281 | return EXIT_SUCCESS; |
| 282 | } |
| 283 | |
| 284 | void setModifier(Modifier::Enum _modifier, bool _set) |
| 285 | { |
| 286 | m_modifiers &= ~_modifier; |
| 287 | m_modifiers |= _set ? _modifier : 0; |
| 288 | } |
| 289 | |
| 290 | uint8_t m_modifiers; |
| 291 | Display* m_display; |
| 292 | Window m_window; |
| 293 | bool m_exit; |
| 294 | |
| 295 | EventQueue m_eventQueue; |
| 296 | }; |
| 297 | |
| 298 | static Context s_ctx; |
| 299 | |
| 300 | int32_t MainThreadEntry::threadFunc(void* _userData) |
| 301 | { |
| 302 | MainThreadEntry* self = (MainThreadEntry*)_userData; |
| 303 | int32_t result = main(self->m_argc, self->m_argv); |
| 304 | s_ctx.m_exit = true; |
| 305 | return result; |
| 306 | } |
| 307 | |
| 308 | const Event* poll() |
| 309 | { |
| 310 | return s_ctx.m_eventQueue.poll(); |
| 311 | } |
| 312 | |
| 313 | void release(const Event* _event) |
| 314 | { |
| 315 | s_ctx.m_eventQueue.release(_event); |
| 316 | } |
| 317 | |
| 318 | void setWindowSize(uint32_t _width, uint32_t _height) |
| 319 | { |
| 320 | XResizeRequestEvent ev; |
| 321 | ev.type = ResizeRequest; |
| 322 | ev.serial = 0; |
| 323 | ev.send_event = true; |
| 324 | ev.display = s_ctx.m_display; |
| 325 | ev.window = s_ctx.m_window; |
| 326 | ev.width = (int)_width; |
| 327 | ev.height = (int)_height; |
| 328 | XSendEvent(s_ctx.m_display, s_ctx.m_window, false, ResizeRedirectMask, (XEvent*)&ev); |
| 329 | } |
| 330 | |
| 331 | void setWindowTitle(const char* _title) |
| 332 | { |
| 333 | BX_UNUSED(_title); |
| 334 | } |
| 335 | |
| 336 | void toggleWindowFrame() |
| 337 | { |
| 338 | } |
| 339 | |
| 340 | void setMouseLock(bool _lock) |
| 341 | { |
| 342 | BX_UNUSED(_lock); |
| 343 | } |
| 344 | |
| 345 | } // namespace entry |
| 346 | |
| 347 | int main(int _argc, char** _argv) |
| 348 | { |
| 349 | using namespace entry; |
| 350 | return s_ctx.run(_argc, _argv); |
| 351 | } |
| 352 | |
| 353 | #endif // ENTRY_CONFIG_USE_NATIVE && (BX_PLATFORM_FREEBSD || BX_PLATFORM_LINUX || BX_PLATFORM_RPI) |