Skip to content

Commit

Permalink
SDL: Move init() method into base
Browse files Browse the repository at this point in the history
  • Loading branch information
vasi committed Apr 24, 2013
1 parent 19529ca commit 9e807c8
Showing 1 changed file with 11 additions and 33 deletions.
44 changes: 11 additions & 33 deletions BasiliskII/src/SDL/video_sdl.cpp
Expand Up @@ -600,7 +600,7 @@ static void migrate_screen_prefs(void)
class driver_base {
public:
driver_base(SDL_monitor_desc &m);
virtual void init();
void init();
~driver_base();

void update_palette(void);
Expand Down Expand Up @@ -631,13 +631,11 @@ static void update_display_static(driver_base *drv);
class driver_window : public driver_base {
public:
driver_window(SDL_monitor_desc &monitor);
virtual void init();
};

class driver_fullscreen : public driver_base {
public:
driver_fullscreen(SDL_monitor_desc &monitor);
virtual void init();
};

static driver_base *drv = NULL; // Pointer to currently used driver object
Expand All @@ -657,6 +655,16 @@ void driver_base::init()
{
int aligned_height = (VIDEO_MODE_Y + 15) & ~15;
int depth = sdl_depth_of_video_depth(VIDEO_MODE_DEPTH);
int width = VIDEO_MODE_X, height = VIDEO_MODE_Y;

ADBSetRelMouseMode(mouse_grabbed);

// Create surface
int flags = SDL_HWSURFACE;
if (display_type == DISPLAY_SCREEN)
flags |= SDL_FULLSCREEN;
if ((s = SDL_SetVideoMode(width, height, depth, flags)) == NULL)
return;

#ifdef ENABLE_VOSF
use_vosf = true;
Expand Down Expand Up @@ -796,21 +804,6 @@ driver_window::driver_window(SDL_monitor_desc &m)
{
}

void driver_window::init()
{
int width = VIDEO_MODE_X, height = VIDEO_MODE_Y;

// Set absolute mouse mode
ADBSetRelMouseMode(mouse_grabbed);

// Create surface
int depth = sdl_depth_of_video_depth(VIDEO_MODE_DEPTH);
if ((s = SDL_SetVideoMode(width, height, depth, SDL_HWSURFACE)) == NULL)
return;

driver_base::init();
}

// Toggle mouse grab
void driver_base::toggle_mouse_grab(void)
{
Expand Down Expand Up @@ -856,21 +849,6 @@ driver_fullscreen::driver_fullscreen(SDL_monitor_desc &m)
{
}

void driver_fullscreen::init()
{
int width = VIDEO_MODE_X, height = VIDEO_MODE_Y;

// Set absolute mouse mode
ADBSetRelMouseMode(false);

// Create surface
int depth = sdl_depth_of_video_depth(VIDEO_MODE_DEPTH);
if ((s = SDL_SetVideoMode(width, height, depth, SDL_HWSURFACE | SDL_FULLSCREEN)) == NULL)
return;

driver_base::init();
}


/*
* Initialization
Expand Down

0 comments on commit 9e807c8

Please sign in to comment.