Browse Source

QNX: Use the common EGL code. (#16303)

eleir9268 5 days ago
parent
commit
23b9968037

+ 9 - 0
src/filesystem/unix/SDL_sysfilesystem.c

@@ -42,6 +42,10 @@
 #include <sys/sysctl.h>
 #include <sys/sysctl.h>
 #endif
 #endif
 
 
+#if defined(SDL_PLATFORM_QNXNTO)
+#include <process.h>
+#endif
+
 static char *readSymLink(const char *path)
 static char *readSymLink(const char *path)
 {
 {
     char *result = NULL;
     char *result = NULL;
@@ -216,6 +220,11 @@ static char *GetExePath(void)
         result = readSymLink("/proc/curproc/exe");
         result = readSymLink("/proc/curproc/exe");
 #elif defined(SDL_PLATFORM_SOLARIS)
 #elif defined(SDL_PLATFORM_SOLARIS)
         result = readSymLink("/proc/self/path/a.out");
         result = readSymLink("/proc/self/path/a.out");
+#elif defined(SDL_PLATFORM_QNXNTO)
+        char exe_path[PATH_MAX];
+        if (_cmdname(exe_path) != NULL) {
+            result = SDL_strdup(exe_path);
+        }
 #else
 #else
         result = readSymLink("/proc/self/exe"); // linux.
         result = readSymLink("/proc/self/exe"); // linux.
         if (!result) {
         if (!result) {

+ 15 - 0
src/video/SDL_egl.c

@@ -29,6 +29,10 @@
 #include <android/native_window.h>
 #include <android/native_window.h>
 #include "../video/android/SDL_androidvideo.h"
 #include "../video/android/SDL_androidvideo.h"
 #endif
 #endif
+#ifdef SDL_VIDEO_DRIVER_QNX
+#include <screen/screen.h>
+#include "../video/qnx/SDL_qnx.h"
+#endif
 #ifdef SDL_VIDEO_DRIVER_RPI
 #ifdef SDL_VIDEO_DRIVER_RPI
 #include <unistd.h>
 #include <unistd.h>
 #endif
 #endif
@@ -1292,6 +1296,17 @@ EGLSurface SDL_EGL_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, Nat
     ANativeWindow_setBuffersGeometry(nw, 0, 0, format_wanted);
     ANativeWindow_setBuffersGeometry(nw, 0, 0, format_wanted);
 #endif
 #endif
 
 
+#ifdef SDL_VIDEO_DRIVER_QNX
+    // Wayland is also a supported platform on QNX, so we need to be specific.
+    if (SDL_strcmp(_this->name, "qnx") == 0) {
+        int format = QNX_ChooseFormat(_this, _this->egl_data->egl_config);
+
+        if (screen_set_window_property_iv(nw, SCREEN_PROPERTY_FORMAT, &format) < 0) {
+            return EGL_NO_SURFACE;
+        }
+    }
+#endif
+
 #ifdef EGL_KHR_gl_colorspace
 #ifdef EGL_KHR_gl_colorspace
     if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_gl_colorspace")) {
     if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_gl_colorspace")) {
         const char *srgbhint = SDL_GetHint(SDL_HINT_OPENGL_FORCE_SRGB_FRAMEBUFFER);
         const char *srgbhint = SDL_GetHint(SDL_HINT_OPENGL_FORCE_SRGB_FRAMEBUFFER);

+ 17 - 15
src/video/qnx/SDL_qnx.h

@@ -40,10 +40,9 @@ typedef struct SDL_DisplayModeData
 typedef struct SDL_WindowData
 typedef struct SDL_WindowData
 {
 {
     screen_window_t window;
     screen_window_t window;
-    EGLSurface      surface;
-    EGLConfig       conf;
+    EGLSurface      egl_surface;
     SDL_GLContext   context;
     SDL_GLContext   context;
-    int             resize;
+    bool            resize;
     bool            has_focus;
     bool            has_focus;
 } SDL_WindowData;
 } SDL_WindowData;
 
 
@@ -66,22 +65,25 @@ extern screen_event_t * getEvent();
 extern void handleKeyboardEvent(screen_event_t event);
 extern void handleKeyboardEvent(screen_event_t event);
 extern void handlePointerEvent(screen_event_t event);
 extern void handlePointerEvent(screen_event_t event);
 
 
-extern bool glInitConfig(SDL_WindowData *impl, int *pformat);
-extern bool glLoadLibrary(SDL_VideoDevice *_this, const char *name);
-extern SDL_FunctionPointer glGetProcAddress(SDL_VideoDevice *_this, const char *proc);
-extern SDL_GLContext glCreateContext(SDL_VideoDevice *_this, SDL_Window *window);
-extern bool glSetSwapInterval(SDL_VideoDevice *_this, int interval);
-extern bool glSwapWindow(SDL_VideoDevice *_this, SDL_Window *window);
-extern bool glMakeCurrent(SDL_VideoDevice *_this, SDL_Window * window, SDL_GLContext context);
-extern bool glDeleteContext(SDL_VideoDevice *_this, SDL_GLContext context);
-extern void glUnloadLibrary(SDL_VideoDevice *_this);
+// extern bool glInitConfig(SDL_WindowData *impl, int *pformat);
+extern bool QNX_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *egl_path);
+extern SDL_FunctionPointer QNX_GLES_GetProcAddress(SDL_VideoDevice *_this, const char *proc);
+extern SDL_GLContext QNX_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window);
+extern bool QNX_GLES_SetSwapInterval(SDL_VideoDevice *_this, int interval);
+extern bool QNX_GLES_GetSwapInterval(SDL_VideoDevice *_this, int *interval);
+extern bool QNX_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window);
+extern bool QNX_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window * window, SDL_GLContext context);
+extern bool QNX_GLES_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context);
+extern void QNX_GLES_UnloadLibrary(SDL_VideoDevice *_this);
 
 
 extern SDL_PixelFormat screenToPixelFormat(int screen_format);
 extern SDL_PixelFormat screenToPixelFormat(int screen_format);
-extern bool getDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display);
-extern bool setDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode);
-extern bool getDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect);
+extern bool QNX_GetDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect);
+extern bool QNX_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display);
+extern bool QNX_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode);
 
 
 extern void initMouse(SDL_VideoDevice *_this);
 extern void initMouse(SDL_VideoDevice *_this);
 extern void quitMouse(SDL_VideoDevice *_this);
 extern void quitMouse(SDL_VideoDevice *_this);
 
 
+extern int QNX_ChooseFormat(SDL_VideoDevice *_this, EGLConfig egl_conf);
+
 #endif
 #endif

+ 33 - 280
src/video/qnx/SDL_qnxgl.c

@@ -22,129 +22,19 @@
 #include "SDL_internal.h"
 #include "SDL_internal.h"
 #include "SDL_qnx.h"
 #include "SDL_qnx.h"
 
 
-static EGLDisplay   egl_disp;
-
-struct DummyConfig
-{
-    int red_size;
-    int green_size;
-    int blue_size;
-    int alpha_size;
-    int native_id;
-};
-
-static struct DummyConfig getDummyConfigFromScreenSettings(int format)
-{
-    struct DummyConfig dummyConfig= {};
-
-    dummyConfig.native_id = format;
-    switch (format) {
-         case SCREEN_FORMAT_RGBX4444:
-            dummyConfig.red_size = 4;
-            dummyConfig.green_size = 4;
-            dummyConfig.blue_size = 4;
-            dummyConfig.alpha_size = 4;
-            break;
-         case SCREEN_FORMAT_RGBA5551:
-            dummyConfig.red_size = 5;
-            dummyConfig.green_size = 5;
-            dummyConfig.blue_size = 5;
-            dummyConfig.alpha_size = 1;
-            break;
-         case SCREEN_FORMAT_RGB565:
-            dummyConfig.red_size = 5;
-            dummyConfig.green_size = 6;
-            dummyConfig.blue_size = 5;
-            dummyConfig.alpha_size = 0;
-            break;
-         case SCREEN_FORMAT_RGB888:
-            dummyConfig.red_size = 8;
-            dummyConfig.green_size = 8;
-            dummyConfig.blue_size = 8;
-            dummyConfig.alpha_size = 0;
-            break;
-            case SCREEN_FORMAT_BGRA8888:
-            case SCREEN_FORMAT_BGRX8888:
-            case SCREEN_FORMAT_RGBA8888:
-         case SCREEN_FORMAT_RGBX8888:
-            dummyConfig.red_size = 8;
-            dummyConfig.green_size = 8;
-            dummyConfig.blue_size = 8;
-            dummyConfig.alpha_size = 8;
-            break;
-            default:
-                break;
-    }
-    return dummyConfig;
-}
-
-static EGLConfig chooseConfig(struct DummyConfig dummyConfig, EGLConfig* egl_configs, EGLint egl_num_configs)
-{
-   EGLConfig glConfig = (EGLConfig)0;
-
-    for (size_t ii = 0; ii < egl_num_configs; ii++) {
-        EGLint val;
-
-        eglGetConfigAttrib(egl_disp, egl_configs[ii], EGL_SURFACE_TYPE, &val);
-        if (!(val & EGL_WINDOW_BIT)) {
-            continue;
-        }
-
-        eglGetConfigAttrib(egl_disp, egl_configs[ii], EGL_RENDERABLE_TYPE, &val);
-        if (!(val & EGL_OPENGL_ES2_BIT)) {
-            continue;
-        }
-
-        eglGetConfigAttrib(egl_disp, egl_configs[ii], EGL_DEPTH_SIZE, &val);
-        if (val == 0) {
-            continue;
-        }
-
-        eglGetConfigAttrib(egl_disp, egl_configs[ii], EGL_RED_SIZE, &val);
-        if (val != dummyConfig.red_size) {
-           continue;
-        }
-
-        eglGetConfigAttrib(egl_disp, egl_configs[ii], EGL_GREEN_SIZE, &val);
-        if (val != dummyConfig.green_size) {
-           continue;
-        }
-
-        eglGetConfigAttrib(egl_disp, egl_configs[ii], EGL_BLUE_SIZE, &val);
-        if (val != dummyConfig.blue_size) {
-           continue;
-        }
-
-        eglGetConfigAttrib(egl_disp, egl_configs[ii], EGL_ALPHA_SIZE, &val);
-        if (val != dummyConfig.alpha_size) {
-            continue;
-        }
-        if(!glConfig)
-        {
-            glConfig = egl_configs[ii];
-        }
-
-        eglGetConfigAttrib(egl_disp, egl_configs[ii], EGL_NATIVE_VISUAL_ID, &val);
-        if ((val != 0) && (val == dummyConfig.native_id)) {
-            return egl_configs[ii];
-        }
-    }
-    return glConfig;
-}
+#include "../SDL_egl_c.h"
 
 
 /**
 /**
  * Detertmines the pixel format to use based on the current display and EGL
  * Detertmines the pixel format to use based on the current display and EGL
  * configuration.
  * configuration.
- * @param   egl_conf    EGL configuration to use
- * @return  A SCREEN_FORMAT* constant for the pixel format to use
  */
  */
-static int chooseFormat(EGLConfig egl_conf)
+int QNX_ChooseFormat(SDL_VideoDevice *_this, EGLConfig egl_conf)
 {
 {
     EGLint buffer_bit_depth;
     EGLint buffer_bit_depth;
     EGLint alpha_bit_depth;
     EGLint alpha_bit_depth;
 
 
-    eglGetConfigAttrib(egl_disp, egl_conf, EGL_BUFFER_SIZE, &buffer_bit_depth);
-    eglGetConfigAttrib(egl_disp, egl_conf, EGL_ALPHA_SIZE, &alpha_bit_depth);
+    _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, egl_conf, EGL_BUFFER_SIZE, &buffer_bit_depth);
+    _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, egl_conf, EGL_ALPHA_SIZE, &alpha_bit_depth);
 
 
     switch (buffer_bit_depth) {
     switch (buffer_bit_depth) {
         case 32:
         case 32:
@@ -165,236 +55,99 @@ static int chooseFormat(EGLConfig egl_conf)
     }
     }
 }
 }
 
 
-/**
- * Enumerates the supported EGL configurations and chooses a suitable one.
- * @param[out]  pformat The chosen pixel format
- * @return true if successful, false on error
- */
-bool glInitConfig(SDL_WindowData *impl, int *pformat)
-{
-    EGLConfig egl_conf = (EGLConfig)0;
-    EGLConfig *egl_configs;
-    EGLint egl_num_configs;
-    EGLBoolean rc;
-    struct DummyConfig dummyconfig = {};
-
-    // Determine the number of configurations.
-    rc = eglGetConfigs(egl_disp, NULL, 0, &egl_num_configs);
-    if (rc != EGL_TRUE) {
-        return false;
-    }
-
-    if (egl_num_configs == 0) {
-        return false;
-    }
-
-    // Allocate enough memory for all configurations.
-    egl_configs = SDL_malloc(egl_num_configs * sizeof(*egl_configs));
-    if (!egl_configs) {
-        return false;
-    }
-
-    // Get the list of configurations.
-    rc = eglGetConfigs(egl_disp, egl_configs, egl_num_configs,
-                       &egl_num_configs);
-    if (rc != EGL_TRUE) {
-        SDL_free(egl_configs);
-        return false;
-    }
-
-    dummyconfig = getDummyConfigFromScreenSettings(*pformat);
-    egl_conf = chooseConfig(dummyconfig, egl_configs, egl_num_configs);
-    *pformat = chooseFormat(egl_conf);
-
-    SDL_free(egl_configs);
-    impl->conf = egl_conf;
-
-    return true;
-}
-
 /**
 /**
  * Initializes the EGL library.
  * Initializes the EGL library.
- * @param   SDL_VideoDevice *_this
- * @param   name    unused
- * @return  true if successful, false on error
  */
  */
-bool glLoadLibrary(SDL_VideoDevice *_this, const char *name)
+bool QNX_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *egl_path)
 {
 {
-    EGLNativeDisplayType    disp_id = EGL_DEFAULT_DISPLAY;
-
-    egl_disp = eglGetDisplay(disp_id);
-    if (egl_disp == EGL_NO_DISPLAY) {
-        return false;
-    }
-
-    if (eglInitialize(egl_disp, NULL, NULL) == EGL_FALSE) {
-        return false;
-    }
-
-    return true;
+    return SDL_EGL_LoadLibrary(_this, egl_path, EGL_DEFAULT_DISPLAY);
 }
 }
 
 
 /**
 /**
  * Finds the address of an EGL extension function.
  * Finds the address of an EGL extension function.
- * @param   proc    Function name
- * @return  Function address
  */
  */
-SDL_FunctionPointer glGetProcAddress(SDL_VideoDevice *_this, const char *proc)
+SDL_FunctionPointer QNX_GLES_GetProcAddress(SDL_VideoDevice *_this, const char *proc)
 {
 {
-    return eglGetProcAddress(proc);
+    return SDL_EGL_GetProcAddressInternal(_this, proc);
 }
 }
 
 
 /**
 /**
  * Associates the given window with the necessary EGL structures for drawing and
  * Associates the given window with the necessary EGL structures for drawing and
  * displaying content.
  * displaying content.
- * @param   SDL_VideoDevice *_this
- * @param   window  The SDL window to create the context for
- * @return  A pointer to the created context, if successful, NULL on error
  */
  */
-SDL_GLContext glCreateContext(SDL_VideoDevice *_this, SDL_Window *window)
+SDL_GLContext QNX_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window)
 {
 {
     SDL_WindowData   *impl = (SDL_WindowData *)window->internal;
     SDL_WindowData   *impl = (SDL_WindowData *)window->internal;
     EGLContext      context;
     EGLContext      context;
-    EGLSurface      surface;
-
-    struct {
-        EGLint client_version[2];
-        EGLint none;
-    } egl_ctx_attr = {
-        .client_version = { EGL_CONTEXT_CLIENT_VERSION, 2 },
-        .none = EGL_NONE
-    };
-
-    struct {
-        EGLint render_buffer[2];
-        EGLint none;
-    } egl_surf_attr = {
-        .render_buffer = { EGL_RENDER_BUFFER, EGL_BACK_BUFFER },
-        .none = EGL_NONE
-    };
-
-    context = eglCreateContext(egl_disp, impl->conf, EGL_NO_CONTEXT,
-                               (EGLint *)&egl_ctx_attr);
-    if (context == EGL_NO_CONTEXT) {
-        return NULL;
-    }
-
-    surface = eglCreateWindowSurface(egl_disp, impl->conf,
-                                     (EGLNativeWindowType)impl->window,
-                                     (EGLint *)&egl_surf_attr);
-    if (surface == EGL_NO_SURFACE) {
-        return NULL;
-    }
 
 
-    eglMakeCurrent(egl_disp, surface, surface, context);
-
-    impl->surface = surface;
+    context = SDL_EGL_CreateContext(_this, impl->egl_surface);
     impl->context = context;
     impl->context = context;
 
 
-    SDL_SetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_QNX_SURFACE_POINTER, impl->surface);
-
     return context;
     return context;
 }
 }
 
 
 /**
 /**
  * Sets a new value for the number of frames to display before swapping buffers.
  * Sets a new value for the number of frames to display before swapping buffers.
- * @param   SDL_VideoDevice *_this
- * @param   interval    New interval value
- * @return  true if successful, false on error
  */
  */
-bool glSetSwapInterval(SDL_VideoDevice *_this, int interval)
+bool QNX_GLES_SetSwapInterval(SDL_VideoDevice *_this, int interval)
 {
 {
-    if (eglSwapInterval(egl_disp, interval) != EGL_TRUE) {
-        return false;
-    }
+    return SDL_EGL_SetSwapInterval(_this, interval);
+}
 
 
-    return true;
+/**
+ * Gets the value for the number of frames to display before swapping buffers.
+ */
+bool QNX_GLES_GetSwapInterval(SDL_VideoDevice *_this, int *interval)
+{
+    return SDL_EGL_GetSwapInterval(_this, interval);
 }
 }
 
 
 /**
 /**
  * Swaps the EGL buffers associated with the given window
  * Swaps the EGL buffers associated with the given window
- * @param   SDL_VideoDevice *_this
- * @param   window  Window to swap buffers for
- * @return  true if successful, false on error
  */
  */
-bool glSwapWindow(SDL_VideoDevice *_this, SDL_Window *window)
+bool QNX_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window)
 {
 {
-    // !!! FIXME: should we migrate this all over to use SDL_egl.c?
     SDL_WindowData   *impl = (SDL_WindowData *)window->internal;
     SDL_WindowData   *impl = (SDL_WindowData *)window->internal;
     {
     {
         if (impl->resize) {
         if (impl->resize) {
             EGLSurface surface;
             EGLSurface surface;
-            struct {
-                EGLint render_buffer[2];
-                EGLint none;
-            } egl_surf_attr = {
-                .render_buffer = { EGL_RENDER_BUFFER, EGL_BACK_BUFFER },
-                .none = EGL_NONE
-            };
 
 
-            if (eglMakeCurrent(egl_disp, NULL, NULL, impl->context) != EGL_TRUE) {
+            if (!SDL_EGL_MakeCurrent(_this, EGL_NO_SURFACE, impl->context)) {
                 return false;
                 return false;
             }
             }
-            eglDestroySurface(egl_disp, impl->surface);
+            SDL_EGL_DestroySurface(_this, impl->egl_surface);
 
 
-            surface = eglCreateWindowSurface(egl_disp, impl->conf, impl->window,
-                                     (EGLint *)&egl_surf_attr);
+            surface = SDL_EGL_CreateSurface(_this, window, (NativeWindowType)impl->window);
             if (surface == EGL_NO_SURFACE) {
             if (surface == EGL_NO_SURFACE) {
                 return false;
                 return false;
             }
             }
 
 
-            if (eglMakeCurrent(egl_disp, surface, surface, impl->context) != EGL_TRUE) {
+            if (!SDL_EGL_MakeCurrent(_this, surface, impl->context)) {
                 return false;
                 return false;
             }
             }
 
 
-            impl->surface = surface;
-            impl->resize = 0;
+            impl->egl_surface = surface;
+            impl->resize = false;
         }
         }
     }
     }
 
 
-    return eglSwapBuffers(egl_disp, impl->surface) == EGL_TRUE ? true : false;
-}
-
-/**
- * Makes the given context the current one for drawing operations.
- * @param   SDL_VideoDevice *_this
- * @param   window  SDL window associated with the context (maybe NULL)
- * @param   context The context to activate
- * @return  true if successful, false on error
- */
-bool glMakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context)
-{
-    SDL_WindowData   *impl;
-    EGLSurface      surface = NULL;
-
-    if (window) {
-        impl = (SDL_WindowData *)window->internal;
-        surface = impl->surface;
-    }
-
-    if (eglMakeCurrent(egl_disp, surface, surface, context) != EGL_TRUE) {
-        return false;
-    }
-
-    return true;
+    return SDL_EGL_SwapBuffers(_this, impl->egl_surface);
 }
 }
 
 
 /**
 /**
  * Destroys a context.
  * Destroys a context.
- * @param   SDL_VideoDevice *_this
- * @param   context The context to destroy
  */
  */
-bool glDeleteContext(SDL_VideoDevice *_this, SDL_GLContext context)
+bool QNX_GLES_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context)
 {
 {
-    eglDestroyContext(egl_disp, context);
-    return true;
+    return SDL_EGL_DestroyContext(_this, context);
 }
 }
 
 
 /**
 /**
  * Terminates access to the EGL library.
  * Terminates access to the EGL library.
- * @param   SDL_VideoDevice *_this
  */
  */
-void glUnloadLibrary(SDL_VideoDevice *_this)
+void QNX_GLES_UnloadLibrary(SDL_VideoDevice *_this)
 {
 {
-    eglTerminate(egl_disp);
+    SDL_EGL_UnloadLibrary(_this);
 }
 }
+
+SDL_EGL_MakeCurrent_impl(QNX)

+ 11 - 14
src/video/qnx/SDL_qnxkeyboard.c

@@ -121,19 +121,17 @@ static int key_to_sdl[] = {
     [KEYCODE_KP_MINUS] = SDL_SCANCODE_KP_MINUS,
     [KEYCODE_KP_MINUS] = SDL_SCANCODE_KP_MINUS,
     [KEYCODE_KP_PLUS] = SDL_SCANCODE_KP_PLUS,
     [KEYCODE_KP_PLUS] = SDL_SCANCODE_KP_PLUS,
     [KEYCODE_KP_ENTER] = SDL_SCANCODE_KP_ENTER,
     [KEYCODE_KP_ENTER] = SDL_SCANCODE_KP_ENTER,
-    /* NO SCREEN MAPPING FOR KEYPAD DIGITS
-    [KEYCODE_ZERO] = SDL_SCANCODE_KP_0,
-    [KEYCODE_ONE] = SDL_SCANCODE_KP_1,
-    [KEYCODE_TWO] = SDL_SCANCODE_KP_2,
-    [KEYCODE_THREE] = SDL_SCANCODE_KP_3,
-    [KEYCODE_FOUR] = SDL_SCANCODE_KP_4,
-    [KEYCODE_FIVE] = SDL_SCANCODE_KP_5,
-    [KEYCODE_SIX] = SDL_SCANCODE_KP_6,
-    [KEYCODE_SEVEN] = SDL_SCANCODE_KP_7,
-    [KEYCODE_EIGHT] = SDL_SCANCODE_KP_8,
-    [KEYCODE_NINE] = SDL_SCANCODE_KP_9,
-    [KEYCODE_PERIOD] = SDL_SCANCODE_KP_PERIOD,
-    */
+    [KEYCODE_KP_INSERT] = SDL_SCANCODE_KP_0,
+    [KEYCODE_KP_END] = SDL_SCANCODE_KP_1,
+    [KEYCODE_KP_DOWN] = SDL_SCANCODE_KP_2,
+    [KEYCODE_KP_PG_DOWN] = SDL_SCANCODE_KP_3,
+    [KEYCODE_KP_LEFT] = SDL_SCANCODE_KP_4,
+    [KEYCODE_KP_FIVE] = SDL_SCANCODE_KP_5,
+    [KEYCODE_KP_RIGHT] = SDL_SCANCODE_KP_6,
+    [KEYCODE_KP_HOME] = SDL_SCANCODE_KP_7,
+    [KEYCODE_KP_UP] = SDL_SCANCODE_KP_8,
+    [KEYCODE_KP_PG_UP] = SDL_SCANCODE_KP_9,
+    [KEYCODE_KP_DELETE] = SDL_SCANCODE_KP_PERIOD,
     [KEYCODE_POWER] = SDL_SCANCODE_POWER,
     [KEYCODE_POWER] = SDL_SCANCODE_POWER,
     [KEYCODE_PLAY] = SDL_SCANCODE_EXECUTE,
     [KEYCODE_PLAY] = SDL_SCANCODE_EXECUTE,
     [KEYCODE_HELP] = SDL_SCANCODE_HELP,
     [KEYCODE_HELP] = SDL_SCANCODE_HELP,
@@ -164,7 +162,6 @@ static int key_to_sdl[] = {
 /**
 /**
  * Called from the event dispatcher when a keyboard event is encountered.
  * Called from the event dispatcher when a keyboard event is encountered.
  * Translates the event such that it can be handled by SDL.
  * Translates the event such that it can be handled by SDL.
- * @param   event   Screen keyboard event
  */
  */
 void handleKeyboardEvent(screen_event_t event)
 void handleKeyboardEvent(screen_event_t event)
 {
 {

+ 4 - 4
src/video/qnx/SDL_qnxmodes.c

@@ -54,7 +54,7 @@ SDL_PixelFormat screenToPixelFormat(int screen_format)
     return _format_map[screen_format];
     return _format_map[screen_format];
 }
 }
 
 
-bool getDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display)
+bool QNX_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display)
 {
 {
     SDL_DisplayData     *display_data = display->internal;
     SDL_DisplayData     *display_data = display->internal;
     SDL_DisplayMode     display_mode;
     SDL_DisplayMode     display_mode;
@@ -132,7 +132,7 @@ bool getDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display)
 // FIXME: This seems to invalidate the screen_display_t, causing issues with the
 // FIXME: This seems to invalidate the screen_display_t, causing issues with the
 // (get|set)_display_property_*() apis. For now, mode switching is emulated
 // (get|set)_display_property_*() apis. For now, mode switching is emulated
 // instead.
 // instead.
-bool setDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
+bool QNX_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
 {
 {
     SDL_DisplayData     *display_data = display->internal;
     SDL_DisplayData     *display_data = display->internal;
     SDL_DisplayModeData *display_mode_data = mode->internal;
     SDL_DisplayModeData *display_mode_data = mode->internal;
@@ -150,7 +150,7 @@ bool setDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Displ
     return true;
     return true;
 }
 }
 
 
-bool getDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect)
+bool QNX_GetDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect)
 {
 {
     SDL_DisplayData *data = display->internal;
     SDL_DisplayData *data = display->internal;
     int             size[2] = { 0, 0 };
     int             size[2] = { 0, 0 };
@@ -170,7 +170,7 @@ bool getDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rec
     return true;
     return true;
 }
 }
 #else
 #else
-bool getDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect)
+bool QNX_GetDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect)
 {
 {
     if (display->current_mode == NULL) {
     if (display->current_mode == NULL) {
         return false;
         return false;

+ 81 - 122
src/video/qnx/SDL_qnxvideo.c

@@ -21,6 +21,7 @@
 
 
 #include "SDL_internal.h"
 #include "SDL_internal.h"
 #include "../SDL_sysvideo.h"
 #include "../SDL_sysvideo.h"
+#include "../SDL_egl_c.h"
 #include "../../events/SDL_keyboard_c.h"
 #include "../../events/SDL_keyboard_c.h"
 #include "../../events/SDL_mouse_c.h"
 #include "../../events/SDL_mouse_c.h"
 #include "../../events/SDL_windowevents_c.h"
 #include "../../events/SDL_windowevents_c.h"
@@ -46,10 +47,8 @@ screen_event_t * getEvent()
  * Initializes the QNX video plugin.
  * Initializes the QNX video plugin.
  * Creates the Screen context and event handles used for all window operations
  * Creates the Screen context and event handles used for all window operations
  * by the plugin.
  * by the plugin.
- * @param   SDL_VideoDevice *_this
- * @return  true if successful, false on error
  */
  */
-static bool videoInit(SDL_VideoDevice *_this)
+static bool QNX_VideoInit(SDL_VideoDevice *_this)
 {
 {
     SDL_VideoDisplay     display;
     SDL_VideoDisplay     display;
     SDL_DisplayData      *display_data;
     SDL_DisplayData      *display_data;
@@ -163,7 +162,7 @@ static bool videoInit(SDL_VideoDevice *_this)
     return true;
     return true;
 }
 }
 
 
-static void videoQuit(SDL_VideoDevice *_this)
+static void QNX_VideoQuit(SDL_VideoDevice *_this)
 {
 {
     if (video_initialized) {
     if (video_initialized) {
         screen_destroy_event(event);
         screen_destroy_event(event);
@@ -175,11 +174,8 @@ static void videoQuit(SDL_VideoDevice *_this)
 /**
 /**
  * Creates a new native Screen window and associates it with the given SDL
  * Creates a new native Screen window and associates it with the given SDL
  * window.
  * window.
- * @param   SDL_VideoDevice *_this
- * @param   window  SDL window to initialize
- * @return  true if successful, false on error
  */
  */
-static bool createWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
+static bool QNX_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
 {
 {
     SDL_WindowData       *impl;
     SDL_WindowData       *impl;
     SDL_VideoDisplay     *display = NULL;
     SDL_VideoDisplay     *display = NULL;
@@ -210,18 +206,15 @@ static bool createWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propert
     position[0] = window->x;
     position[0] = window->x;
     position[1] = window->y;
     position[1] = window->y;
 
 
-    if (screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_SIZE,
-                                      size) < 0) {
+    if (screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_SIZE, size) < 0) {
         goto fail;
         goto fail;
     }
     }
 
 
-    if (screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_SOURCE_SIZE,
-                                      size) < 0) {
+    if (screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_SOURCE_SIZE, size) < 0) {
         goto fail;
         goto fail;
     }
     }
 
 
-    if (screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_POSITION,
-                                      position) < 0) {
+    if (screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_POSITION, position) < 0) {
         goto fail;
         goto fail;
     }
     }
 
 
@@ -230,47 +223,47 @@ static bool createWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propert
     SDL_assert(display->desktop_mode.internal != NULL);
     SDL_assert(display->desktop_mode.internal != NULL);
     display_mode_data = display->desktop_mode.internal;
     display_mode_data = display->desktop_mode.internal;
 
 
-    if (screen_get_window_property_iv(impl->window, SCREEN_PROPERTY_FORMAT,
-                                      &format) < 0) {
-        format = display_mode_data->screen_format;
-    }
-
     // Create window buffer(s).
     // Create window buffer(s).
     if (window->flags & SDL_WINDOW_OPENGL) {
     if (window->flags & SDL_WINDOW_OPENGL) {
-        if (!glInitConfig(impl, &format)) {
-            goto fail;
-        }
         numbufs = 2;
         numbufs = 2;
 
 
         usage = SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_OPENGL_ES3;
         usage = SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_OPENGL_ES3;
-        if (screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_USAGE,
-                                          &usage) < 0) {
+        if (screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_USAGE, &usage) < 0) {
             goto fail;
             goto fail;
         }
         }
     } else {
     } else {
         numbufs = 1;
         numbufs = 1;
     }
     }
 
 
+    // Create buffer(s).
+    if (screen_create_window_buffers(impl->window, numbufs>0?numbufs:1) < 0) {
+        goto fail;
+    }
+
+    // Initialize EGL surface.
+    if (window->flags & SDL_WINDOW_OPENGL) {
+        // The SDL_EGL_CreateSurface() function chooses the EGL config and
+        // assigns the window the corresponding format.
+        impl->egl_surface = SDL_EGL_CreateSurface(_this, window, (NativeWindowType)impl->window);
+        if (impl->egl_surface == EGL_NO_SURFACE) {
+            goto fail;
+        }
+        SDL_SetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_QNX_SURFACE_POINTER, impl->egl_surface);
+    }
+
+    if (screen_get_window_property_iv(impl->window, SCREEN_PROPERTY_FORMAT, &format) < 0) {
+        format = display_mode_data->screen_format;
+    }
+
     // We now know what the pixel format is, so we need to provide it to the
     // We now know what the pixel format is, so we need to provide it to the
     // right SDL APIs.
     // right SDL APIs.
     display->desktop_mode.format = screenToPixelFormat(format);
     display->desktop_mode.format = screenToPixelFormat(format);
     display_mode_data->screen_format = format;
     display_mode_data->screen_format = format;
 
 
     display_data = display->internal;
     display_data = display->internal;
-    // Initialized in videoInit()
+    // Initialized in QNX_VideoInit()
     SDL_assert(display_data != NULL);
     SDL_assert(display_data != NULL);
 
 
-    // Set pixel format.
-    if (screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_FORMAT,
-                                      &format) < 0) {
-        goto fail;
-    }
-
-    // Create buffer(s).
-    if (screen_create_window_buffers(impl->window, numbufs>0?numbufs:1) < 0) {
-        goto fail;
-    }
-
     // Get initial focus state. Fallback to true.
     // Get initial focus state. Fallback to true.
     if(screen_get_window_property_iv(impl->window, SCREEN_PROPERTY_FOCUS, &has_focus_i) < 0){
     if(screen_get_window_property_iv(impl->window, SCREEN_PROPERTY_FOCUS, &has_focus_i) < 0){
         impl->has_focus = true;
         impl->has_focus = true;
@@ -298,15 +291,9 @@ fail:
 
 
 /**
 /**
  * Gets a pointer to the Screen buffer associated with the given window. Note
  * Gets a pointer to the Screen buffer associated with the given window. Note
- * that the buffer is actually created in createWindow().
- * @param       SDL_VideoDevice *_this
- * @param       window  SDL window to get the buffer for
- * @param[out]  pixels  Holds a pointer to the window's buffer
- * @param[out]  format  Holds the pixel format for the buffer
- * @param[out]  pitch   Holds the number of bytes per line
- * @return  true if successful, false on error
+ * that the buffer is actually created in QNX_CreateWindow().
  */
  */
-static bool createWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window * window, SDL_PixelFormat * format,
+static bool QNX_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window * window, SDL_PixelFormat * format,
                         void ** pixels, int *pitch)
                         void ** pixels, int *pitch)
 {
 {
     int              buffer_count;
     int              buffer_count;
@@ -314,26 +301,22 @@ static bool createWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window * window,
     screen_buffer_t  *buffer;
     screen_buffer_t  *buffer;
     SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window);
     SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window);
 
 
-    if (screen_get_window_property_iv(impl->window, SCREEN_PROPERTY_BUFFER_COUNT,
-                                      &buffer_count) < 0) {
+    if (screen_get_window_property_iv(impl->window, SCREEN_PROPERTY_BUFFER_COUNT, &buffer_count) < 0) {
         return false;
         return false;
     }
     }
     buffer = SDL_calloc(buffer_count, sizeof(screen_buffer_t));
     buffer = SDL_calloc(buffer_count, sizeof(screen_buffer_t));
 
 
     // Get a pointer to the buffer's memory.
     // Get a pointer to the buffer's memory.
-    if (screen_get_window_property_pv(impl->window, SCREEN_PROPERTY_BUFFERS,
-                                      (void **)buffer) < 0) {
+    if (screen_get_window_property_pv(impl->window, SCREEN_PROPERTY_BUFFERS, (void **)buffer) < 0) {
         return false;
         return false;
     }
     }
 
 
-    if (screen_get_buffer_property_pv(*buffer, SCREEN_PROPERTY_POINTER,
-                                      pixels) < 0) {
+    if (screen_get_buffer_property_pv(*buffer, SCREEN_PROPERTY_POINTER, pixels) < 0) {
         return false;
         return false;
     }
     }
 
 
     // Set format and pitch.
     // Set format and pitch.
-    if (screen_get_buffer_property_iv(*buffer, SCREEN_PROPERTY_STRIDE,
-                                      pitch) < 0) {
+    if (screen_get_buffer_property_iv(*buffer, SCREEN_PROPERTY_STRIDE, pitch) < 0) {
         return false;
         return false;
     }
     }
 
 
@@ -343,27 +326,20 @@ static bool createWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window * window,
 
 
 /**
 /**
  * Informs the window manager that the window needs to be updated.
  * Informs the window manager that the window needs to be updated.
- * @param   SDL_VideoDevice *_this
- * @param   window      The window to update
- * @param   rects       An array of reectangular areas to update
- * @param   numrects    Rect array length
- * @return  true if successful, false on error
  */
  */
-static bool updateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects,
+static bool QNX_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects,
                         int numrects)
                         int numrects)
 {
 {
     int buffer_count, *rects_int;
     int buffer_count, *rects_int;
     SDL_WindowData   *impl = (SDL_WindowData *)window->internal;
     SDL_WindowData   *impl = (SDL_WindowData *)window->internal;
     screen_buffer_t *buffer;
     screen_buffer_t *buffer;
 
 
-    if (screen_get_window_property_iv(impl->window, SCREEN_PROPERTY_BUFFER_COUNT,
-                                      &buffer_count) < 0) {
+    if (screen_get_window_property_iv(impl->window, SCREEN_PROPERTY_BUFFER_COUNT, &buffer_count) < 0) {
         return false;
         return false;
     }
     }
     buffer = SDL_calloc(buffer_count, sizeof(screen_buffer_t));
     buffer = SDL_calloc(buffer_count, sizeof(screen_buffer_t));
 
 
-    if (screen_get_window_property_pv(impl->window, SCREEN_PROPERTY_BUFFERS,
-                                      (void **)buffer) < 0) {
+    if (screen_get_window_property_pv(impl->window, SCREEN_PROPERTY_BUFFERS, (void **)buffer) < 0) {
         return false;
         return false;
     }
     }
 
 
@@ -387,10 +363,9 @@ static bool updateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window,
     return true;
     return true;
 }
 }
 
 
-static SDL_FullscreenResult setWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen)
+static SDL_FullscreenResult QNX_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen)
 {
 {
     SDL_WindowData *window_data = window->internal;
     SDL_WindowData *window_data = window->internal;
-    SDL_DisplayData *display_data = display->internal;
     int size[2] = { 0, 0 };
     int size[2] = { 0, 0 };
     int position[2] = { 0, 0 };
     int position[2] = { 0, 0 };
 
 
@@ -401,7 +376,7 @@ static SDL_FullscreenResult setWindowFullscreen(SDL_VideoDevice *_this, SDL_Wind
     if (fullscreen) {
     if (fullscreen) {
         SDL_Rect bounds;
         SDL_Rect bounds;
 
 
-        if (!getDisplayBounds(_this, display, &bounds)) {
+        if (!QNX_GetDisplayBounds(_this, display, &bounds)) {
             return SDL_FULLSCREEN_FAILED;
             return SDL_FULLSCREEN_FAILED;
         }
         }
         position[0] = bounds.x;
         position[0] = bounds.x;
@@ -415,18 +390,15 @@ static SDL_FullscreenResult setWindowFullscreen(SDL_VideoDevice *_this, SDL_Wind
         size[1] = window->h;
         size[1] = window->h;
     }
     }
 
 
-    if (screen_set_window_property_iv(window_data->window, SCREEN_PROPERTY_SIZE,
-                                      size) < 0) {
+    if (screen_set_window_property_iv(window_data->window, SCREEN_PROPERTY_SIZE, size) < 0) {
         return SDL_FULLSCREEN_FAILED;
         return SDL_FULLSCREEN_FAILED;
     }
     }
 
 
-    if (screen_set_window_property_iv(window_data->window, SCREEN_PROPERTY_SOURCE_SIZE,
-                                      size) < 0) {
+    if (screen_set_window_property_iv(window_data->window, SCREEN_PROPERTY_SOURCE_SIZE, size) < 0) {
         return SDL_FULLSCREEN_FAILED;
         return SDL_FULLSCREEN_FAILED;
     }
     }
 
 
-    if (screen_set_window_property_iv(window_data->window, SCREEN_PROPERTY_POSITION,
-                                      position) < 0) {
+    if (screen_set_window_property_iv(window_data->window, SCREEN_PROPERTY_POSITION, position) < 0) {
         return SDL_FULLSCREEN_FAILED;
         return SDL_FULLSCREEN_FAILED;
     }
     }
 
 
@@ -435,7 +407,7 @@ static SDL_FullscreenResult setWindowFullscreen(SDL_VideoDevice *_this, SDL_Wind
     return SDL_FULLSCREEN_SUCCEEDED;
     return SDL_FULLSCREEN_SUCCEEDED;
 }
 }
 
 
-static SDL_DisplayID getDisplayForWindow(SDL_VideoDevice *_this, SDL_Window *window)
+static SDL_DisplayID QNX_GetDisplayForWindow(SDL_VideoDevice *_this, SDL_Window *window)
 {
 {
     // We need this, otherwise SDL will fallback to the primary display, meaning
     // We need this, otherwise SDL will fallback to the primary display, meaning
     // any data we store about the display will be inconveniently overwritten.
     // any data we store about the display will be inconveniently overwritten.
@@ -448,8 +420,7 @@ static SDL_DisplayID getDisplayForWindow(SDL_VideoDevice *_this, SDL_Window *win
         return 0;
         return 0;
     }
     }
 
 
-    if (screen_get_window_property_pv(impl->window, SCREEN_PROPERTY_DISPLAY,
-                                      (void **)&screen_display) < 0) {
+    if (screen_get_window_property_pv(impl->window, SCREEN_PROPERTY_DISPLAY, (void **)&screen_display) < 0) {
         return 0;
         return 0;
     }
     }
 
 
@@ -465,9 +436,8 @@ static SDL_DisplayID getDisplayForWindow(SDL_VideoDevice *_this, SDL_Window *win
 
 
 /**
 /**
  * Runs the main event loop.
  * Runs the main event loop.
- * @param   SDL_VideoDevice *_this
  */
  */
-static void pumpEvents(SDL_VideoDevice *_this)
+static void QNX_PumpEvents(SDL_VideoDevice *_this)
 {
 {
     SDL_Window      *window;
     SDL_Window      *window;
     SDL_WindowData   *impl;
     SDL_WindowData   *impl;
@@ -523,10 +493,8 @@ static void pumpEvents(SDL_VideoDevice *_this)
 
 
 /**
 /**
  * Updates the size of the native window using the geometry of the SDL window.
  * Updates the size of the native window using the geometry of the SDL window.
- * @param   SDL_VideoDevice *_this
- * @param   window  SDL window to update
  */
  */
-static void setWindowSize(SDL_VideoDevice *_this, SDL_Window *window)
+static void QNX_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window)
 {
 {
     SDL_WindowData   *impl = (SDL_WindowData *)window->internal;
     SDL_WindowData   *impl = (SDL_WindowData *)window->internal;
     int             size[2];
     int             size[2];
@@ -538,7 +506,7 @@ static void setWindowSize(SDL_VideoDevice *_this, SDL_Window *window)
         if (screen_destroy_window_buffers(impl->window) < 0) {
         if (screen_destroy_window_buffers(impl->window) < 0) {
             return;
             return;
         }
         }
-        impl->resize = 1;
+        impl->resize = true;
 
 
         screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_SIZE, size);
         screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_SIZE, size);
         screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_SOURCE_SIZE, size);
         screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_SOURCE_SIZE, size);
@@ -551,38 +519,30 @@ static void setWindowSize(SDL_VideoDevice *_this, SDL_Window *window)
 
 
 /**
 /**
  * Makes the native window associated with the given SDL window visible.
  * Makes the native window associated with the given SDL window visible.
- * @param   SDL_VideoDevice *_this
- * @param   window  SDL window to update
  */
  */
-static void showWindow(SDL_VideoDevice *_this, SDL_Window *window)
+static void QNX_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window)
 {
 {
     SDL_WindowData   *impl = (SDL_WindowData *)window->internal;
     SDL_WindowData   *impl = (SDL_WindowData *)window->internal;
     const int       visible = 1;
     const int       visible = 1;
 
 
-    screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_VISIBLE,
-                                  &visible);
+    screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_VISIBLE, &visible);
 }
 }
 
 
 /**
 /**
  * Makes the native window associated with the given SDL window invisible.
  * Makes the native window associated with the given SDL window invisible.
- * @param   SDL_VideoDevice *_this
- * @param   window  SDL window to update
  */
  */
-static void hideWindow(SDL_VideoDevice *_this, SDL_Window *window)
+static void QNX_HideWindow(SDL_VideoDevice *_this, SDL_Window *window)
 {
 {
     SDL_WindowData   *impl = (SDL_WindowData *)window->internal;
     SDL_WindowData   *impl = (SDL_WindowData *)window->internal;
     const int       visible = 0;
     const int       visible = 0;
 
 
-    screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_VISIBLE,
-        &visible);
+    screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_VISIBLE, &visible);
 }
 }
 
 
 /**
 /**
  * Destroys the native window associated with the given SDL window.
  * Destroys the native window associated with the given SDL window.
- * @param   SDL_VideoDevice *_this
- * @param   window  SDL window that is being destroyed
  */
  */
-static void destroyWindow(SDL_VideoDevice *_this, SDL_Window *window)
+static void QNX_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window)
 {
 {
     SDL_WindowData   *impl = (SDL_WindowData *)window->internal;
     SDL_WindowData   *impl = (SDL_WindowData *)window->internal;
 
 
@@ -594,16 +554,14 @@ static void destroyWindow(SDL_VideoDevice *_this, SDL_Window *window)
 
 
 /**
 /**
  * Frees the plugin object created by createDevice().
  * Frees the plugin object created by createDevice().
- * @param   device  Plugin object to free
  */
  */
-static void deleteDevice(SDL_VideoDevice *device)
+static void QNX_DeleteDevice(SDL_VideoDevice *device)
 {
 {
     SDL_free(device);
     SDL_free(device);
 }
 }
 
 
 /**
 /**
  * Creates the QNX video plugin used by SDL.
  * Creates the QNX video plugin used by SDL.
- * @return  Initialized device if successful, NULL otherwise
  */
  */
 static SDL_VideoDevice *createDevice(void)
 static SDL_VideoDevice *createDevice(void)
 {
 {
@@ -615,34 +573,35 @@ static SDL_VideoDevice *createDevice(void)
     }
     }
 
 
     device->internal = NULL;
     device->internal = NULL;
-    device->VideoInit = videoInit;
-    device->VideoQuit = videoQuit;
-    device->CreateSDLWindow = createWindow;
-    device->CreateWindowFramebuffer = createWindowFramebuffer;
-    device->UpdateWindowFramebuffer = updateWindowFramebuffer;
-    device->SetWindowSize = setWindowSize;
-    device->SetWindowFullscreen = setWindowFullscreen;
-    device->ShowWindow = showWindow;
-    device->HideWindow = hideWindow;
-    device->GetDisplayForWindow = getDisplayForWindow;
-    device->GetDisplayBounds = getDisplayBounds;
-    device->GetDisplayModes = getDisplayModes;
+    device->VideoInit = QNX_VideoInit;
+    device->VideoQuit = QNX_VideoQuit;
+    device->CreateSDLWindow = QNX_CreateWindow;
+    device->CreateWindowFramebuffer = QNX_CreateWindowFramebuffer;
+    device->UpdateWindowFramebuffer = QNX_UpdateWindowFramebuffer;
+    device->SetWindowSize = QNX_SetWindowSize;
+    device->SetWindowFullscreen = QNX_SetWindowFullscreen;
+    device->ShowWindow = QNX_ShowWindow;
+    device->HideWindow = QNX_HideWindow;
+    device->GetDisplayForWindow = QNX_GetDisplayForWindow;
+    device->GetDisplayBounds = QNX_GetDisplayBounds;
+    device->GetDisplayModes = QNX_GetDisplayModes;
 #if 0
 #if 0
-    device->SetDisplayMode = setDisplayMode;
+    device->SetDisplayMode = QNX_SetDisplayMode;
 #endif
 #endif
-    device->PumpEvents = pumpEvents;
-    device->DestroyWindow = destroyWindow;
-
-    device->GL_LoadLibrary = glLoadLibrary;
-    device->GL_GetProcAddress = glGetProcAddress;
-    device->GL_CreateContext = glCreateContext;
-    device->GL_SetSwapInterval = glSetSwapInterval;
-    device->GL_SwapWindow = glSwapWindow;
-    device->GL_MakeCurrent = glMakeCurrent;
-    device->GL_DestroyContext = glDeleteContext;
-    device->GL_UnloadLibrary = glUnloadLibrary;
-
-    device->free = deleteDevice;
+    device->PumpEvents = QNX_PumpEvents;
+    device->DestroyWindow = QNX_DestroyWindow;
+
+    device->GL_LoadLibrary = QNX_GLES_LoadLibrary;
+    device->GL_GetProcAddress = QNX_GLES_GetProcAddress;
+    device->GL_CreateContext = QNX_GLES_CreateContext;
+    device->GL_SetSwapInterval = QNX_GLES_SetSwapInterval;
+    device->GL_GetSwapInterval = QNX_GLES_GetSwapInterval;
+    device->GL_SwapWindow = QNX_GLES_SwapWindow;
+    device->GL_MakeCurrent = QNX_GLES_MakeCurrent;
+    device->GL_DestroyContext = QNX_GLES_DeleteContext;
+    device->GL_UnloadLibrary = QNX_GLES_UnloadLibrary;
+
+    device->free = QNX_DeleteDevice;
 
 
     return device;
     return device;
 }
 }