SDL is now fully shut down with the RPi renderer.

This commit is contained in:
Aloshi 2012-09-29 13:14:31 -05:00
parent 7e6498df60
commit e08391080b
3 changed files with 32 additions and 21 deletions

View file

@ -1,3 +1,6 @@
September 29
-SDL is now completely shut down on both the RPi and SDL GL renderer. You may see the flicker of a terminal when you launch a game. This was done in preparation for audio.
September 23
-Fixed crash when "%ROM%" isn't present in a launch command. Not sure why you'd ever do this on purpose, but hey.
-Added relative path operator ("./") support for gamelist.xml, for both game paths and image paths.

View file

@ -6,9 +6,13 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include "Font.h"
#include <SDL/SDL.h>
#include "InputManager.h"
namespace Renderer
{
SDL_Surface* sdlScreen;
EGLDisplay display;
EGLSurface surface;
EGLContext context;
@ -24,6 +28,26 @@ namespace Renderer
bool createSurface() //unsigned int display_width, unsigned int display_height)
{
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) != 0)
{
std::cerr << "Error initializing SDL!\n";
std::cerr << SDL_GetError() << "\n";
std::cerr << "Are you in the 'video' and 'input' groups? Is X closed? Is your firmware up to date? Are you using at least the 192/64 memory split?\n";
return false;
}
sdlScreen = SDL_SetVideoMode(1, 1, 0, SDL_SWSURFACE);
if(sdlScreen == NULL)
{
std::cerr << "Error creating SDL window for input!\n";
return false;
}
//have to reload config to re-open SDL joysticks
InputManager::loadConfig();
std::cout << "Creating surface...";
DISPMANX_ELEMENT_HANDLE_T dispman_element;
@ -148,6 +172,10 @@ namespace Renderer
void destroySurface()
{
SDL_FreeSurface(sdlScreen);
sdlScreen = NULL;
SDL_Quit();
eglSwapBuffers(display, surface);
eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglDestroySurface(display, surface);

View file

@ -71,27 +71,7 @@ int main(int argc, char* argv[])
bool running = true;
//desktop uses SDL to set up an OpenGL context, and has its own SDL window...so I #ifdefed here.
//this should be moved to the RPi init/deinit file
//ALWAYS INITIALIZE VIDEO. It starts SDL's event system, and without it, input won't work.
#ifdef _RPI_
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) != 0)
{
std::cerr << "Error - could not initialize SDL!\n";
std::cerr << " " << SDL_GetError() << "\n";
std::cerr << "Are you in the 'video' and 'input' groups? Are you running with X closed? Is your firmware up to date? Are you using at least the 192/64 memory split?\n";
return 1;
}
SDL_Surface* sdlScreen = SDL_SetVideoMode(1, 1, 0, SDL_SWSURFACE);
if(sdlScreen == NULL)
{
std::cerr << "Error initializing SDL screen!\n";
running = false;
}
#endif
//the renderer also takes care of setting up SDL for input
bool renderInit = Renderer::init(width, height);
if(!renderInit)
{