SDL  2.0
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_VideoDevicecreateDevice (int devindex)
static int available ()

Variables

static screen_context_t context
static screen_event_t event
VideoBootStrap QNX_bootstrap

Function Documentation

static int available ( )
static

Definition at line 356 of file video.c.

Referenced by SDL_VideoInit().

{
return 1;
}
static SDL_VideoDevice* createDevice ( int  devindex)
static

Creates the QNX video plugin used by SDL.

Parameters
devindexUnused
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.

static int createWindow ( _THIS  ,
SDL_Window window 
)
static

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

Parameters
_THIS
windowSDL 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().

{
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;
}
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
windowSDL window to get the buffer for
[out]pixlesHolds a pointer to the window's buffer
[out]formatHolds the pixel format for the buffer
[out]pitchHolds 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().

{
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;
}
return 0;
}
static void deleteDevice ( SDL_VideoDevice device)
static

Frees the plugin object created by createDevice().

Parameters
devicePlugin object to free

Definition at line 310 of file video.c.

References SDL_free.

Referenced by createDevice().

{
SDL_free(device);
}
static void destroyWindow ( _THIS  ,
SDL_Window window 
)
static

Destroys the native window associated with the given SDL window.

Parameters
_THIS
windowSDL 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().

{
if (impl) {
screen_destroy_window(impl->window);
window->driverdata = NULL;
}
}
static void hideWindow ( _THIS  ,
SDL_Window window 
)
static

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

Parameters
_THIS
windowSDL window to update

Definition at line 280 of file video.c.

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

Referenced by createDevice().

{
const int visible = 0;
screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_VISIBLE,
&visible);
}
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:
break;
default:
break;
}
}
}
static void setWindowSize ( _THIS  ,
SDL_Window window 
)
static

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

Parameters
_THIS
windowSDL 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().

{
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);
}
static void showWindow ( _THIS  ,
SDL_Window window 
)
static

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

Parameters
_THIS
windowSDL window to update

Definition at line 265 of file video.c.

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

Referenced by createDevice().

{
const int visible = 1;
screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_VISIBLE,
&visible);
}
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
windowThe window to update
rectsAn array of reectangular areas to update
numrectsRect 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().

{
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;
}
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().

{
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;
}
return 0;
}
static void videoQuit ( _THIS  )
static

Definition at line 59 of file video.c.

Referenced by createDevice().

{
}

Variable Documentation

screen_context_t context
static
screen_event_t event
static

Definition at line 26 of file video.c.

VideoBootStrap QNX_bootstrap
Initial value:
{
"qnx", "QNX Screen",
}

Definition at line 361 of file video.c.