video.c File Reference
`#include "../../SDL_internal.h"`
`#include "../SDL_sysvideo.h"`
`#include "sdl_qnx.h"`
Include dependency graph for video.c:

Go to the source code of this file.

## Functions

static int | videoInit (_THIS)
static void | videoQuit (_THIS)
static int | createWindow (_THIS, SDL_Window *window)
static int | createWindowFramebuffer (_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
static int | updateWindowFramebuffer (_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
static void | pumpEvents (_THIS)
static void | setWindowSize (_THIS, SDL_Window *window)
static void | showWindow (_THIS, SDL_Window *window)
static void | hideWindow (_THIS, SDL_Window *window)
static void | destroyWindow (_THIS, SDL_Window *window)
static void | deleteDevice (SDL_VideoDevice *device)
static SDL_VideoDevice * | createDevice (int devindex)
static int | available ()

## Variables

static screen_context_t | context
static screen_event_t | event
VideoBootStrap | QNX_bootstrap

## Function Documentation

## available()

static int available | ( |  | ) |

static

Definition at line 356 of file video.c.

Referenced by SDL_VideoInit().

{
return 1;
}

## createDevice()

static SDL_VideoDevice* createDevice | ( | int | devindex | ) |

static

Creates the QNX video plugin used by SDL.

Parameters

  devindex | Unused

Returns
  Initialized device if successful, NULL otherwise

Definition at line 321 of file video.c.

References SDL_VideoDevice::CreateSDLWindow, createWindow(), createWindowFramebuffer(), SDL_VideoDevice::CreateWindowFramebuffer, deleteDevice(), SDL_VideoDevice::DestroyWindow, destroyWindow(), device, SDL_VideoDevice::driverdata, SDL_VideoDevice::free, SDL_VideoDevice::GL_CreateContext, SDL_VideoDevice::GL_DeleteContext, SDL_VideoDevice::GL_GetProcAddress, SDL_VideoDevice::GL_LoadLibrary, SDL_VideoDevice::GL_MakeCurrent, SDL_VideoDevice::GL_SetSwapInterval, SDL_VideoDevice::GL_SwapWindow, SDL_VideoDevice::GL_UnloadLibrary, glCreateContext(), glDeleteContext(), glGetProcAddress(), glLoadLibrary(), glMakeCurrent(), glSetSwapInterval(), glSwapWindow(), glUnloadLibrary(), SDL_VideoDevice::HideWindow, hideWindow(), NULL, pumpEvents(), SDL_VideoDevice::PumpEvents, SDL_calloc, SDL_VideoDevice::SetWindowSize, setWindowSize(), SDL_VideoDevice::ShowWindow, showWindow(), updateWindowFramebuffer(), SDL_VideoDevice::UpdateWindowFramebuffer, videoInit(), SDL_VideoDevice::VideoInit, videoQuit(), and SDL_VideoDevice::VideoQuit.

{
SDL_VideoDevice *device;
device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice));
if (device == NULL) {
return NULL;
}
device->driverdata = NULL;
device->VideoInit = videoInit;
device->VideoQuit = videoQuit;
device->CreateSDLWindow = createWindow;
device->CreateWindowFramebuffer = createWindowFramebuffer;
device->UpdateWindowFramebuffer = updateWindowFramebuffer;
device->SetWindowSize = setWindowSize;
device->ShowWindow = showWindow;
device->HideWindow = hideWindow;
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_DeleteContext = glDeleteContext;
device->GL_UnloadLibrary = glUnloadLibrary;
device->free = deleteDevice;
return device;
}
updateWindowFramebuffer
static int updateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
Definition: video.c:190
videoInit
static int videoInit(_THIS)
Definition: video.c:36
glCreateContext
SDL_GLContext glCreateContext(_THIS, SDL_Window *window)
Definition: gl.c:171
SDL_VideoDevice::free
void(* free)(_THIS)
Definition: SDL_sysvideo.h:390
glUnloadLibrary
void glUnloadLibrary(_THIS)
Definition: gl.c:282
SDL_VideoDevice::driverdata
void * driverdata
Definition: SDL_sysvideo.h:377
SDL_VideoDevice::GL_SetSwapInterval
int(* GL_SetSwapInterval)(_THIS, int interval)
Definition: SDL_sysvideo.h:260
SDL_VideoDevice::ShowWindow
void(* ShowWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:222
glLoadLibrary
int glLoadLibrary(_THIS, const char *name)
Definition: gl.c:136
SDL_VideoDevice::SetWindowSize
void(* SetWindowSize)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:215
setWindowSize
static void setWindowSize(_THIS, SDL_Window *window)
Definition: video.c:246
hideWindow
static void hideWindow(_THIS, SDL_Window *window)
Definition: video.c:280
SDL_VideoDevice::GL_LoadLibrary
int(* GL_LoadLibrary)(_THIS, const char *path)
Definition: SDL_sysvideo.h:254
glDeleteContext
void glDeleteContext(_THIS, SDL_GLContext context)
Definition: gl.c:272
pumpEvents
static void pumpEvents(_THIS)
Definition: video.c:211
glSetSwapInterval
int glSetSwapInterval(_THIS, int interval)
Definition: gl.c:218
SDL_VideoDevice::HideWindow
void(* HideWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:223
device
static SDL_AudioDeviceID device
Definition: loopwave.c:37
SDL_VideoDevice::GL_CreateContext
SDL_GLContext(* GL_CreateContext)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:257
SDL_VideoDevice::GL_MakeCurrent
int(* GL_MakeCurrent)(_THIS, SDL_Window *window, SDL_GLContext context)
Definition: SDL_sysvideo.h:258
createWindow
static int createWindow(_THIS, SDL_Window *window)
Definition: video.c:71
SDL_VideoDevice::DestroyWindow
void(* DestroyWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:234
showWindow
static void showWindow(_THIS, SDL_Window *window)
Definition: video.c:265
createWindowFramebuffer
static int createWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
Definition: video.c:154
SDL_VideoDevice::GL_UnloadLibrary
void(* GL_UnloadLibrary)(_THIS)
Definition: SDL_sysvideo.h:256
NULL
#define NULL
Definition: begin_code.h:164
SDL_VideoDevice::CreateSDLWindow
int(* CreateSDLWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:210
SDL_VideoDevice::VideoQuit
void(* VideoQuit)(_THIS)
Definition: SDL_sysvideo.h:166
SDL_calloc
#define SDL_calloc
Definition: SDL_dynapi_overrides.h:375
SDL_VideoDevice::GL_SwapWindow
int(* GL_SwapWindow)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:262
destroyWindow
static void destroyWindow(_THIS, SDL_Window *window)
Definition: video.c:295
SDL_VideoDevice
Definition: SDL_sysvideo.h:147
glGetProcAddress
void * glGetProcAddress(_THIS, const char *proc)
Definition: gl.c:158
SDL_VideoDevice::VideoInit
int(* VideoInit)(_THIS)
Definition: SDL_sysvideo.h:160
SDL_VideoDevice::UpdateWindowFramebuffer
int(* UpdateWindowFramebuffer)(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
Definition: SDL_sysvideo.h:236
SDL_VideoDevice::GL_DeleteContext
void(* GL_DeleteContext)(_THIS, SDL_GLContext context)
Definition: SDL_sysvideo.h:263
videoQuit
static void videoQuit(_THIS)
Definition: video.c:59
glMakeCurrent
int glMakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
Definition: gl.c:249
glSwapWindow
int glSwapWindow(_THIS, SDL_Window *window)
Definition: gl.c:234
SDL_VideoDevice::CreateWindowFramebuffer
int(* CreateWindowFramebuffer)(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
Definition: SDL_sysvideo.h:235
SDL_VideoDevice::GL_GetProcAddress
void *(* GL_GetProcAddress)(_THIS, const char *proc)
Definition: SDL_sysvideo.h:255
deleteDevice
static void deleteDevice(SDL_VideoDevice *device)
Definition: video.c:310
SDL_VideoDevice::PumpEvents
void(* PumpEvents)(_THIS)
Definition: SDL_sysvideo.h:280

## createWindow()

static int createWindow | ( | _THIS | ,
|  | SDL_Window * | window
| ) |  |

static

Creates a new native Screen window and associates it with the given SDL window.

Parameters

  _THIS |
  window | SDL window to initialize

Returns
  0 if successful, -1 on error

Definition at line 71 of file video.c.

References window_impl_t::conf, context, SDL_Window::driverdata, SDL_Window::flags, glGetConfig(), SDL_Window::h, NULL, SDL_calloc, SDL_free, SDL_WINDOW_OPENGL, SDL_Window::w, and window_impl_t::window.

Referenced by createDevice().

{
window_impl_t *impl;
int size[2];
int numbufs;
int format;
int usage;
impl = SDL_calloc(1, sizeof(*impl));
if (impl == NULL) {
return -1;
}
// Create a native window.
if (screen_create_window(&impl->window, context) < 0) {
goto fail;
}
// Set the native window's size to match the SDL window.
size[0] = window->w;
size[1] = window->h;
if (screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_SIZE,
size) < 0) {
goto fail;
}
if (screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_SOURCE_SIZE,
size) < 0) {
goto fail;
}
// Create window buffer(s).
if (window->flags & SDL_WINDOW_OPENGL) {
if (glGetConfig(&impl->conf, &format) < 0) {
goto fail;
}
numbufs = 2;
usage = SCREEN_USAGE_OPENGL_ES2;
if (screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_USAGE,
&usage) < 0) {
return -1;
}
} else {
format = SCREEN_FORMAT_RGBX8888;
numbufs = 1;
}
// 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) {
goto fail;
}
window->driverdata = impl;
return 0;
fail:
if (impl->window) {
screen_destroy_window(impl->window);
}
SDL_free(impl);
return -1;
}
glGetConfig
int glGetConfig(EGLConfig *pconf, int *pformat)
Definition: gl.c:68
SDL_Window::w
int w
Definition: SDL_sysvideo.h:80
window_impl_t::conf
EGLConfig conf
Definition: sdl_qnx.h:33
context
static screen_context_t context
Definition: video.c:25
format
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1572
usage
GLsizeiptr const void GLenum usage
Definition: SDL_opengl_glext.h:537
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
window_impl_t
Definition: sdl_qnx.h:29
window_impl_t::window
screen_window_t window
Definition: sdl_qnx.h:31
size
GLsizeiptr size
Definition: SDL_opengl_glext.h:537
SDL_Window::h
int h
Definition: SDL_sysvideo.h:80
NULL
#define NULL
Definition: begin_code.h:164
SDL_calloc
#define SDL_calloc
Definition: SDL_dynapi_overrides.h:375
SDL_WINDOW_OPENGL
Definition: SDL_video.h:101
SDL_Window::driverdata
void * driverdata
Definition: SDL_sysvideo.h:111
SDL_Window::flags
Uint32 flags
Definition: SDL_sysvideo.h:83

## createWindowFramebuffer()

static int createWindowFramebuffer | ( | _THIS | ,
|  | SDL_Window * | window,
|  | Uint32 * | format,
|  | void ** | pixels,
|  | int * | pitch
| ) |  |

static

Gets a pointer to the Screen buffer associated with the given window. Note that the buffer is actually created in createWindow().

Parameters

  | _THIS |
  | window | SDL window to get the buffer for
  [out] | pixles | Holds a pointer to the window's buffer
  [out] | format | Holds the pixel format for the buffer
  [out] | pitch | Holds the number of bytes per line

Returns
  0 if successful, -1 on error

Definition at line 154 of file video.c.

References SDL_Window::driverdata, SDL_PIXELFORMAT_RGB888, and window_impl_t::window.

Referenced by createDevice().

{
window_impl_t *impl = (window_impl_t *)window->driverdata;
screen_buffer_t buffer;
// Get a pointer to the buffer's memory.
if (screen_get_window_property_pv(impl->window, SCREEN_PROPERTY_BUFFERS,
(void **)&buffer) < 0) {
return -1;
}
if (screen_get_buffer_property_pv(buffer, SCREEN_PROPERTY_POINTER,
pixels) < 0) {
return -1;
}
// Set format and pitch.
if (screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_STRIDE,
pitch) < 0) {
return -1;
}
*format = SDL_PIXELFORMAT_RGB888;
return 0;
}
SDL_PIXELFORMAT_RGB888
Definition: SDL_pixels.h:236
format
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1572
window_impl_t
Definition: sdl_qnx.h:29
window_impl_t::window
screen_window_t window
Definition: sdl_qnx.h:31
pixels
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1572
buffer
GLuint buffer
Definition: SDL_opengl_glext.h:533
SDL_Window::driverdata
void * driverdata
Definition: SDL_sysvideo.h:111

## deleteDevice()

static void deleteDevice | ( | SDL_VideoDevice * | device | ) |

static

Frees the plugin object created by createDevice().

Parameters

  device | Plugin object to free

Definition at line 310 of file video.c.

References SDL_free.

Referenced by createDevice().

{
SDL_free(device);
}
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377

## destroyWindow()

static void destroyWindow | ( | _THIS | ,
|  | SDL_Window * | window
| ) |  |

static

Destroys the native window associated with the given SDL window.

Parameters

  _THIS |
  window | SDL window that is being destroyed

Definition at line 295 of file video.c.

References SDL_Window::driverdata, NULL, and window_impl_t::window.

Referenced by createDevice().

{
window_impl_t *impl = (window_impl_t *)window->driverdata;
if (impl) {
screen_destroy_window(impl->window);
window->driverdata = NULL;
}
}
window_impl_t
Definition: sdl_qnx.h:29
window_impl_t::window
screen_window_t window
Definition: sdl_qnx.h:31
NULL
#define NULL
Definition: begin_code.h:164
SDL_Window::driverdata
void * driverdata
Definition: SDL_sysvideo.h:111

## hideWindow()

static void hideWindow | ( | _THIS | ,
|  | SDL_Window * | window
| ) |  |

static

Makes the native window associated with the given SDL window invisible.

Parameters

  _THIS |
  window | SDL window to update

Definition at line 280 of file video.c.

References SDL_Window::driverdata, and window_impl_t::window.

Referenced by createDevice().

{
window_impl_t *impl = (window_impl_t *)window->driverdata;
const int visible = 0;
screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_VISIBLE,
&visible);
}
window_impl_t
Definition: sdl_qnx.h:29
window_impl_t::window
screen_window_t window
Definition: sdl_qnx.h:31
SDL_Window::driverdata
void * driverdata
Definition: SDL_sysvideo.h:111

## pumpEvents()

static void pumpEvents | ( | _THIS |  | ) |

static

Runs the main event loop.

Parameters

  _THIS |

Definition at line 211 of file video.c.

References context, and handleKeyboardEvent().

Referenced by createDevice().

{
int type;
for (;;) {
if (screen_get_event(context, event, 0) < 0) {
break;
}
if (screen_get_event_property_iv(event, SCREEN_PROPERTY_TYPE, &type)
< 0) {
break;
}
if (type == SCREEN_EVENT_NONE) {
break;
}
switch (type) {
case SCREEN_EVENT_KEYBOARD:
handleKeyboardEvent(event);
break;
default:
break;
}
}
}
context
static screen_context_t context
Definition: video.c:25
event
struct _cl_event * event
Definition: SDL_opengl_glext.h:2649
type
GLuint GLuint GLsizei GLenum type
Definition: SDL_opengl.h:1571
handleKeyboardEvent
void handleKeyboardEvent(screen_event_t event)
Definition: keyboard.c:99

## setWindowSize()

static void setWindowSize | ( | _THIS | ,
|  | SDL_Window * | window
| ) |  |

static

Updates the size of the native window using the geometry of the SDL window.

Parameters

  _THIS |
  window | SDL window to update

Definition at line 246 of file video.c.

References SDL_Window::driverdata, SDL_Window::h, SDL_Window::w, and window_impl_t::window.

Referenced by createDevice().

{
window_impl_t *impl = (window_impl_t *)window->driverdata;
int size[2];
size[0] = window->w;
size[1] = window->h;
screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_SIZE, size);
screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_SOURCE_SIZE,
size);
}
SDL_Window::w
int w
Definition: SDL_sysvideo.h:80
window_impl_t
Definition: sdl_qnx.h:29
window_impl_t::window
screen_window_t window
Definition: sdl_qnx.h:31
size
GLsizeiptr size
Definition: SDL_opengl_glext.h:537
SDL_Window::h
int h
Definition: SDL_sysvideo.h:80
SDL_Window::driverdata
void * driverdata
Definition: SDL_sysvideo.h:111

## showWindow()

static void showWindow | ( | _THIS | ,
|  | SDL_Window * | window
| ) |  |

static

Makes the native window associated with the given SDL window visible.

Parameters

  _THIS |
  window | SDL window to update

Definition at line 265 of file video.c.

References SDL_Window::driverdata, and window_impl_t::window.

Referenced by createDevice().

{
window_impl_t *impl = (window_impl_t *)window->driverdata;
const int visible = 1;
screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_VISIBLE,
&visible);
}
window_impl_t
Definition: sdl_qnx.h:29
window_impl_t::window
screen_window_t window
Definition: sdl_qnx.h:31
SDL_Window::driverdata
void * driverdata
Definition: SDL_sysvideo.h:111

## updateWindowFramebuffer()

static int updateWindowFramebuffer | ( | _THIS | ,
|  | SDL_Window * | window,
|  | const SDL_Rect * | rects,
|  | int | numrects
| ) |  |

static

Informs the window manager that the window needs to be updated.

Parameters

  _THIS |
  window | The window to update
  rects | An array of reectangular areas to update
  numrects | Rect array length

Returns
  0 if successful, -1 on error

Definition at line 190 of file video.c.

References context, SDL_Window::driverdata, and window_impl_t::window.

Referenced by createDevice().

{
window_impl_t *impl = (window_impl_t *)window->driverdata;
screen_buffer_t buffer;
if (screen_get_window_property_pv(impl->window, SCREEN_PROPERTY_BUFFERS,
(void **)&buffer) < 0) {
return -1;
}
screen_post_window(impl->window, buffer, numrects, (int *)rects, 0);
screen_flush_context(context, 0);
return 0;
}
context
static screen_context_t context
Definition: video.c:25
window_impl_t
Definition: sdl_qnx.h:29
window_impl_t::window
screen_window_t window
Definition: sdl_qnx.h:31
buffer
GLuint buffer
Definition: SDL_opengl_glext.h:533
SDL_Window::driverdata
void * driverdata
Definition: SDL_sysvideo.h:111

## videoInit()

static int videoInit | ( | _THIS |  | ) |

static

Initializes the QNX video plugin. Creates the Screen context and event handles used for all window operations by the plugin.

Parameters

  _THIS |

Returns
  0 if successful, -1 on error

Definition at line 36 of file video.c.

References _this, context, SDL_VideoDevice::num_displays, SDL_AddVideoDisplay(), and SDL_zero.

Referenced by createDevice().

{
SDL_VideoDisplay display;
if (screen_create_context(&context, 0) < 0) {
return -1;
}
if (screen_create_event(&event) < 0) {
return -1;
}
SDL_zero(display);
if (SDL_AddVideoDisplay(&display) < 0) {
return -1;
}
_this->num_displays = 1;
return 0;
}
context
static screen_context_t context
Definition: video.c:25
SDL_AddVideoDisplay
int SDL_AddVideoDisplay(const SDL_VideoDisplay *display)
Definition: SDL_video.c:606
_this
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
event
struct _cl_event * event
Definition: SDL_opengl_glext.h:2649
SDL_VideoDevice::num_displays
int num_displays
Definition: SDL_sysvideo.h:311
SDL_zero
#define SDL_zero(x)
Definition: SDL_stdinc.h:416
SDL_VideoDisplay
Definition: SDL_sysvideo.h:125

## videoQuit()

static void videoQuit | ( | _THIS |  | ) |

static

Definition at line 59 of file video.c.

Referenced by createDevice().

{
}

## Variable Documentation

## context

screen_context_t context

static

Definition at line 25 of file video.c.

Referenced by createWindow(), glCreateContext(), pumpEvents(), SDL_TrackAllocation(), ShouldUseTextureFramebuffer(), updateWindowFramebuffer(), and videoInit().

## event

screen_event_t event

static

Definition at line 26 of file video.c.

## QNX_bootstrap

VideoBootStrap QNX_bootstrap

Initial value:
= {
"qnx", "QNX Screen",
available, createDevice
}
available
static int available()
Definition: video.c:356
createDevice
static SDL_VideoDevice * createDevice(int devindex)
Definition: video.c:321

Definition at line 361 of file video.c.