Commit 6b09fabb authored by hybrid's avatar hybrid

Also updated the WinCE device.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1371 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 32ae11b4
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#endif #endif
namespace irr namespace irr
{ {
namespace video namespace video
...@@ -276,47 +275,38 @@ namespace irr ...@@ -276,47 +275,38 @@ namespace irr
{ {
//! constructor //! constructor
CIrrDeviceWinCE::CIrrDeviceWinCE(video::E_DRIVER_TYPE driverType, CIrrDeviceWinCE::CIrrDeviceWinCE(const SIrrlichtCreationParameters& params)
core::dimension2d<s32> windowSize, : CIrrDeviceStub(params), HWnd(reinterpret_cast<HWND>(CreationParams.WindowId)),
u32 bits, bool fullscreen, Win32CursorControl(0), ChangedToFullScreen(false), Resized(false),
bool stencilbuffer, bool vsync, ExternalWindow(false)
bool antiAlias,
bool highPrecisionFPU,
HWND externalWindow,
const SIrrlichtCreationParameters& params)
: CIrrDeviceStub(params), HWnd(externalWindow), ChangedToFullScreen(false),
FullScreen(fullscreen), Resized(false),
ExternalWindow(false), Win32CursorControl(0)
{ {
#ifdef _DEBUG
setDebugName("CIrrDeviceWinCE");
#endif
core::stringc winversion; core::stringc winversion;
getWindowsVersion(winversion); getWindowsVersion(winversion);
Operator = new COSOperator(winversion.c_str()); Operator = new COSOperator(winversion.c_str());
os::Printer::log(winversion.c_str(), ELL_INFORMATION); os::Printer::log(winversion.c_str(), ELL_INFORMATION);
// create window
HINSTANCE hInstance = GetModuleHandle(0); HINSTANCE hInstance = GetModuleHandle(0);
#ifdef _DEBUG // create the window only if we do not use the null device
setDebugName("CIrrDeviceWinCE"); if (!HWnd && (CreationParams.DriverType != video::EDT_NULL))
#endif
// create the window, only if we do not use the null device
if (driverType != video::EDT_NULL && HWnd==0)
{ {
const wchar_t* ClassName = L"CIrrDeviceWinCE"; const wchar_t* ClassName = L"CIrrDeviceWinCE";
// Register Class // Register Class
WNDCLASS wc; WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW; wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC)WndProc; wc.lpfnWndProc = (WNDPROC)WndProc;
wc.cbClsExtra = 0; wc.cbClsExtra = 0;
wc.cbWndExtra = 0; wc.cbWndExtra = 0;
wc.hInstance = hInstance; wc.hInstance = hInstance;
wc.hIcon = NULL; wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = 0; wc.lpszMenuName = 0;
wc.lpszClassName = ClassName; wc.lpszClassName = ClassName;
// if there is an icon, load it // if there is an icon, load it
...@@ -329,21 +319,21 @@ CIrrDeviceWinCE::CIrrDeviceWinCE(video::E_DRIVER_TYPE driverType, ...@@ -329,21 +319,21 @@ CIrrDeviceWinCE::CIrrDeviceWinCE(video::E_DRIVER_TYPE driverType,
RECT clientSize; RECT clientSize;
clientSize.top = 0; clientSize.top = 0;
clientSize.left = 0; clientSize.left = 0;
clientSize.right = windowSize.Width; clientSize.right = CreationParams.WindowSize.Width;
clientSize.bottom = windowSize.Height; clientSize.bottom = CreationParams.WindowSize.Height;
DWORD style = WS_POPUP; DWORD style = WS_POPUP;
if (!fullscreen) if (!CreationParams.Fullscreen)
style = WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; style = WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
AdjustWindowRectEx(&clientSize, style, FALSE, 0); AdjustWindowRectEx(&clientSize, style, FALSE, 0);
s32 realWidth = clientSize.right - clientSize.left; const s32 realWidth = clientSize.right - clientSize.left;
s32 realHeight = clientSize.bottom - clientSize.top; const s32 realHeight = clientSize.bottom - clientSize.top;
s32 windowLeft = core::s32_max ( 0, (GetSystemMetrics(SM_CXSCREEN) - realWidth) >> 1 ); const s32 windowLeft = core::s32_max ( 0, (GetSystemMetrics(SM_CXSCREEN) - realWidth) >> 1 );
s32 windowTop = core::s32_max ( 0, (GetSystemMetrics(SM_CYSCREEN) - realHeight) >> 1 ); const s32 windowTop = core::s32_max ( 0, (GetSystemMetrics(SM_CYSCREEN) - realHeight) >> 1 );
// create window // create window
...@@ -358,24 +348,24 @@ CIrrDeviceWinCE::CIrrDeviceWinCE(video::E_DRIVER_TYPE driverType, ...@@ -358,24 +348,24 @@ CIrrDeviceWinCE::CIrrDeviceWinCE(video::E_DRIVER_TYPE driverType,
} }
// attach external window // attach external window
if (externalWindow) if (CreationParams.WindowId)
{ {
RECT r; RECT r;
GetWindowRect(HWnd, &r); GetWindowRect(HWnd, &r);
windowSize.Width = r.right - r.left; CreationParams.WindowSize.Width = r.right - r.left;
windowSize.Height = r.bottom - r.top; CreationParams.WindowSize.Height = r.bottom - r.top;
fullscreen = false; CreationParams.Fullscreen = false;
ExternalWindow = true; ExternalWindow = true;
} }
// create cursor control // create cursor control
Win32CursorControl = new CCursorControl(windowSize, HWnd, fullscreen); Win32CursorControl = new CCursorControl(CreationParams.WindowSize, HWnd, CreationParams.Fullscreen);
CursorControl = Win32CursorControl; CursorControl = Win32CursorControl;
// create driver // create driver
createDriver(driverType, windowSize, bits, fullscreen, stencilbuffer, vsync, antiAlias, highPrecisionFPU); createDriver();
if (VideoDriver) if (VideoDriver)
createGUIAndScene(); createGUIAndScene();
...@@ -416,21 +406,14 @@ CIrrDeviceWinCE::~CIrrDeviceWinCE() ...@@ -416,21 +406,14 @@ CIrrDeviceWinCE::~CIrrDeviceWinCE()
//! create the driver //! create the driver
void CIrrDeviceWinCE::createDriver(video::E_DRIVER_TYPE driverType, void CIrrDeviceWinCE::createDriver()
const core::dimension2d<s32>& windowSize,
u32 bits,
bool fullscreen,
bool stencilbuffer,
bool vsync,
bool antiAlias,
bool highPrecisionFPU)
{ {
switch(driverType) switch(CreationParams.DriverType)
{ {
case video::EDT_DIRECT3D8: case video::EDT_DIRECT3D8:
#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ #ifdef _IRR_COMPILE_WITH_DIRECT3D_8_
VideoDriver = video::createDirectX8Driver(windowSize, HWnd, bits, fullscreen, VideoDriver = video::createDirectX8Driver(CreationParams.WindowSize, HWnd, CreationParams.Bits, CreationParams.Fullscreen,
stencilbuffer, FileSystem, false, highPrecisionFPU, vsync, antiAlias); CreationParams.Stencilbuffer, FileSystem, false, CreationParams.HighPrecisionFPU, CreationParams.Vsync, CreationParams.AntiAlias);
if (!VideoDriver) if (!VideoDriver)
{ {
os::Printer::log("Could not create DIRECT3D8 Driver.", ELL_ERROR); os::Printer::log("Could not create DIRECT3D8 Driver.", ELL_ERROR);
...@@ -443,8 +426,8 @@ void CIrrDeviceWinCE::createDriver(video::E_DRIVER_TYPE driverType, ...@@ -443,8 +426,8 @@ void CIrrDeviceWinCE::createDriver(video::E_DRIVER_TYPE driverType,
case video::EDT_DIRECT3D9: case video::EDT_DIRECT3D9:
#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
VideoDriver = video::createDirectX9Driver(windowSize, HWnd, bits, fullscreen, VideoDriver = video::createDirectX9Driver(CreationParams.WindowSize, HWnd, CreationParams.Bits, CreationParams.Fullscreen,
stencilbuffer, FileSystem, false, highPrecisionFPU, vsync, antiAlias); CreationParams.Stencilbuffer, FileSystem, false, CreationParams.HighPrecisionFPU, CreationParams.Vsync, CreationParams.AntiAlias);
if (!VideoDriver) if (!VideoDriver)
{ {
os::Printer::log("Could not create DIRECT3D9 Driver.", ELL_ERROR); os::Printer::log("Could not create DIRECT3D9 Driver.", ELL_ERROR);
...@@ -458,9 +441,10 @@ void CIrrDeviceWinCE::createDriver(video::E_DRIVER_TYPE driverType, ...@@ -458,9 +441,10 @@ void CIrrDeviceWinCE::createDriver(video::E_DRIVER_TYPE driverType,
case video::EDT_OPENGL: case video::EDT_OPENGL:
#ifdef _IRR_COMPILE_WITH_OPENGL_ #ifdef _IRR_COMPILE_WITH_OPENGL_
if (fullscreen) switchToFullScreen(windowSize.Width, windowSize.Height, bits); if (CreationParams.Fullscreen)
VideoDriver = video::createOpenGLDriver(windowSize, HWnd, bits, fullscreen, stencilbuffer, FileSystem, switchToFullScreen();
vsync, antiAlias); VideoDriver = video::createOpenGLDriver(CreationParams.WindowSize, HWnd, CreationParams.Bits, CreationParams.Fullscreen, CreationParams.Stencilbuffer, FileSystem,
CreationParams.Vsync, CreationParams.AntiAlias);
if (!VideoDriver) if (!VideoDriver)
{ {
os::Printer::log("Could not create OpenGL driver.", ELL_ERROR); os::Printer::log("Could not create OpenGL driver.", ELL_ERROR);
...@@ -473,8 +457,9 @@ void CIrrDeviceWinCE::createDriver(video::E_DRIVER_TYPE driverType, ...@@ -473,8 +457,9 @@ void CIrrDeviceWinCE::createDriver(video::E_DRIVER_TYPE driverType,
case video::EDT_SOFTWARE: case video::EDT_SOFTWARE:
#ifdef _IRR_COMPILE_WITH_SOFTWARE_ #ifdef _IRR_COMPILE_WITH_SOFTWARE_
if (fullscreen) switchToFullScreen(windowSize.Width, windowSize.Height, bits); if (CreationParams.Fullscreen)
VideoDriver = video::createSoftwareDriver(windowSize, fullscreen, FileSystem, this); switchToFullScreen();
VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this);
#else #else
os::Printer::log("Software driver was not compiled in.", ELL_ERROR); os::Printer::log("Software driver was not compiled in.", ELL_ERROR);
#endif #endif
...@@ -483,8 +468,9 @@ void CIrrDeviceWinCE::createDriver(video::E_DRIVER_TYPE driverType, ...@@ -483,8 +468,9 @@ void CIrrDeviceWinCE::createDriver(video::E_DRIVER_TYPE driverType,
case video::EDT_BURNINGSVIDEO: case video::EDT_BURNINGSVIDEO:
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
if (fullscreen) switchToFullScreen(windowSize.Width, windowSize.Height, bits); if (CreationParams.Fullscreen)
VideoDriver = video::createSoftwareDriver2(windowSize, fullscreen, FileSystem, this); switchToFullScreen();
VideoDriver = video::createSoftwareDriver2(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this);
#else #else
os::Printer::log("Burning's Video driver was not compiled in.", ELL_ERROR); os::Printer::log("Burning's Video driver was not compiled in.", ELL_ERROR);
#endif #endif
...@@ -492,7 +478,7 @@ void CIrrDeviceWinCE::createDriver(video::E_DRIVER_TYPE driverType, ...@@ -492,7 +478,7 @@ void CIrrDeviceWinCE::createDriver(video::E_DRIVER_TYPE driverType,
case video::EDT_NULL: case video::EDT_NULL:
// create null driver // create null driver
VideoDriver = video::createNullDriver(FileSystem, windowSize); VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
break; break;
default: default:
...@@ -502,7 +488,6 @@ void CIrrDeviceWinCE::createDriver(video::E_DRIVER_TYPE driverType, ...@@ -502,7 +488,6 @@ void CIrrDeviceWinCE::createDriver(video::E_DRIVER_TYPE driverType,
} }
//! runs the device. Returns false if device wants to be deleted //! runs the device. Returns false if device wants to be deleted
bool CIrrDeviceWinCE::run() bool CIrrDeviceWinCE::run()
{ {
...@@ -537,9 +522,9 @@ bool CIrrDeviceWinCE::run() ...@@ -537,9 +522,9 @@ bool CIrrDeviceWinCE::run()
void CIrrDeviceWinCE::yield() void CIrrDeviceWinCE::yield()
{ {
Sleep(1); Sleep(1);
} }
//! Pause execution and let other processes to run for a specified amount of time. //! Pause execution and let other processes to run for a specified amount of time.
void CIrrDeviceWinCE::sleep(u32 timeMs, bool pauseTimer) void CIrrDeviceWinCE::sleep(u32 timeMs, bool pauseTimer)
{ {
...@@ -581,16 +566,14 @@ void CIrrDeviceWinCE::resizeIfNecessary() ...@@ -581,16 +566,14 @@ void CIrrDeviceWinCE::resizeIfNecessary()
} }
//! sets the caption of the window //! sets the caption of the window
void CIrrDeviceWinCE::setWindowCaption(const wchar_t* text) void CIrrDeviceWinCE::setWindowCaption(const wchar_t* text)
{ {
SetWindowTextW(HWnd, text); SetWindowTextW(HWnd, text);
} }
#if !defined(BITMAPV4HEADER)
#if !defined(BITMAPV4HEADER)
typedef struct { typedef struct {
DWORD bV4Size; DWORD bV4Size;
LONG bV4Width; LONG bV4Width;
...@@ -612,6 +595,7 @@ typedef struct { ...@@ -612,6 +595,7 @@ typedef struct {
} BITMAPV4HEADER, *PBITMAPV4HEADER; } BITMAPV4HEADER, *PBITMAPV4HEADER;
#endif #endif
//! presents a surface in the client area //! presents a surface in the client area
void CIrrDeviceWinCE::present(video::IImage* image, void* windowId, core::rect<s32>* src) void CIrrDeviceWinCE::present(video::IImage* image, void* windowId, core::rect<s32>* src)
{ {
...@@ -655,7 +639,6 @@ void CIrrDeviceWinCE::present(video::IImage* image, void* windowId, core::rect<s ...@@ -655,7 +639,6 @@ void CIrrDeviceWinCE::present(video::IImage* image, void* windowId, core::rect<s
memory, (const BITMAPINFO*)(&bi), DIB_RGB_COLORS, SRCCOPY); memory, (const BITMAPINFO*)(&bi), DIB_RGB_COLORS, SRCCOPY);
} }
image->unlock(); image->unlock();
ReleaseDC(hwnd, dc); ReleaseDC(hwnd, dc);
...@@ -663,7 +646,6 @@ void CIrrDeviceWinCE::present(video::IImage* image, void* windowId, core::rect<s ...@@ -663,7 +646,6 @@ void CIrrDeviceWinCE::present(video::IImage* image, void* windowId, core::rect<s
} }
//! notifies the device that it should close itself //! notifies the device that it should close itself
void CIrrDeviceWinCE::closeDevice() void CIrrDeviceWinCE::closeDevice()
{ {
...@@ -687,10 +669,10 @@ bool CIrrDeviceWinCE::isWindowActive() const ...@@ -687,10 +669,10 @@ bool CIrrDeviceWinCE::isWindowActive() const
//! switches to fullscreen //! switches to fullscreen
bool CIrrDeviceWinCE::switchToFullScreen(s32 width, s32 height, s32 bits) bool CIrrDeviceWinCE::switchToFullScreen()
{ {
ChangedToFullScreen = SHFullScreen(HWnd, SHFS_HIDESIPBUTTON | SHFS_HIDETASKBAR) != 0; ChangedToFullScreen = SHFullScreen(HWnd, SHFS_HIDESIPBUTTON | SHFS_HIDETASKBAR) != 0;
return ChangedToFullScreen; return ChangedToFullScreen;
} }
...@@ -701,8 +683,8 @@ CIrrDeviceWinCE::CCursorControl* CIrrDeviceWinCE::getWin32CursorControl() ...@@ -701,8 +683,8 @@ CIrrDeviceWinCE::CCursorControl* CIrrDeviceWinCE::getWin32CursorControl()
} }
//! \return Returns a pointer to a list with all video modes supported //! Return pointer to a list with all video modes supported by the gfx adapter.
//! by the gfx adapter. /** \return Pointer to video modes list */
video::IVideoModeList* CIrrDeviceWinCE::getVideoModeList() video::IVideoModeList* CIrrDeviceWinCE::getVideoModeList()
{ {
if (!VideoModeList.getVideoModeCount()) if (!VideoModeList.getVideoModeCount())
...@@ -734,16 +716,18 @@ void CIrrDeviceWinCE::getWindowsVersion(core::stringc& out) ...@@ -734,16 +716,18 @@ void CIrrDeviceWinCE::getWindowsVersion(core::stringc& out)
out = "WinCE"; out = "WinCE";
} }
//! Notifies the device, that it has been resized //! Notifies the device, that it has been resized
void CIrrDeviceWinCE::OnResized() void CIrrDeviceWinCE::OnResized()
{ {
Resized = true; Resized = true;
} }
//! Sets if the window should be resizeable in windowed mode. //! Sets if the window should be resizeable in windowed mode.
void CIrrDeviceWinCE::setResizeAble(bool resize) void CIrrDeviceWinCE::setResizeAble(bool resize)
{ {
if (ExternalWindow || !getVideoDriver() || FullScreen) if (ExternalWindow || !getVideoDriver() || CreationParams.Fullscreen)
return; return;
LONG style = WS_POPUP; LONG style = WS_POPUP;
...@@ -764,11 +748,11 @@ void CIrrDeviceWinCE::setResizeAble(bool resize) ...@@ -764,11 +748,11 @@ void CIrrDeviceWinCE::setResizeAble(bool resize)
AdjustWindowRectEx(&clientSize, style, FALSE, 0); AdjustWindowRectEx(&clientSize, style, FALSE, 0);
s32 realWidth = clientSize.right - clientSize.left; const s32 realWidth = clientSize.right - clientSize.left;
s32 realHeight = clientSize.bottom - clientSize.top; const s32 realHeight = clientSize.bottom - clientSize.top;
s32 windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2; const s32 windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2;
s32 windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2; const s32 windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2;
SetWindowPos(HWnd, HWND_TOP, windowLeft, windowTop, realWidth, realHeight, SetWindowPos(HWnd, HWND_TOP, windowLeft, windowTop, realWidth, realHeight,
SWP_FRAMECHANGED | SWP_NOMOVE | SWP_SHOWWINDOW); SWP_FRAMECHANGED | SWP_NOMOVE | SWP_SHOWWINDOW);
...@@ -776,19 +760,9 @@ void CIrrDeviceWinCE::setResizeAble(bool resize) ...@@ -776,19 +760,9 @@ void CIrrDeviceWinCE::setResizeAble(bool resize)
IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx( IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(
const SIrrlichtCreationParameters& parameters) const SIrrlichtCreationParameters& parameters)
{ {
CIrrDeviceWinCE* dev = new CIrrDeviceWinCE( CIrrDeviceWinCE* dev = new CIrrDeviceWinCE(parameters);
parameters.DriverType,
parameters.WindowSize,
parameters.Bits,
parameters.Fullscreen,
parameters.Stencilbuffer,
parameters.Vsync,
parameters.AntiAlias,
parameters.HighPrecisionFPU,
reinterpret_cast<HWND>(parameters.WindowId),
parameters);
if (dev && !dev->getVideoDriver() && parameters.DriverType != video::EDT_NULL) if (dev && !dev->getVideoDriver() && parameters.DriverType != video::EDT_NULL)
{ {
......
...@@ -26,11 +26,8 @@ namespace irr ...@@ -26,11 +26,8 @@ namespace irr
public: public:
//! constructor //! constructor
CIrrDeviceWinCE(video::E_DRIVER_TYPE deviceType, CIrrDeviceWinCE(
core::dimension2d<s32> windowSize, u32 bits, core::dimension2d<s32> windowSize,
bool fullscreen, bool stencilbuffer, bool vsync,
bool antiAlias, bool highPrecisionFPU,
HWND window,
const SIrrlichtCreationParameters& params); const SIrrlichtCreationParameters& params);
//! destructor //! destructor
...@@ -235,24 +232,21 @@ namespace irr ...@@ -235,24 +232,21 @@ namespace irr
private: private:
//! create the driver //! create the driver
void createDriver(video::E_DRIVER_TYPE driverType, void createDriver();
const core::dimension2d<s32>& windowSize, u32 bits, bool fullscreen,
bool stencilbuffer, bool vsync, bool antiAlias, bool highPrecisionFPU);
//! switchs to fullscreen //! switchs to fullscreen
bool switchToFullScreen(s32 width, s32 height, s32 bits); bool switchToFullScreen();
void getWindowsVersion(core::stringc& version); void getWindowsVersion(core::stringc& version);
void resizeIfNecessary(); void resizeIfNecessary();
HWND HWnd; HWND HWnd;
CCursorControl* Win32CursorControl;
bool ChangedToFullScreen; bool ChangedToFullScreen;
bool FullScreen;
bool Resized; bool Resized;
bool ExternalWindow; bool ExternalWindow;
CCursorControl* Win32CursorControl;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment