SDL  2.0
sdl_qnx.h File Reference
#include "../SDL_sysvideo.h"
#include <screen/screen.h>
#include <EGL/egl.h>
+ Include dependency graph for sdl_qnx.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  window_impl_t

Functions

void handleKeyboardEvent (screen_event_t event)
int glGetConfig (EGLConfig *pconf, int *pformat)
int glLoadLibrary (_THIS, const char *name)
voidglGetProcAddress (_THIS, const char *proc)
SDL_GLContext glCreateContext (_THIS, SDL_Window *window)
int glSetSwapInterval (_THIS, int interval)
int glSwapWindow (_THIS, SDL_Window *window)
int glMakeCurrent (_THIS, SDL_Window *window, SDL_GLContext context)
void glDeleteContext (_THIS, SDL_GLContext context)
void glUnloadLibrary (_THIS)

Function Documentation

SDL_GLContext glCreateContext ( _THIS  ,
SDL_Window window 
)

Associates the given window with the necessary EGL structures for drawing and displaying content.

Parameters
_THIS
windowThe SDL window to create the context for
Returns
A pointer to the created context, if successful, NULL on error

Definition at line 171 of file gl.c.

References context, and SDL_Window::driverdata.

Referenced by createDevice().

{
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
};
(EGLint *)&egl_ctx_attr);
return NULL;
}
surface = eglCreateWindowSurface(egl_disp, impl->conf, impl->window,
(EGLint *)&egl_surf_attr);
return NULL;
}
impl->surface = surface;
return context;
}
void glDeleteContext ( _THIS  ,
SDL_GLContext  context 
)

Destroys a context.

Parameters
_THIS
contextThe context to destroy

Definition at line 272 of file gl.c.

References egl_disp, and eglDestroyContext().

Referenced by createDevice().

int glGetConfig ( EGLConfig pconf,
int *  pformat 
)

Enumerates the supported EGL configurations and chooses a suitable one.

Parameters
[out]pconfThe chosen configuration
[out]pformatThe chosen pixel format
Returns
0 if successful, -1 on error

Definition at line 68 of file gl.c.

References chooseFormat(), EGL_DEPTH_SIZE, egl_disp, EGL_OPENGL_ES2_BIT, EGL_RENDERABLE_TYPE, EGL_SURFACE_TYPE, EGL_TRUE, EGL_WINDOW_BIT, eglGetConfigAttrib(), eglGetConfigs(), free, i, malloc, and NULL.

Referenced by createWindow().

{
EGLConfig egl_conf = (EGLConfig)0;
EGLConfig *egl_configs;
EGLint egl_num_configs;
// Determine the numbfer of configurations.
rc = eglGetConfigs(egl_disp, NULL, 0, &egl_num_configs);
if (rc != EGL_TRUE) {
return -1;
}
if (egl_num_configs == 0) {
return -1;
}
// Allocate enough memory for all configurations.
egl_configs = malloc(egl_num_configs * sizeof(*egl_configs));
if (egl_configs == NULL) {
return -1;
}
// Get the list of configurations.
rc = eglGetConfigs(egl_disp, egl_configs, egl_num_configs,
&egl_num_configs);
if (rc != EGL_TRUE) {
free(egl_configs);
return -1;
}
// Find a good configuration.
for (i = 0; i < egl_num_configs; i++) {
eglGetConfigAttrib(egl_disp, egl_configs[i], EGL_SURFACE_TYPE, &val);
if (!(val & EGL_WINDOW_BIT)) {
continue;
}
if (!(val & EGL_OPENGL_ES2_BIT)) {
continue;
}
eglGetConfigAttrib(egl_disp, egl_configs[i], EGL_DEPTH_SIZE, &val);
if (val == 0) {
continue;
}
egl_conf = egl_configs[i];
break;
}
free(egl_configs);
*pconf = egl_conf;
*pformat = chooseFormat(egl_conf);
return 0;
}
void* glGetProcAddress ( _THIS  ,
const char *  proc 
)

Finds the address of an EGL extension function.

Parameters
procFunction name
Returns
Function address

Definition at line 158 of file gl.c.

References eglGetProcAddress().

Referenced by createDevice().

{
return eglGetProcAddress(proc);
}
int glLoadLibrary ( _THIS  ,
const char *  name 
)

Initializes the EGL library.

Parameters
_THIS
nameunused
Returns
0 if successful, -1 on error

Definition at line 136 of file gl.c.

References EGL_DEFAULT_DISPLAY, egl_disp, EGL_FALSE, EGL_NO_DISPLAY, eglGetDisplay(), eglInitialize(), and NULL.

Referenced by createDevice().

{
egl_disp = eglGetDisplay(disp_id);
return -1;
}
return -1;
}
return 0;
}
int glMakeCurrent ( _THIS  ,
SDL_Window window,
SDL_GLContext  context 
)

Makes the given context the current one for drawing operations.

Parameters
_THIS
windowSDL window associated with the context (maybe NULL)
contextThe context to activate
Returns
0 if successful, -1 on error

Definition at line 249 of file gl.c.

References SDL_Window::driverdata, egl_disp, EGL_TRUE, eglMakeCurrent(), NULL, and window_impl_t::surface.

Referenced by createDevice().

{
if (window) {
impl = (window_impl_t *)window->driverdata;
surface = impl->surface;
}
if (eglMakeCurrent(egl_disp, surface, surface, context) != EGL_TRUE) {
return -1;
}
return 0;
}
int glSetSwapInterval ( _THIS  ,
int  interval 
)

Sets a new value for the number of frames to display before swapping buffers.

Parameters
_THIS
intervalNew interval value
Returns
0 if successful, -1 on error

Definition at line 218 of file gl.c.

References egl_disp, EGL_TRUE, and eglSwapInterval().

Referenced by createDevice().

{
if (eglSwapInterval(egl_disp, interval) != EGL_TRUE) {
return -1;
}
return 0;
}
int glSwapWindow ( _THIS  ,
SDL_Window window 
)

Swaps the EGL buffers associated with the given window

Parameters
_THIS
windowWindow to swap buffers for
Returns
0 if successful, -1 on error

Definition at line 234 of file gl.c.

References SDL_Window::driverdata, egl_disp, EGL_TRUE, eglSwapBuffers(), and window_impl_t::surface.

Referenced by createDevice().

{
/* !!! FIXME: should we migrate this all over to use SDL_egl.c? */
return eglSwapBuffers(egl_disp, impl->surface) == EGL_TRUE ? 0 : -1;
}
void glUnloadLibrary ( _THIS  )

Terminates access to the EGL library.

Parameters
_THIS

Definition at line 282 of file gl.c.

References egl_disp, and eglTerminate().

Referenced by createDevice().

void handleKeyboardEvent ( screen_event_t  event)

Called from the event dispatcher when a keyboard event is encountered. Translates the event such that it can be handled by SDL.

Parameters
eventScreen keyboard event

Definition at line 99 of file keyboard.c.

References key_to_sdl, SDL_PRESSED, SDL_RELEASED, SDL_SendKeyboardKey(), and SDL_TABLESIZE.

Referenced by pumpEvents().

{
int val;
SDL_Scancode scancode;
// Get the key value.
if (screen_get_event_property_iv(event, SCREEN_PROPERTY_SYM, &val) < 0) {
return;
}
// Skip unrecognized keys.
if ((val < 0) || (val >= SDL_TABLESIZE(key_to_sdl))) {
return;
}
// Translate to an SDL scan code.
scancode = key_to_sdl[val];
if (scancode == 0) {
return;
}
// Get event flags (key state).
if (screen_get_event_property_iv(event, SCREEN_PROPERTY_FLAGS, &val) < 0) {
return;
}
// Propagate the event to SDL.
// FIXME:
// Need to handle more key states (such as key combinations).
if (val & KEY_DOWN) {
} else {
}
}