If you're trying to get every bit of performance out of the system, you can actually create a 0x0 window that is strictly software and all of the input events seem to work fine. Something like:
Code: Select all
SDL_SetVideoMode(0, 0, 32, SDL_SWSURFACE);
Apparently SDL can operate without the use of X somehow (trying to lauch it without X causes it to try to access the device framebuffer). If I can ever get it to work, that would be even more overhead removed.
And for someone who happens to stumble onto this thread in a search, here is a basic EGL init function (it took me several hours to figure out to check the hello_triangles example file, not realizing that the raspi doesn't have a standard EGL init process). Note this will init a GLES 2 context. Set screen_width and screen_height to 0 to get the maximum size, otherwise the passed width and height are used, and the surface is centered on the screen.
Code: Select all
void initEGL(EGLDisplay& display, EGLSurface& surface, EGLContext& context,
Uint32& screen_width, Uint32& screen_height) {
bcm_host_init();
int32_t success = 0;
EGLBoolean result;
EGLint num_config;
static EGL_DISPMANX_WINDOW_T nativewindow;
DISPMANX_ELEMENT_HANDLE_T dispman_element;
DISPMANX_DISPLAY_HANDLE_T dispman_display;
DISPMANX_UPDATE_HANDLE_T dispman_update;
VC_RECT_T dst_rect;
VC_RECT_T src_rect;
static const EGLint attribute_list[] =
{
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 8,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_NONE
};
static const EGLint context_attributes[] =
{
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
EGLConfig config;
// get an EGL display connection
display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
assert(display!=EGL_NO_DISPLAY);
// initialize the EGL display connection
result = eglInitialize(display, NULL, NULL);
assert(EGL_FALSE != result);
// get an appropriate EGL frame buffer configuration
result = eglChooseConfig(display, attribute_list, &config, 1, &num_config);
assert(EGL_FALSE != result);
// create an EGL rendering context
context = eglCreateContext(display, config, EGL_NO_CONTEXT,
context_attributes);
assert(context!=EGL_NO_CONTEXT);
// create an EGL window surface
Uint32 maxW, maxH;
success = graphics_get_display_size(0 /* LCD */, &maxW,
&maxH);
assert( success >= 0 );
if(screen_width == 0) {
screen_width = maxW; screen_height = maxH;
dst_rect.x = 0;
dst_rect.y = 0;
} else {
dst_rect.x = (maxW - screen_width)/2;
dst_rect.y = (maxH - screen_height)/2;
}
dst_rect.width = screen_width;
dst_rect.height = screen_height;
src_rect.x = 0;
src_rect.y = 0;
src_rect.width = screen_width << 16;
src_rect.height = screen_height << 16;
dispman_display = vc_dispmanx_display_open( 0 /* LCD */);
dispman_update = vc_dispmanx_update_start( 0 );
dispman_element = vc_dispmanx_element_add(dispman_update, dispman_display,
0, &dst_rect, 0, &src_rect,
DISPMANX_PROTECTION_NONE, 0, 0,
(DISPMANX_TRANSFORM_T)0);
nativewindow.element = dispman_element;
nativewindow.width = screen_width;
nativewindow.height = screen_height;
vc_dispmanx_update_submit_sync( dispman_update );
surface = eglCreateWindowSurface(display, config, &nativewindow, NULL );
assert(surface != EGL_NO_SURFACE);
// connect the context to the surface
result = eglMakeCurrent(display, surface, surface, context);
assert(EGL_FALSE != result);
}