(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
This commit is contained in:
@@ -3,11 +3,30 @@
|
||||
#ifndef VIDEO_COCOA_H
|
||||
#define VIDEO_COCOA_H
|
||||
|
||||
#include "../hal.h"
|
||||
#include "video_driver.hpp"
|
||||
|
||||
#include "../openttd.h"
|
||||
#include "../gfx.h"
|
||||
class VideoDriver_Cocoa: public VideoDriver {
|
||||
public:
|
||||
/* virtual */ bool CanProbe() { return true; }
|
||||
|
||||
extern const HalVideoDriver _cocoa_video_driver;
|
||||
/* virtual */ const char *Start(const char * const *param);
|
||||
|
||||
/* virtual */ void Stop();
|
||||
|
||||
/* virtual */ void MakeDirty(int left, int top, int width, int height);
|
||||
|
||||
/* virtual */ void MainLoop();
|
||||
|
||||
/* virtual */ bool ChangeResolution(int w, int h);
|
||||
|
||||
/* virtual */ void ToggleFullscreen(bool fullscreen);
|
||||
};
|
||||
|
||||
class FVideoDriver_Cocoa: public VideoDriverFactory<FVideoDriver_Cocoa> {
|
||||
public:
|
||||
/* virtual */ const char *GetName() { return "cocoa"; }
|
||||
/* virtual */ const char *GetDescription() { return "Cocoa Video Driver"; }
|
||||
/* virtual */ Driver *CreateInstance() { return new VideoDriver_Cocoa(); }
|
||||
};
|
||||
|
||||
#endif /* VIDEO_COCOA_H */
|
||||
|
@@ -65,10 +65,12 @@ extern "C" void HideMenuBar();
|
||||
|
||||
|
||||
#include "../stdafx.h"
|
||||
#include "../openttd.h"
|
||||
#include "../debug.h"
|
||||
#include "../macros.h"
|
||||
#include "../os/macosx/splash.h"
|
||||
#include "../variables.h"
|
||||
#include "../gfx.h"
|
||||
#include "cocoa_v.h"
|
||||
#include "cocoa_keys.h"
|
||||
#include "../blitter/factory.hpp"
|
||||
@@ -131,14 +133,13 @@ static void QZ_UpdatePalette(uint start, uint count);
|
||||
static void QZ_WarpCursor(int x, int y);
|
||||
static void QZ_ShowMouse();
|
||||
static void QZ_HideMouse();
|
||||
static void CocoaVideoFullScreen(bool full_screen);
|
||||
|
||||
|
||||
static NSAutoreleasePool *_ottd_autorelease_pool;
|
||||
static OTTDMain *_ottd_main;
|
||||
|
||||
|
||||
static struct CocoaVideoData {
|
||||
static struct VideoDriver_Cocoa::Data {
|
||||
bool isset;
|
||||
bool issetting;
|
||||
|
||||
@@ -366,7 +367,7 @@ static void QZ_KeyEvent(unsigned short keycode, unsigned short unicode, BOOL dow
|
||||
case QZ_RETURN:
|
||||
case QZ_f:
|
||||
if (down && (_cocoa_video_data.current_mods & NSCommandKeyMask)) {
|
||||
CocoaVideoFullScreen(!_fullscreen);
|
||||
_video_driver->ToggleFullscreen(!_fullscreen);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1319,9 +1320,9 @@ static uint32 QZ_FadeGammaIn(const OTTD_QuartzGammaTable* table)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char* QZ_SetVideoFullScreen(int width, int height)
|
||||
static const char* QZ_SetVideoToggleFullscreen(int width, int height)
|
||||
{
|
||||
const char* errstr = "QZ_SetVideoFullScreen error";
|
||||
const char* errstr = "QZ_SetVideoToggleFullscreen error";
|
||||
int exact_match;
|
||||
CFNumberRef number;
|
||||
int bpp;
|
||||
@@ -1707,7 +1708,7 @@ static const char* QZ_SetVideoMode(uint width, uint height, bool fullscreen)
|
||||
_cocoa_video_data.issetting = true;
|
||||
if (fullscreen) {
|
||||
/* Setup full screen video */
|
||||
ret = QZ_SetVideoFullScreen(width, height);
|
||||
ret = QZ_SetVideoToggleFullscreen(width, height);
|
||||
} else {
|
||||
/* Setup windowed video */
|
||||
ret = QZ_SetVideoWindowed(width, height);
|
||||
@@ -1970,7 +1971,9 @@ static void setupApplication()
|
||||
* Video driver interface *
|
||||
******************************************************************************/
|
||||
|
||||
static void CocoaVideoStop()
|
||||
static FVideoDriver_Cocoa iFVideoDriver_Cocoa;
|
||||
|
||||
void VideoDriver_Cocoa::Stop()
|
||||
{
|
||||
if (!_cocoa_video_started) return;
|
||||
|
||||
@@ -1981,7 +1984,7 @@ static void CocoaVideoStop()
|
||||
_cocoa_video_started = false;
|
||||
}
|
||||
|
||||
static const char *CocoaVideoStart(const char * const *parm)
|
||||
const char *VideoDriver_Cocoa::Start(const char * const *parm)
|
||||
{
|
||||
const char *ret;
|
||||
|
||||
@@ -1998,12 +2001,12 @@ static const char *CocoaVideoStart(const char * const *parm)
|
||||
QZ_VideoInit();
|
||||
|
||||
ret = QZ_SetVideoMode(_cur_resolution[0], _cur_resolution[1], _fullscreen);
|
||||
if (ret != NULL) CocoaVideoStop();
|
||||
if (ret != NULL) VideoDriver_Cocoa::Stop();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void CocoaVideoMakeDirty(int left, int top, int width, int height)
|
||||
void VideoDriver_Cocoa::MakeDirty(int left, int top, int width, int height)
|
||||
{
|
||||
if (_cocoa_video_data.num_dirty_rects < MAX_DIRTY_RECTS) {
|
||||
_cocoa_video_data.dirty_rects[_cocoa_video_data.num_dirty_rects].left = left;
|
||||
@@ -2014,41 +2017,32 @@ static void CocoaVideoMakeDirty(int left, int top, int width, int height)
|
||||
_cocoa_video_data.num_dirty_rects++;
|
||||
}
|
||||
|
||||
static void CocoaVideoMainLoop()
|
||||
void VideoDriver_Cocoa::MainLoop()
|
||||
{
|
||||
/* Start the main event loop */
|
||||
[NSApp run];
|
||||
}
|
||||
|
||||
static bool CocoaVideoChangeRes(int w, int h)
|
||||
bool VideoDriver_Cocoa::ChangeResolution(int w, int h)
|
||||
{
|
||||
const char *ret = QZ_SetVideoModeAndRestoreOnFailure((uint)w, (uint)h, _cocoa_video_data.fullscreen);
|
||||
if (ret != NULL) {
|
||||
DEBUG(driver, 0, "cocoa_v: CocoaVideoChangeRes failed with message: %s", ret);
|
||||
DEBUG(driver, 0, "cocoa_v: VideoDriver_Cocoa::ChangeResolution failed with message: %s", ret);
|
||||
}
|
||||
|
||||
return ret == NULL;
|
||||
}
|
||||
|
||||
static void CocoaVideoFullScreen(bool full_screen)
|
||||
void VideoDriver_Cocoa::ToggleFullscreen(bool full_screen)
|
||||
{
|
||||
const char *ret = QZ_SetVideoModeAndRestoreOnFailure(_cocoa_video_data.width, _cocoa_video_data.height, full_screen);
|
||||
if (ret != NULL) {
|
||||
DEBUG(driver, 0, "cocoa_v: CocoaVideoFullScreen failed with message: %s", ret);
|
||||
DEBUG(driver, 0, "cocoa_v: VideoDriver_Cocoa::ToggleFullscreen failed with message: %s", ret);
|
||||
}
|
||||
|
||||
_fullscreen = _cocoa_video_data.fullscreen;
|
||||
}
|
||||
|
||||
const HalVideoDriver _cocoa_video_driver = {
|
||||
CocoaVideoStart,
|
||||
CocoaVideoStop,
|
||||
CocoaVideoMakeDirty,
|
||||
CocoaVideoMainLoop,
|
||||
CocoaVideoChangeRes,
|
||||
CocoaVideoFullScreen,
|
||||
};
|
||||
|
||||
|
||||
/* This is needed since sometimes assert is called before the videodriver is initialized */
|
||||
void CocoaDialog(const char* title, const char* message, const char* buttonLabel)
|
||||
@@ -2058,14 +2052,14 @@ void CocoaDialog(const char* title, const char* message, const char* buttonLabel
|
||||
_cocoa_video_dialog = true;
|
||||
|
||||
wasstarted = _cocoa_video_started;
|
||||
if (!_cocoa_video_started && CocoaVideoStart(NULL) != NULL) {
|
||||
if (!_cocoa_video_started && VideoDriver_Cocoa::Start(NULL) != NULL) {
|
||||
fprintf(stderr, "%s: %s\n", title, message);
|
||||
return;
|
||||
}
|
||||
|
||||
NSRunAlertPanel([NSString stringWithCString: title], [NSString stringWithCString: message], [NSString stringWithCString: buttonLabel], nil, nil);
|
||||
|
||||
if (!wasstarted) CocoaVideoStop();
|
||||
if (!wasstarted) VideoDriver_Cocoa::Stop();
|
||||
|
||||
_cocoa_video_dialog = false;
|
||||
}
|
||||
|
@@ -119,8 +119,10 @@ static void *_dedicated_video_mem;
|
||||
extern bool SafeSaveOrLoad(const char *filename, int mode, int newgm, Subdirectory subdir);
|
||||
extern void SwitchMode(int new_mode);
|
||||
|
||||
static FVideoDriver_Dedicated iFVideoDriver_Dedicated;
|
||||
|
||||
static const char *DedicatedVideoStart(const char * const *parm)
|
||||
|
||||
const char *VideoDriver_Dedicated::Start(const char * const *parm)
|
||||
{
|
||||
int bpp = BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth();
|
||||
if (bpp == 0) _dedicated_video_mem = NULL;
|
||||
@@ -147,7 +149,7 @@ static const char *DedicatedVideoStart(const char * const *parm)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void DedicatedVideoStop()
|
||||
void VideoDriver_Dedicated::Stop()
|
||||
{
|
||||
#ifdef WIN32
|
||||
CloseWindowsConsoleThread();
|
||||
@@ -155,9 +157,9 @@ static void DedicatedVideoStop()
|
||||
free(_dedicated_video_mem);
|
||||
}
|
||||
|
||||
static void DedicatedVideoMakeDirty(int left, int top, int width, int height) {}
|
||||
static bool DedicatedVideoChangeRes(int w, int h) { return false; }
|
||||
static void DedicatedVideoFullScreen(bool fs) {}
|
||||
void VideoDriver_Dedicated::MakeDirty(int left, int top, int width, int height) {}
|
||||
bool VideoDriver_Dedicated::ChangeResolution(int w, int h) { return false; }
|
||||
void VideoDriver_Dedicated::ToggleFullscreen(bool fs) {}
|
||||
|
||||
#if defined(UNIX) || defined(__OS2__) || defined(PSP)
|
||||
static bool InputWaiting()
|
||||
@@ -232,7 +234,7 @@ static void DedicatedHandleKeyInput()
|
||||
IConsoleCmdExec(input_line); // execute command
|
||||
}
|
||||
|
||||
static void DedicatedVideoMainLoop()
|
||||
void VideoDriver_Dedicated::MainLoop()
|
||||
{
|
||||
uint32 cur_ticks = GetTime();
|
||||
uint32 next_tick = cur_ticks + 30;
|
||||
@@ -295,13 +297,4 @@ static void DedicatedVideoMainLoop()
|
||||
}
|
||||
}
|
||||
|
||||
const HalVideoDriver _dedicated_video_driver = {
|
||||
DedicatedVideoStart,
|
||||
DedicatedVideoStop,
|
||||
DedicatedVideoMakeDirty,
|
||||
DedicatedVideoMainLoop,
|
||||
DedicatedVideoChangeRes,
|
||||
DedicatedVideoFullScreen,
|
||||
};
|
||||
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
@@ -3,8 +3,30 @@
|
||||
#ifndef VIDEO_DEDICATED_H
|
||||
#define VIDEO_DEDICATED_H
|
||||
|
||||
#include "../hal.h"
|
||||
#include "video_driver.hpp"
|
||||
|
||||
extern const HalVideoDriver _dedicated_video_driver;
|
||||
class VideoDriver_Dedicated: public VideoDriver {
|
||||
public:
|
||||
/* virtual */ bool CanProbe() { return false; }
|
||||
|
||||
/* virtual */ const char *Start(const char * const *param);
|
||||
|
||||
/* virtual */ void Stop();
|
||||
|
||||
/* virtual */ void MakeDirty(int left, int top, int width, int height);
|
||||
|
||||
/* virtual */ void MainLoop();
|
||||
|
||||
/* virtual */ bool ChangeResolution(int w, int h);
|
||||
|
||||
/* virtual */ void ToggleFullscreen(bool fullscreen);
|
||||
};
|
||||
|
||||
class FVideoDriver_Dedicated: public VideoDriverFactory<FVideoDriver_Dedicated> {
|
||||
public:
|
||||
/* virtual */ const char *GetName() { return "dedicated"; }
|
||||
/* virtual */ const char *GetDescription() { return "Dedicated Video Driver"; }
|
||||
/* virtual */ Driver *CreateInstance() { return new VideoDriver_Dedicated(); }
|
||||
};
|
||||
|
||||
#endif /* VIDEO_DEDICATED_H */
|
||||
|
@@ -9,7 +9,9 @@
|
||||
#include "../blitter/factory.hpp"
|
||||
#include "null_v.h"
|
||||
|
||||
static const char* NullVideoStart(const char* const* parm)
|
||||
static FVideoDriver_Null iFVideoDriver_Null;
|
||||
|
||||
const char *VideoDriver_Null::Start(const char* const *parm)
|
||||
{
|
||||
_screen.width = _screen.pitch = _cur_resolution[0];
|
||||
_screen.height = _cur_resolution[1];
|
||||
@@ -19,11 +21,11 @@ static const char* NullVideoStart(const char* const* parm)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void NullVideoStop() { }
|
||||
void VideoDriver_Null::Stop() { }
|
||||
|
||||
static void NullVideoMakeDirty(int left, int top, int width, int height) {}
|
||||
void VideoDriver_Null::MakeDirty(int left, int top, int width, int height) {}
|
||||
|
||||
static void NullVideoMainLoop()
|
||||
void VideoDriver_Null::MainLoop()
|
||||
{
|
||||
uint i;
|
||||
|
||||
@@ -34,14 +36,6 @@ static void NullVideoMainLoop()
|
||||
}
|
||||
}
|
||||
|
||||
static bool NullVideoChangeRes(int w, int h) { return false; }
|
||||
static void NullVideoFullScreen(bool fs) {}
|
||||
bool VideoDriver_Null::ChangeResolution(int w, int h) { return false; }
|
||||
|
||||
const HalVideoDriver _null_video_driver = {
|
||||
NullVideoStart,
|
||||
NullVideoStop,
|
||||
NullVideoMakeDirty,
|
||||
NullVideoMainLoop,
|
||||
NullVideoChangeRes,
|
||||
NullVideoFullScreen,
|
||||
};
|
||||
void VideoDriver_Null::ToggleFullscreen(bool fs) {}
|
||||
|
@@ -3,8 +3,30 @@
|
||||
#ifndef VIDEO_NULL_H
|
||||
#define VIDEO_NULL_H
|
||||
|
||||
#include "../hal.h"
|
||||
#include "video_driver.hpp"
|
||||
|
||||
extern const HalVideoDriver _null_video_driver;
|
||||
class VideoDriver_Null: public VideoDriver {
|
||||
public:
|
||||
/* virtual */ bool CanProbe() { return false; }
|
||||
|
||||
/* virtual */ const char *Start(const char * const *param);
|
||||
|
||||
/* virtual */ void Stop();
|
||||
|
||||
/* virtual */ void MakeDirty(int left, int top, int width, int height);
|
||||
|
||||
/* virtual */ void MainLoop();
|
||||
|
||||
/* virtual */ bool ChangeResolution(int w, int h);
|
||||
|
||||
/* virtual */ void ToggleFullscreen(bool fullscreen);
|
||||
};
|
||||
|
||||
class FVideoDriver_Null: public VideoDriverFactory<FVideoDriver_Null> {
|
||||
public:
|
||||
/* virtual */ const char *GetName() { return "null"; }
|
||||
/* virtual */ const char *GetDescription() { return "Null Video Driver"; }
|
||||
/* virtual */ Driver *CreateInstance() { return new VideoDriver_Null(); }
|
||||
};
|
||||
|
||||
#endif /* VIDEO_NULL_H */
|
||||
|
@@ -17,6 +17,8 @@
|
||||
#include "sdl_v.h"
|
||||
#include <SDL.h>
|
||||
|
||||
static FVideoDriver_SDL iFVideoDriver_SDL;
|
||||
|
||||
static SDL_Surface *_sdl_screen;
|
||||
static bool _all_modes;
|
||||
|
||||
@@ -24,7 +26,7 @@ static bool _all_modes;
|
||||
static SDL_Rect _dirty_rects[MAX_DIRTY_RECTS];
|
||||
static int _num_dirty_rects;
|
||||
|
||||
static void SdlVideoMakeDirty(int left, int top, int width, int height)
|
||||
void VideoDriver_SDL::MakeDirty(int left, int top, int width, int height)
|
||||
{
|
||||
if (_num_dirty_rects < MAX_DIRTY_RECTS) {
|
||||
_dirty_rects[_num_dirty_rects].x = left;
|
||||
@@ -415,7 +417,7 @@ static int PollEvent()
|
||||
return -1;
|
||||
}
|
||||
|
||||
static const char *SdlVideoStart(const char * const *parm)
|
||||
const char *VideoDriver_SDL::Start(const char * const *parm)
|
||||
{
|
||||
char buf[30];
|
||||
|
||||
@@ -434,12 +436,12 @@ static const char *SdlVideoStart(const char * const *parm)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void SdlVideoStop()
|
||||
void VideoDriver_SDL::Stop()
|
||||
{
|
||||
SdlClose(SDL_INIT_VIDEO);
|
||||
}
|
||||
|
||||
static void SdlVideoMainLoop()
|
||||
void VideoDriver_SDL::MainLoop()
|
||||
{
|
||||
uint32 cur_ticks = SDL_CALL SDL_GetTicks();
|
||||
uint32 last_cur_ticks = cur_ticks;
|
||||
@@ -505,28 +507,19 @@ static void SdlVideoMainLoop()
|
||||
}
|
||||
}
|
||||
|
||||
static bool SdlVideoChangeRes(int w, int h)
|
||||
bool VideoDriver_SDL::ChangeResolution(int w, int h)
|
||||
{
|
||||
return CreateMainSurface(w, h);
|
||||
}
|
||||
|
||||
static void SdlVideoFullScreen(bool full_screen)
|
||||
void VideoDriver_SDL::ToggleFullscreen(bool fullscreen)
|
||||
{
|
||||
_fullscreen = full_screen;
|
||||
_fullscreen = fullscreen;
|
||||
GetVideoModes(); // get the list of available video modes
|
||||
if (_num_resolutions == 0 || !_video_driver->change_resolution(_cur_resolution[0], _cur_resolution[1])) {
|
||||
if (_num_resolutions == 0 || !this->ChangeResolution(_cur_resolution[0], _cur_resolution[1])) {
|
||||
// switching resolution failed, put back full_screen to original status
|
||||
_fullscreen ^= true;
|
||||
}
|
||||
}
|
||||
|
||||
const HalVideoDriver _sdl_video_driver = {
|
||||
SdlVideoStart,
|
||||
SdlVideoStop,
|
||||
SdlVideoMakeDirty,
|
||||
SdlVideoMainLoop,
|
||||
SdlVideoChangeRes,
|
||||
SdlVideoFullScreen,
|
||||
};
|
||||
|
||||
#endif /* WITH_SDL */
|
||||
|
@@ -3,8 +3,30 @@
|
||||
#ifndef VIDEO_SDL_H
|
||||
#define VIDEO_SDL_H
|
||||
|
||||
#include "../hal.h"
|
||||
#include "video_driver.hpp"
|
||||
|
||||
extern const HalVideoDriver _sdl_video_driver;
|
||||
class VideoDriver_SDL: public VideoDriver {
|
||||
public:
|
||||
/* virtual */ bool CanProbe() { return true; }
|
||||
|
||||
/* virtual */ const char *Start(const char * const *param);
|
||||
|
||||
/* virtual */ void Stop();
|
||||
|
||||
/* virtual */ void MakeDirty(int left, int top, int width, int height);
|
||||
|
||||
/* virtual */ void MainLoop();
|
||||
|
||||
/* virtual */ bool ChangeResolution(int w, int h);
|
||||
|
||||
/* virtual */ void ToggleFullscreen(bool fullscreen);
|
||||
};
|
||||
|
||||
class FVideoDriver_SDL: public VideoDriverFactory<FVideoDriver_SDL> {
|
||||
public:
|
||||
/* virtual */ const char *GetName() { return "sdl"; }
|
||||
/* virtual */ const char *GetDescription() { return "SDL Video Driver"; }
|
||||
/* virtual */ Driver *CreateInstance() { return new VideoDriver_SDL(); }
|
||||
};
|
||||
|
||||
#endif /* VIDEO_SDL_H */
|
||||
|
35
src/video/video_driver.hpp
Normal file
35
src/video/video_driver.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef VIDEO_VIDEO_DRIVER_HPP
|
||||
#define VIDEO_VIDEO_DRIVER_HPP
|
||||
|
||||
#include "../driver.h"
|
||||
|
||||
class VideoDriver: public Driver {
|
||||
public:
|
||||
virtual void MakeDirty(int left, int top, int width, int height) = 0;
|
||||
|
||||
virtual void MainLoop() = 0;
|
||||
|
||||
virtual bool ChangeResolution(int w, int h) = 0;
|
||||
|
||||
virtual void ToggleFullscreen(bool fullscreen) = 0;
|
||||
};
|
||||
|
||||
class VideoDriverFactoryBase: public DriverFactoryBase {
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class VideoDriverFactory: public VideoDriverFactoryBase {
|
||||
public:
|
||||
VideoDriverFactory() { this->RegisterDriver(((T *)this)->GetName(), Driver::DT_VIDEO); }
|
||||
|
||||
/**
|
||||
* Get the long, human readable, name for the Driver-class.
|
||||
*/
|
||||
const char *GetName();
|
||||
};
|
||||
|
||||
extern VideoDriver *_video_driver;
|
||||
|
||||
#endif /* VIDEO_VIDEO_DRIVER_HPP */
|
@@ -751,8 +751,9 @@ static void FindResolutions()
|
||||
SortResolutions(_num_resolutions);
|
||||
}
|
||||
|
||||
static FVideoDriver_Win32 iFVideoDriver_Win32;
|
||||
|
||||
static const char *Win32GdiStart(const char * const *parm)
|
||||
const char *VideoDriver_Win32::Start(const char * const *parm)
|
||||
{
|
||||
memset(&_wnd, 0, sizeof(_wnd));
|
||||
|
||||
@@ -774,7 +775,7 @@ static const char *Win32GdiStart(const char * const *parm)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void Win32GdiStop()
|
||||
void VideoDriver_Win32::Stop()
|
||||
{
|
||||
DeleteObject(_wnd.gdi_palette);
|
||||
DeleteObject(_wnd.dib_sect);
|
||||
@@ -786,7 +787,7 @@ static void Win32GdiStop()
|
||||
MyShowCursor(true);
|
||||
}
|
||||
|
||||
static void Win32GdiMakeDirty(int left, int top, int width, int height)
|
||||
void VideoDriver_Win32::MakeDirty(int left, int top, int width, int height)
|
||||
{
|
||||
RECT r = { left, top, left + width, top + height };
|
||||
|
||||
@@ -800,7 +801,7 @@ static void CheckPaletteAnim()
|
||||
InvalidateRect(_wnd.main_wnd, NULL, FALSE);
|
||||
}
|
||||
|
||||
static void Win32GdiMainLoop()
|
||||
void VideoDriver_Win32::MainLoop()
|
||||
{
|
||||
MSG mesg;
|
||||
uint32 cur_ticks = GetTickCount();
|
||||
@@ -873,7 +874,7 @@ static void Win32GdiMainLoop()
|
||||
}
|
||||
}
|
||||
|
||||
static bool Win32GdiChangeRes(int w, int h)
|
||||
bool VideoDriver_Win32::ChangeResolution(int w, int h)
|
||||
{
|
||||
_wnd.width = _wnd.width_org = w;
|
||||
_wnd.height = _wnd.height_org = h;
|
||||
@@ -883,16 +884,7 @@ static bool Win32GdiChangeRes(int w, int h)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void Win32GdiFullScreen(bool full_screen)
|
||||
void VideoDriver_Win32::ToggleFullscreen(bool full_screen)
|
||||
{
|
||||
MakeWindow(full_screen);
|
||||
}
|
||||
|
||||
const HalVideoDriver _win32_video_driver = {
|
||||
Win32GdiStart,
|
||||
Win32GdiStop,
|
||||
Win32GdiMakeDirty,
|
||||
Win32GdiMainLoop,
|
||||
Win32GdiChangeRes,
|
||||
Win32GdiFullScreen,
|
||||
};
|
||||
|
@@ -3,8 +3,30 @@
|
||||
#ifndef VIDEO_WIN32_H
|
||||
#define VIDEO_WIN32_H
|
||||
|
||||
#include "../hal.h"
|
||||
#include "video_driver.hpp"
|
||||
|
||||
extern const HalVideoDriver _win32_video_driver;
|
||||
class VideoDriver_Win32: public VideoDriver {
|
||||
public:
|
||||
/* virtual */ bool CanProbe() { return true; }
|
||||
|
||||
/* virtual */ const char *Start(const char * const *param);
|
||||
|
||||
/* virtual */ void Stop();
|
||||
|
||||
/* virtual */ void MakeDirty(int left, int top, int width, int height);
|
||||
|
||||
/* virtual */ void MainLoop();
|
||||
|
||||
/* virtual */ bool ChangeResolution(int w, int h);
|
||||
|
||||
/* virtual */ void ToggleFullscreen(bool fullscreen);
|
||||
};
|
||||
|
||||
class FVideoDriver_Win32: public VideoDriverFactory<FVideoDriver_Win32> {
|
||||
public:
|
||||
/* virtual */ const char *GetName() { return "win32"; }
|
||||
/* virtual */ const char *GetDescription() { return "Win32 Video Driver"; }
|
||||
/* virtual */ Driver *CreateInstance() { return new VideoDriver_Win32(); }
|
||||
};
|
||||
|
||||
#endif /* VIDEO_WIN32_H */
|
||||
|
Reference in New Issue
Block a user