SDL

From Pandora Wiki
Revision as of 16:21, 21 April 2013 by Notaz (talk | contribs) (Using SDL with OpenGL ES)
Jump to: navigation, search

SDL is popular library for graphics, sound and input. This page lists some things to know when using it on pandora.

Pandora optimized mode

The SDL library included in pandora has a special mode (SDL internal driver) to make use of OMAP's features, like hardware scaling and double buffering. This mode is disabled by default because it doesn't support windowed mode and has some compatibility problems with some games. Information about how to use it can be found in this readme.

Issues with standard SDL mode on pandora

Cursor drift in fullscreen mode

When cursor is hidden (after SDL_ShowCursor(0) is called), touchscreen coordinates start to drift away over time, i.e. if you touch center of the screen, SDL may start reporting you touched the right or left edge. This is because SDL switches to relative mouse mode and starts warping the cursor when it's hidden. This is supposedly intended for 3D action games where cursor should never hit edge of screen and player should be able to look at some direction by moving the mouse to single direction as much as he wants (on pandora that can be accomplished with nubs or external mouse). Because some games rely on that feature to be functional, when not needed it should be disabled manually by:

  • Setting environment variable SDL_MOUSE_RELATIVE=0, which can be easily done in launch script like this:
export SDL_MOUSE_RELATIVE=0
./yourapp

Using SDL with OpenGL ES

This can be accomplished with SDL_GetWMInfo() call to get the required handles, like:

SDL_SysWMinfo sysWmInfo;
SDL_VERSION(&sysWmInfo.version);
SDL_GetWMInfo(&sysWmInfo);
eglDisplay = eglGetDisplay((EGLNativeDisplayType)sysWmInfo.info.x11.display);
...
eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig, (NativeWindowType)sysWmInfo.info.x11.window, NULL);

This will allow to use GL on the window. Note that if you use fullscreen mode, because of how SGX drivers are implemented, you may get better performance if you don't specify display/window handles to run the GL driver in framebuffer mode, like this:

eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
...
eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig, NULL, NULL);

You should still create fullscreen SDL window to prevent interference with Xorg and to have working input. See also SGX driver operation modes.