Commit c0170c7c authored by bitplane's avatar bitplane

Allow multiple device types compiled in at the same time. Renamed...

Allow multiple device types compiled in at the same time. Renamed _IRR_USE_LINUX_DEVICE_ to _IRR_USE_X11_DEVICE_, added missing platform for Windows CE. Currently only tested in Linux (X11, SDL, console)

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2513 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 4ee90d29
Changes in 1.6 (??.??.2009) Changes in 1.6 (??.??.2009)
- Irrlicht can now come with multiple device types compiled in, the device to use is selected by SIrrlichtCreationParameters.DeviceType. This defaults to EIDT_BEST which automatically select the best device available starting with native, then X11, SDL and finally the console.
- Added support for EXP2 fog distribution. This required a change in the setFog parameters where now an enum value instead of the bool linear is given. - Added support for EXP2 fog distribution. This required a change in the setFog parameters where now an enum value instead of the bool linear is given.
......
#ifndef __E_DEVICE_TYPES_H_INCLUDED__
#define __E_DEVICE_TYPES_H_INCLUDED__
namespace irr
{
//! An enum for the different device types supported by the Irrlicht Engine.
enum E_DEVICE_TYPE
{
//! A device native to Microsoft Windows
/** This device uses the Win32 API and works in all versions of Windows. */
EIDT_WIN32,
//! A device native to Windows CE devices
/** This device works on Windows Mobile, Pocket PC and Microsoft SmartPhone devices */
EIDT_WINCE,
//! A device native to Unix style operating systems.
/** This device uses the X11 windowing system and works in Linux, Solaris, FreeBSD, OSX and
other operating systems which support X11. */
EIDT_X11,
//! A device native to Mac OSX
/** This device uses Apple's Cocoa API and works in Mac OSX 10.2 and above. */
EIDT_OSX,
//! A device which uses Simple DirectMedia Layer
/** The SDL device works under all platforms supported by SDL but first must be compiled
in by defining the IRR_USE_SDL_DEVICE macro in IrrCompileConfig.h */
EIDT_SDL,
//! A simple text only device supported by all platforms.
/** This device allows applications to run from the command line without opening a window.
It can render the output of the software drivers to the console as ASCII. It only supports
mouse and keyboard in Windows operating systems. */
EIDT_CONSOLE,
//! This selection allows Irrlicht to choose the best device from the ones available.
/** If this selection is chosen then Irrlicht will try to use the IrrlichtDevice native
to your operating system. If this is unavailable then the X11, SDL and then console device
will be tried. This ensures that Irrlicht will run even if your platform is unsupported,
although it may not be able to render anything. */
EIDT_BEST
};
} // end namespace irr
#endif // __E_DEVICE_TYPES_H_INCLUDED__
...@@ -18,51 +18,60 @@ ...@@ -18,51 +18,60 @@
//! The defines for different operating system are: //! The defines for different operating system are:
//! _IRR_XBOX_PLATFORM_ for XBox //! _IRR_XBOX_PLATFORM_ for XBox
//! _IRR_WINDOWS_ for all irrlicht supported Windows versions //! _IRR_WINDOWS_ for all irrlicht supported Windows versions
//! _IRR_WINDOWS_CE_PLATFORM_ for Windows CE
//! _IRR_WINDOWS_API_ for Windows or XBox //! _IRR_WINDOWS_API_ for Windows or XBox
//! _IRR_LINUX_PLATFORM_ for Linux (it is defined here if no other os is defined) //! _IRR_LINUX_PLATFORM_ for Linux (it is defined here if no other os is defined)
//! _IRR_SOLARIS_PLATFORM_ for Solaris //! _IRR_SOLARIS_PLATFORM_ for Solaris
//! _IRR_OSX_PLATFORM_ for Apple systems running OSX //! _IRR_OSX_PLATFORM_ for Apple systems running OSX
//! _IRR_POSIX_API_ for Posix compatible systems //! _IRR_POSIX_API_ for Posix compatible systems
//! _IRR_USE_SDL_DEVICE_ for platform independent SDL framework //! Note: PLATFORM defines the OS specific layer, API can group several platforms
//! _IRR_USE_CONSOLE_DEVICE_ for no windowing system, like for running as a service
//! _IRR_USE_WINDOWS_DEVICE_ for Windows API based device //! DEVICE is the windowing system used, several PLATFORMs support more than one DEVICE
//! _IRR_USE_WINDOWS_CE_DEVICE_ for Windows CE API based device //! Irrlicht can be compiled with more than one device
//! _IRR_USE_LINUX_DEVICE_ for X11 based device //! _IRR_COMPILE_WITH_WINDOWS_DEVICE_ for Windows API based device
//! _IRR_USE_OSX_DEVICE_ for Cocoa native windowing on OSX //! _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_ for Windows CE API based device
//! Note: PLATFORM defines the OS specific layer, API can groups several platforms //! _IRR_COMPILE_WITH_OSX_DEVICE_ for Cocoa native windowing on OSX
//! DEVICE is the windowing system used, several PLATFORMs support more than one DEVICE //! _IRR_COMPILE_WITH_X11_DEVICE_ for Linux X11 based device
//! Moreover, the DEVICE defined here is not directly related to the Irrlicht devices created in the app (but may depend on each other). //! _IRR_COMPILE_WITH_SDL_DEVICE_ for platform independent SDL framework
//! _IRR_COMPILE_WITH_CONSOLE_DEVICE_ for no windowing system, used as a fallback
//! Uncomment this line to compile with the SDL device instead of platform specific devices
//#define _IRR_USE_SDL_DEVICE_
//! Uncomment this line to compile with the SDL device
//! Uncomment this line to compile as a console application with no windowing system. Hardware drivers will be disabled. //#define _IRR_COMPILE_WITH_SDL_DEVICE_
//#define _IRR_USE_CONSOLE_DEVICE_
//! Comment this line to compile without the fallback console device.
#define _IRR_COMPILE_WITH_CONSOLE_DEVICE_
//! WIN32 for Windows32 //! WIN32 for Windows32
//! WIN64 for Windows64 //! WIN64 for Windows64
// The windows platform and API support SDL and WINDOW device // The windows platform and API support SDL and WINDOW device
#if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64) || defined(_WIN32_WCE) #if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64)
#define _IRR_WINDOWS_ #define _IRR_WINDOWS_
#define _IRR_WINDOWS_API_ #define _IRR_WINDOWS_API_
#if !defined(_IRR_USE_SDL_DEVICE_) && !defined(_IRR_USE_CONSOLE_DEVICE_) #define _IRR_COMPILE_WITH_WINDOWS_DEVICE_
#define _IRR_USE_WINDOWS_DEVICE_ #endif
#endif
//
#if defined(_WIN32_WCE)
#define _IRR_WINDOWS_
#define _IRR_WINDOWS_API_
#define _IRR_WINDOWS_CE_PLATFORM_
#define _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_
#endif #endif
#if defined(_MSC_VER) && (_MSC_VER < 1300) #if defined(_MSC_VER) && (_MSC_VER < 1300)
# error "Only Microsoft Visual Studio 7.0 and later are supported." # error "Only Microsoft Visual Studio 7.0 and later are supported."
#endif #endif
// XBox only suppots the native Window stuff // XBox only suppots the native Window stuff
#if defined(_XBOX) #if defined(_XBOX)
#undef _IRR_WINDOWS_ #undef _IRR_WINDOWS_
#define _IRR_XBOX_PLATFORM_ #define _IRR_XBOX_PLATFORM_
#define _IRR_WINDOWS_API_ #define _IRR_WINDOWS_API_
//#define _IRR_USE_WINDOWS_DEVICE_ //#define _IRR_COMPILE_WITH_WINDOWS_DEVICE_
#undef _IRR_USE_WINDOWS_DEVICE_ #undef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
//#define _IRR_USE_SDL_DEVICE_ //#define _IRR_COMPILE_WITH_SDL_DEVICE_
#include <xtl.h> #include <xtl.h>
#endif #endif
...@@ -72,9 +81,7 @@ ...@@ -72,9 +81,7 @@
#define MACOSX // legacy support #define MACOSX // legacy support
#endif #endif
#define _IRR_OSX_PLATFORM_ #define _IRR_OSX_PLATFORM_
#if !defined(_IRR_USE_LINUX_DEVICE_) && !defined(_IRR_USE_CONSOLE_DEVICE_) && !defined(_IRR_USE_SDL_DEVICE_) #define _IRR_COMPILE_WITH_OSX_DEVICE_
#define _IRR_USE_OSX_DEVICE_
#endif
#endif #endif
#if !defined(_IRR_WINDOWS_API_) && !defined(_IRR_OSX_PLATFORM_) #if !defined(_IRR_WINDOWS_API_) && !defined(_IRR_OSX_PLATFORM_)
...@@ -85,10 +92,7 @@ ...@@ -85,10 +92,7 @@
#define _IRR_LINUX_PLATFORM_ #define _IRR_LINUX_PLATFORM_
#endif #endif
#define _IRR_POSIX_API_ #define _IRR_POSIX_API_
#define _IRR_COMPILE_WITH_X11_DEVICE_
#if !defined(_IRR_USE_SDL_DEVICE_) && !defined(_IRR_USE_CONSOLE_DEVICE_)
#define _IRR_USE_LINUX_DEVICE_
#endif
#endif #endif
//! Define _IRR_COMPILE_WITH_JOYSTICK_SUPPORT_ if you want joystick events. //! Define _IRR_COMPILE_WITH_JOYSTICK_SUPPORT_ if you want joystick events.
...@@ -107,14 +111,14 @@ _IRR_COMPILE_WITH_DX9_DEV_PACK_. So you simply need to add something like this ...@@ -107,14 +111,14 @@ _IRR_COMPILE_WITH_DX9_DEV_PACK_. So you simply need to add something like this
to the compiler settings: -DIRR_COMPILE_WITH_DX9_DEV_PACK to the compiler settings: -DIRR_COMPILE_WITH_DX9_DEV_PACK
and this to the linker settings: -ld3dx9 -ld3dx8 and this to the linker settings: -ld3dx9 -ld3dx8
Microsoft have chosen to remove D3D8 headers from their recent DXSDKs, and Microsoft have chosen to remove D3D8 headers from their recent DXSDKs, and
so D3D8 support is now disabled by default. If you really want to build so D3D8 support is now disabled by default. If you really want to build
with D3D8 support, then you will have to source a DXSDK with the appropriate with D3D8 support, then you will have to source a DXSDK with the appropriate
headers, e.g. Summer 2004. This is a Microsoft issue, not an Irrlicht one. headers, e.g. Summer 2004. This is a Microsoft issue, not an Irrlicht one.
*/ */
#if defined(_IRR_WINDOWS_API_) && (!defined(__GNUC__) || defined(IRR_COMPILE_WITH_DX9_DEV_PACK)) #if defined(_IRR_WINDOWS_API_) && (!defined(__GNUC__) || defined(IRR_COMPILE_WITH_DX9_DEV_PACK))
//! Only define _IRR_COMPILE_WITH_DIRECT3D_8_ if you have an appropriate DXSDK, e.g. Summer 2004 //! Only define _IRR_COMPILE_WITH_DIRECT3D_8_ if you have an appropriate DXSDK, e.g. Summer 2004
//#define _IRR_COMPILE_WITH_DIRECT3D_8_ //#define _IRR_COMPILE_WITH_DIRECT3D_8_
#define _IRR_COMPILE_WITH_DIRECT3D_9_ #define _IRR_COMPILE_WITH_DIRECT3D_9_
...@@ -213,7 +217,7 @@ Note that the engine will run in D3D REF for this, which is a lot slower than HA ...@@ -213,7 +217,7 @@ Note that the engine will run in D3D REF for this, which is a lot slower than HA
#define _IRR_D3D_NO_SHADER_DEBUGGING #define _IRR_D3D_NO_SHADER_DEBUGGING
//! Define _IRR_D3D_USE_LEGACY_HLSL_COMPILER to enable the old HLSL compiler in recent DX SDKs //! Define _IRR_D3D_USE_LEGACY_HLSL_COMPILER to enable the old HLSL compiler in recent DX SDKs
/** This enables support for ps_1_x shaders for recent DX SDKs. Otherwise, support /** This enables support for ps_1_x shaders for recent DX SDKs. Otherwise, support
for this shader model is not available anymore in SDKs after Oct2006. You need to for this shader model is not available anymore in SDKs after Oct2006. You need to
distribute the OCT2006_d3dx9_31_x86.cab or OCT2006_d3dx9_31_x64.cab though, in order distribute the OCT2006_d3dx9_31_x86.cab or OCT2006_d3dx9_31_x64.cab though, in order
to provide the user with the proper DLL. That's why it's disabled by default. */ to provide the user with the proper DLL. That's why it's disabled by default. */
...@@ -409,8 +413,8 @@ precision will be lower but speed higher. currently X86 only ...@@ -409,8 +413,8 @@ precision will be lower but speed higher. currently X86 only
#undef BURNINGVIDEO_RENDERER_ULTRA_FAST #undef BURNINGVIDEO_RENDERER_ULTRA_FAST
#define BURNINGVIDEO_RENDERER_CE #define BURNINGVIDEO_RENDERER_CE
#undef _IRR_USE_WINDOWS_DEVICE_ #undef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
#define _IRR_USE_WINDOWS_CE_DEVICE_ #define _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_
//#define _IRR_WCHAR_FILESYSTEM //#define _IRR_WCHAR_FILESYSTEM
#undef _IRR_COMPILE_WITH_IRR_MESH_LOADER_ #undef _IRR_COMPILE_WITH_IRR_MESH_LOADER_
...@@ -454,13 +458,5 @@ precision will be lower but speed higher. currently X86 only ...@@ -454,13 +458,5 @@ precision will be lower but speed higher. currently X86 only
#undef _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ #undef _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
#endif #endif
//! Remove joystick support and hardware drivers when compiling as a service
#if defined(_IRR_USE_CONSOLE_DEVICE_)
#undef _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
#undef _IRR_COMPILE_WITH_OPENGL_
#undef _IRR_COMPILE_WITH_DIRECT3D_8_
#undef _IRR_COMPILE_WITH_DIRECT3D_9_
#endif
#endif // __IRR_COMPILE_CONFIG_H_INCLUDED__ #endif // __IRR_COMPILE_CONFIG_H_INCLUDED__
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
#include "IReferenceCounted.h" #include "IReferenceCounted.h"
#include "dimension2d.h" #include "dimension2d.h"
#include "IVideoDriver.h" #include "IVideoDriver.h"
#include "EDriverTypes.h" #include "EDriverTypes.h"
#include "EDeviceTypes.h"
#include "IEventReceiver.h" #include "IEventReceiver.h"
#include "ICursorControl.h" #include "ICursorControl.h"
#include "IVideoModeList.h" #include "IVideoModeList.h"
...@@ -229,11 +230,15 @@ namespace irr ...@@ -229,11 +230,15 @@ namespace irr
//! Get the current Gamma Value for the Display //! Get the current Gamma Value for the Display
virtual bool getGammaRamp(f32 &red, f32 &green, f32 &blue, virtual bool getGammaRamp(f32 &red, f32 &green, f32 &blue,
f32 &brightness, f32 &contrast) =0; f32 &brightness, f32 &contrast) =0;
//! Get the type of the device.
//! Allows to check which drivers are supported by the engine. /** This allows the user to check which windowing system is currently being
/** Even if true is returned the driver needs not be available used. */
for an actual configuration requested upon device creation. */ virtual E_DEVICE_TYPE getType() const = 0;
//! Check if a driver type is supported by the engine.
/** Even if true is returned the driver may not be available
for a configuration requested when creating the device. */
static bool isDriverSupported(video::E_DRIVER_TYPE driver) static bool isDriverSupported(video::E_DRIVER_TYPE driver)
{ {
switch (driver) switch (driver)
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
#ifndef __I_IRRLICHT_CREATION_PARAMETERS_H_INCLUDED__ #ifndef __I_IRRLICHT_CREATION_PARAMETERS_H_INCLUDED__
#define __I_IRRLICHT_CREATION_PARAMETERS_H_INCLUDED__ #define __I_IRRLICHT_CREATION_PARAMETERS_H_INCLUDED__
#include "EDriverTypes.h" #include "EDriverTypes.h"
#include "EDeviceTypes.h"
#include "dimension2d.h" #include "dimension2d.h"
namespace irr namespace irr
...@@ -17,7 +18,8 @@ namespace irr ...@@ -17,7 +18,8 @@ namespace irr
struct SIrrlichtCreationParameters struct SIrrlichtCreationParameters
{ {
//! Constructs a SIrrlichtCreationParameters structure with default values. //! Constructs a SIrrlichtCreationParameters structure with default values.
SIrrlichtCreationParameters() : SIrrlichtCreationParameters() :
DeviceType(EIDT_BEST),
DriverType(video::EDT_BURNINGSVIDEO), DriverType(video::EDT_BURNINGSVIDEO),
WindowSize(core::dimension2d<u32>(800, 600)), WindowSize(core::dimension2d<u32>(800, 600)),
Bits(16), Bits(16),
...@@ -42,7 +44,8 @@ namespace irr ...@@ -42,7 +44,8 @@ namespace irr
{*this = other;} {*this = other;}
SIrrlichtCreationParameters& operator=(const SIrrlichtCreationParameters& other) SIrrlichtCreationParameters& operator=(const SIrrlichtCreationParameters& other)
{ {
DeviceType = other.DeviceType;
DriverType = other.DriverType; DriverType = other.DriverType;
WindowSize = other.WindowSize; WindowSize = other.WindowSize;
Bits = other.Bits; Bits = other.Bits;
...@@ -60,8 +63,21 @@ namespace irr ...@@ -60,8 +63,21 @@ namespace irr
WindowId = other.WindowId; WindowId = other.WindowId;
return *this; return *this;
} }
//! Type of the device. //! Type of the device.
/** This setting decides the windowing system used by the device, most device types are native
to a specific operating system and so may not be available.
EIDT_WIN32 is only available on Windows desktops,
EIDT_WINCE is only available on Windows mobile devices,
EIDT_COCOA is only available on Mac OSX,
EIDT_X11 is available on Linux, Solaris, BSD and other operating systems which use X11,
EIDT_SDL is available on most systems if compiled in,
EIDT_CONSOLE is usually available but can only render to text,
EIDT_BEST will select the best available device for your operating system.
Default: EIDT_BEST. */
E_DEVICE_TYPE DeviceType;
//! Type of video driver used to render graphics.
/** This can currently be video::EDT_NULL, video::EDT_SOFTWARE, /** This can currently be video::EDT_NULL, video::EDT_SOFTWARE,
video::EDT_BURNINGSVIDEO, video::EDT_DIRECT3D8, video::EDT_BURNINGSVIDEO, video::EDT_DIRECT3D8,
video::EDT_DIRECT3D9, and video::EDT_OPENGL. video::EDT_DIRECT3D9, and video::EDT_OPENGL.
...@@ -83,7 +99,7 @@ namespace irr ...@@ -83,7 +99,7 @@ namespace irr
//! Specifies if the stencil buffer should be enabled. //! Specifies if the stencil buffer should be enabled.
/** Set this to true, if you want the engine be able to draw /** Set this to true, if you want the engine be able to draw
stencil buffer shadows. Note that not all devices are able to stencil buffer shadows. Note that not all drivers are able to
use the stencil buffer, hence it can be ignored during device use the stencil buffer, hence it can be ignored during device
creation. Without the stencil buffer no shadows will be drawn. creation. Without the stencil buffer no shadows will be drawn.
Default: false. */ Default: false. */
......
...@@ -42,7 +42,7 @@ CFileSystem::CFileSystem() ...@@ -42,7 +42,7 @@ CFileSystem::CFileSystem()
#endif #endif
setFileListSystem(FILESYSTEM_NATIVE); setFileListSystem(FILESYSTEM_NATIVE);
ArchiveLoader.push_back(new CArchiveLoaderZIP(this)); ArchiveLoader.push_back(new CArchiveLoaderZIP(this));
ArchiveLoader.push_back(new CArchiveLoaderMount(this)); ArchiveLoader.push_back(new CArchiveLoaderMount(this));
ArchiveLoader.push_back(new CArchiveLoaderPAK(this)); ArchiveLoader.push_back(new CArchiveLoaderPAK(this));
...@@ -161,7 +161,7 @@ bool CFileSystem::moveFileArchive(u32 sourceIndex, s32 relative) ...@@ -161,7 +161,7 @@ bool CFileSystem::moveFileArchive(u32 sourceIndex, s32 relative)
//! Adds an archive to the file system. //! Adds an archive to the file system.
bool CFileSystem::addFileArchive(const core::string<c16>& filename, bool ignoreCase, bool CFileSystem::addFileArchive(const core::string<c16>& filename, bool ignoreCase,
bool ignorePaths, E_FILE_ARCHIVE_TYPE archiveType) bool ignorePaths, E_FILE_ARCHIVE_TYPE archiveType)
{ {
IFileArchive* archive = 0; IFileArchive* archive = 0;
...@@ -214,7 +214,7 @@ bool CFileSystem::addFileArchive(const core::string<c16>& filename, bool ignoreC ...@@ -214,7 +214,7 @@ bool CFileSystem::addFileArchive(const core::string<c16>& filename, bool ignoreC
{ {
// try to open archive based on archive loader type // try to open archive based on archive loader type
io::IReadFile* file = 0; io::IReadFile* file = 0;
for (i = 0; i < ArchiveLoader.size(); ++i) for (i = 0; i < ArchiveLoader.size(); ++i)
{ {
...@@ -321,7 +321,7 @@ const core::string<c16>& CFileSystem::getWorkingDirectory() ...@@ -321,7 +321,7 @@ const core::string<c16>& CFileSystem::getWorkingDirectory()
WorkingDirectory[type].reserve(FILE_SYSTEM_MAX_PATH); WorkingDirectory[type].reserve(FILE_SYSTEM_MAX_PATH);
c16* r = (c16*) WorkingDirectory[type].c_str(); c16* r = (c16*) WorkingDirectory[type].c_str();
#if defined(_IRR_USE_WINDOWS_CE_DEVICE_) #if defined(_IRR_WINDOWS_CE_PLATFORM_)
#elif defined(_IRR_WINDOWS_API_) #elif defined(_IRR_WINDOWS_API_)
#if defined(_IRR_WCHAR_FILESYSTEM ) #if defined(_IRR_WCHAR_FILESYSTEM )
_wgetcwd(r, FILE_SYSTEM_MAX_PATH); _wgetcwd(r, FILE_SYSTEM_MAX_PATH);
...@@ -361,7 +361,7 @@ bool CFileSystem::changeWorkingDirectoryTo(const core::string<c16>& newDirectory ...@@ -361,7 +361,7 @@ bool CFileSystem::changeWorkingDirectoryTo(const core::string<c16>& newDirectory
{ {
WorkingDirectory[FILESYSTEM_NATIVE] = newDirectory; WorkingDirectory[FILESYSTEM_NATIVE] = newDirectory;
#if defined(_IRR_USE_WINDOWS_CE_DEVICE_) #if defined(_IRR_WINDOWS_CE_PLATFORM_)
success = true; success = true;
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
#if defined(_IRR_WCHAR_FILESYSTEM) #if defined(_IRR_WCHAR_FILESYSTEM)
...@@ -382,7 +382,7 @@ core::string<c16> CFileSystem::getAbsolutePath(const core::string<c16>& filename ...@@ -382,7 +382,7 @@ core::string<c16> CFileSystem::getAbsolutePath(const core::string<c16>& filename
{ {
c16 *p=0; c16 *p=0;
#if defined(_IRR_USE_WINDOWS_CE_DEVICE_) #if defined(_IRR_WINDOWS_CE_PLATFORM_)
return filename; return filename;
#elif defined(_IRR_WINDOWS_API_) #elif defined(_IRR_WINDOWS_API_)
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "CIrrDeviceConsole.h" #include "CIrrDeviceConsole.h"
#ifdef _IRR_USE_CONSOLE_DEVICE_ #ifdef _IRR_COMPILE_WITH_CONSOLE_DEVICE_
#include "os.h" #include "os.h"
#include "IGUISkin.h" #include "IGUISkin.h"
...@@ -90,7 +90,7 @@ CIrrDeviceConsole::CIrrDeviceConsole(const SIrrlichtCreationParameters& params) ...@@ -90,7 +90,7 @@ CIrrDeviceConsole::CIrrDeviceConsole(const SIrrlichtCreationParameters& params)
ConsoleSize.X = CreationParams.WindowSize.Height; ConsoleSize.X = CreationParams.WindowSize.Height;
SetConsoleScreenBufferSize(WindowsSTDOut, ConsoleSize); SetConsoleScreenBufferSize(WindowsSTDOut, ConsoleSize);
} }
// catch windows close/break signals // catch windows close/break signals
SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleHandler, TRUE); SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleHandler, TRUE);
...@@ -129,7 +129,7 @@ CIrrDeviceConsole::CIrrDeviceConsole(const SIrrlichtCreationParameters& params) ...@@ -129,7 +129,7 @@ CIrrDeviceConsole::CIrrDeviceConsole(const SIrrlichtCreationParameters& params)
case video::EDT_DIRECT3D8: case video::EDT_DIRECT3D8:
case video::EDT_DIRECT3D9: case video::EDT_DIRECT3D9:
case video::EDT_OPENGL: case video::EDT_OPENGL:
os::Printer::log("The console device cannot use hardware drivers", ELL_ERROR); os::Printer::log("The console device cannot use hardware drivers yet.", ELL_ERROR);
break; break;
case video::EDT_NULL: case video::EDT_NULL:
VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize); VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
...@@ -151,7 +151,7 @@ CIrrDeviceConsole::CIrrDeviceConsole(const SIrrlichtCreationParameters& params) ...@@ -151,7 +151,7 @@ CIrrDeviceConsole::CIrrDeviceConsole(const SIrrlichtCreationParameters& params)
#ifdef _IRR_WINDOWS_NT_CONSOLE_ #ifdef _IRR_WINDOWS_NT_CONSOLE_
CursorControl = new CCursorControl(CreationParams.WindowSize); CursorControl = new CCursorControl(CreationParams.WindowSize);
#endif #endif
if (VideoDriver) if (VideoDriver)
{ {
...@@ -186,7 +186,7 @@ CIrrDeviceConsole::~CIrrDeviceConsole() ...@@ -186,7 +186,7 @@ CIrrDeviceConsole::~CIrrDeviceConsole()
ConsoleFont = 0; ConsoleFont = 0;
} }
#ifdef _IRR_VT100_CONSOLE_ #ifdef _IRR_VT100_CONSOLE_
// reset terminal // reset terminal
printf("%cc", 27); printf("%cc", 27);
#endif #endif
} }
...@@ -197,7 +197,7 @@ bool CIrrDeviceConsole::run() ...@@ -197,7 +197,7 @@ bool CIrrDeviceConsole::run()
// increment timer // increment timer
os::Timer::tick(); os::Timer::tick();
// process Windows console input // process Windows console input
#ifdef _IRR_WINDOWS_NT_CONSOLE_ #ifdef _IRR_WINDOWS_NT_CONSOLE_
INPUT_RECORD in; INPUT_RECORD in;
...@@ -235,13 +235,13 @@ bool CIrrDeviceConsole::run() ...@@ -235,13 +235,13 @@ bool CIrrDeviceConsole::run()
e.MouseInput.X = in.Event.MouseEvent.dwMousePosition.X; e.MouseInput.X = in.Event.MouseEvent.dwMousePosition.X;
e.MouseInput.Y = in.Event.MouseEvent.dwMousePosition.Y; e.MouseInput.Y = in.Event.MouseEvent.dwMousePosition.Y;
e.MouseInput.Wheel = 0.f; e.MouseInput.Wheel = 0.f;
e.MouseInput.ButtonStates = e.MouseInput.ButtonStates =
( (in.Event.MouseEvent.dwButtonState & FROM_LEFT_1ST_BUTTON_PRESSED) ? EMBSM_LEFT : 0 ) | ( (in.Event.MouseEvent.dwButtonState & FROM_LEFT_1ST_BUTTON_PRESSED) ? EMBSM_LEFT : 0 ) |
( (in.Event.MouseEvent.dwButtonState & RIGHTMOST_BUTTON_PRESSED) ? EMBSM_RIGHT : 0 ) | ( (in.Event.MouseEvent.dwButtonState & RIGHTMOST_BUTTON_PRESSED) ? EMBSM_RIGHT : 0 ) |
( (in.Event.MouseEvent.dwButtonState & FROM_LEFT_2ND_BUTTON_PRESSED) ? EMBSM_MIDDLE : 0 ) | ( (in.Event.MouseEvent.dwButtonState & FROM_LEFT_2ND_BUTTON_PRESSED) ? EMBSM_MIDDLE : 0 ) |
( (in.Event.MouseEvent.dwButtonState & FROM_LEFT_3RD_BUTTON_PRESSED) ? EMBSM_EXTRA1 : 0 ) | ( (in.Event.MouseEvent.dwButtonState & FROM_LEFT_3RD_BUTTON_PRESSED) ? EMBSM_EXTRA1 : 0 ) |
( (in.Event.MouseEvent.dwButtonState & FROM_LEFT_4TH_BUTTON_PRESSED) ? EMBSM_EXTRA2 : 0 ); ( (in.Event.MouseEvent.dwButtonState & FROM_LEFT_4TH_BUTTON_PRESSED) ? EMBSM_EXTRA2 : 0 );
if (in.Event.MouseEvent.dwEventFlags & MOUSE_MOVED) if (in.Event.MouseEvent.dwEventFlags & MOUSE_MOVED)
{ {
CursorControl->setPosition(core::position2di(e.MouseInput.X, e.MouseInput.Y)); CursorControl->setPosition(core::position2di(e.MouseInput.X, e.MouseInput.Y));
...@@ -281,9 +281,9 @@ bool CIrrDeviceConsole::run() ...@@ -281,9 +281,9 @@ bool CIrrDeviceConsole::run()
break; break;
} }
case WINDOW_BUFFER_SIZE_EVENT: case WINDOW_BUFFER_SIZE_EVENT:
VideoDriver->OnResize( VideoDriver->OnResize(
core::dimension2d<u32>(in.Event.WindowBufferSizeEvent.dwSize.X, core::dimension2d<u32>(in.Event.WindowBufferSizeEvent.dwSize.X,
in.Event.WindowBufferSizeEvent.dwSize.Y)); in.Event.WindowBufferSizeEvent.dwSize.Y));
break; break;
case FOCUS_EVENT: case FOCUS_EVENT:
...@@ -300,7 +300,7 @@ bool CIrrDeviceConsole::run() ...@@ -300,7 +300,7 @@ bool CIrrDeviceConsole::run()
#else #else
// todo: keyboard input from terminal in raw mode // todo: keyboard input from terminal in raw mode
#endif #endif
return IsDeviceRunning; return IsDeviceRunning;
} }
...@@ -449,23 +449,6 @@ void CIrrDeviceConsole::addPostPresentText(s16 X, s16 Y, const wchar_t *text) ...@@ -449,23 +449,6 @@ void CIrrDeviceConsole::addPostPresentText(s16 X, s16 Y, const wchar_t *text)
Text.push_back(p); Text.push_back(p);
} }
extern "C" IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(
const SIrrlichtCreationParameters& parameters)
{
CIrrDeviceConsole* dev = new CIrrDeviceConsole(parameters);
if (dev && !dev->getVideoDriver() && parameters.DriverType != video::EDT_NULL)
{
dev->closeDevice(); // close device
dev->run(); // consume quit message
dev->drop();
dev = 0;
}
return dev;
}
} // end namespace irr } // end namespace irr
#endif // _IRR_USE_CONSOLE_DEVICE_ #endif // _IRR_COMPILE_WITH_CONSOLE_DEVICE_
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
#define __C_IRR_DEVICE_CONSOLE_H_INCLUDED__ #define __C_IRR_DEVICE_CONSOLE_H_INCLUDED__
#include "IrrCompileConfig.h" #include "IrrCompileConfig.h"
#ifdef _IRR_USE_CONSOLE_DEVICE_ #ifdef _IRR_COMPILE_WITH_CONSOLE_DEVICE_
#define _IRR_USE_CONSOLE_FONT_ //#define _IRR_USE_CONSOLE_FONT_
#include "SIrrCreationParameters.h" #include "SIrrCreationParameters.h"
#include "CIrrDeviceStub.h" #include "CIrrDeviceStub.h"
...@@ -79,7 +79,13 @@ namespace irr ...@@ -79,7 +79,13 @@ namespace irr
virtual void setResizable(bool resize=false); virtual void setResizable(bool resize=false);
//! Minimizes the window. //! Minimizes the window.
virtual void minimizeWindow(); virtual void minimizeWindow();
//! Get the device type
virtual E_DEVICE_TYPE getType() const
{
return EIDT_CONSOLE;
}
void addPostPresentText(s16 X, s16 Y, const wchar_t *text); void addPostPresentText(s16 X, s16 Y, const wchar_t *text);
...@@ -180,7 +186,7 @@ namespace irr ...@@ -180,7 +186,7 @@ namespace irr
UseReferenceRect = false; UseReferenceRect = false;
} }
//! Updates the internal cursor position //! Updates the internal cursor position
void setInternalCursorPosition(const core::position2di &pos) void setInternalCursorPosition(const core::position2di &pos)
{ {
...@@ -195,7 +201,7 @@ namespace irr ...@@ -195,7 +201,7 @@ namespace irr
core::position2d<s32> CursorPos; core::position2d<s32> CursorPos;
core::dimension2d<u32> WindowSize; core::dimension2d<u32> WindowSize;
core::dimension2d<f32> InvWindowSize; core::dimension2d<f32> InvWindowSize;
bool IsVisible, bool IsVisible,
UseReferenceRect; UseReferenceRect;
core::rect<s32> ReferenceRect; core::rect<s32> ReferenceRect;
}; };
...@@ -205,7 +211,7 @@ namespace irr ...@@ -205,7 +211,7 @@ namespace irr
//! Set the position of the text caret //! Set the position of the text caret
void setTextCursorPos(s16 x, s16 y); void setTextCursorPos(s16 x, s16 y);
// text to be added after drawing the screen // text to be added after drawing the screen
struct SPostPresentText struct SPostPresentText
{ {
core::position2d<s16> Pos; core::position2d<s16> Pos;
...@@ -241,7 +247,7 @@ namespace gui ...@@ -241,7 +247,7 @@ namespace gui
const core::rect<s32>* clip=0) const core::rect<s32>* clip=0)
{ {
core::rect<s32> Area = clip ? *clip : position; core::rect<s32> Area = clip ? *clip : position;
if (Area.UpperLeftCorner.X < 0) if (Area.UpperLeftCorner.X < 0)
Area.UpperLeftCorner.X = 0; Area.UpperLeftCorner.X = 0;
...@@ -252,7 +258,7 @@ namespace gui ...@@ -252,7 +258,7 @@ namespace gui
// centre vertically // centre vertically
pos.Y = vcenter ? (position.UpperLeftCorner.Y + position.LowerRightCorner.Y) / 2 : position.UpperLeftCorner.Y; pos.Y = vcenter ? (position.UpperLeftCorner.Y + position.LowerRightCorner.Y) / 2 : position.UpperLeftCorner.Y;
// nothing to display? // nothing to display?
if (pos.Y < Area.UpperLeftCorner.Y || pos.Y > Area.LowerRightCorner.Y) if (pos.Y < Area.UpperLeftCorner.Y || pos.Y > Area.LowerRightCorner.Y)
return; return;
...@@ -261,7 +267,7 @@ namespace gui ...@@ -261,7 +267,7 @@ namespace gui
// centre horizontally // centre horizontally
pos.X = hcenter ? position.getCenter().X - ( tempText.size() / 2) : position.UpperLeftCorner.X; pos.X = hcenter ? position.getCenter().X - ( tempText.size() / 2) : position.UpperLeftCorner.X;
// clip // clip
u32 xlclip = 0, u32 xlclip = 0,
xrclip = 0; xrclip = 0;
...@@ -313,7 +319,5 @@ namespace gui ...@@ -313,7 +319,5 @@ namespace gui
} // end namespace irr } // end namespace irr
#endif // _IRR_COMPILE_WITH_CONSOLE_DEVICE_
#endif // _IRR_USE_CONSOLE_DEVICE_
#endif // __C_IRR_DEVICE_CONSOLE_H_INCLUDED__ #endif // __C_IRR_DEVICE_CONSOLE_H_INCLUDED__
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "CIrrDeviceLinux.h" #include "CIrrDeviceLinux.h"
#ifdef _IRR_USE_LINUX_DEVICE_ #ifdef _IRR_COMPILE_WITH_X11_DEVICE_
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -41,7 +41,7 @@ namespace irr ...@@ -41,7 +41,7 @@ namespace irr
namespace video namespace video
{ {
IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params, IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params,
io::IFileSystem* io); io::IFileSystem* io, CIrrDeviceLinux* device);
} }
} // end namespace irr } // end namespace irr
...@@ -55,7 +55,7 @@ namespace ...@@ -55,7 +55,7 @@ namespace
namespace irr namespace irr
{ {
const char* wmDeleteWindow = "WM_DELETE_WINDOW"; const char* wmDeleteWindow = "WM_DELETE_WINDOW";
//! constructor //! constructor
...@@ -719,12 +719,12 @@ void CIrrDeviceLinux::createDriver() ...@@ -719,12 +719,12 @@ void CIrrDeviceLinux::createDriver()
break; break;
case video::EDT_OPENGL: case video::EDT_OPENGL:
#ifdef _IRR_COMPILE_WITH_OPENGL_ #ifdef _IRR_COMPILE_WITH_OPENGL_
if (Context) if (Context)
VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem); VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, this);
#else #else
os::Printer::log("No OpenGL support compiled in.", ELL_ERROR); os::Printer::log("No OpenGL support compiled in.", ELL_ERROR);
#endif #endif
break; break;
case video::EDT_DIRECT3D8: case video::EDT_DIRECT3D8:
...@@ -1662,22 +1662,7 @@ void CIrrDeviceLinux::initXAtoms() ...@@ -1662,22 +1662,7 @@ void CIrrDeviceLinux::initXAtoms()
#endif #endif
} }
extern "C" IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(const SIrrlichtCreationParameters& param)
{
CIrrDeviceLinux* dev = new CIrrDeviceLinux(param);
if (dev && !dev->getVideoDriver() && param.DriverType != video::EDT_NULL)
{
dev->drop();
dev = 0;
}
return dev;
}
} // end namespace } // end namespace
#endif // _IRR_USE_LINUX_DEVICE_ #endif // _IRR_COMPILE_WITH_X11_DEVICE_
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "IrrCompileConfig.h" #include "IrrCompileConfig.h"
#ifdef _IRR_USE_LINUX_DEVICE_ #ifdef _IRR_COMPILE_WITH_X11_DEVICE_
#include "CIrrDeviceStub.h" #include "CIrrDeviceStub.h"
#include "IrrlichtDevice.h" #include "IrrlichtDevice.h"
...@@ -102,7 +102,13 @@ namespace irr ...@@ -102,7 +102,13 @@ namespace irr
//! copies text to the clipboard //! copies text to the clipboard
//! This sets the clipboard selection and _not_ the primary selection which you have on X on the middle mouse button. //! This sets the clipboard selection and _not_ the primary selection which you have on X on the middle mouse button.
virtual void copyToClipboard(const c8* text) const; virtual void copyToClipboard(const c8* text) const;
//! Get the device type
virtual E_DEVICE_TYPE getType() const
{
return EIDT_X11;
}
private: private:
...@@ -380,6 +386,6 @@ namespace irr ...@@ -380,6 +386,6 @@ namespace irr
} // end namespace irr } // end namespace irr
#endif // _IRR_USE_LINUX_DEVICE_ #endif // _IRR_COMPILE_WITH_X11_DEVICE_
#endif // __C_IRR_DEVICE_LINUX_H_INCLUDED__ #endif // __C_IRR_DEVICE_LINUX_H_INCLUDED__
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "IrrCompileConfig.h" #include "IrrCompileConfig.h"
#ifdef _IRR_USE_SDL_DEVICE_ #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
#include "CIrrDeviceSDL.h" #include "CIrrDeviceSDL.h"
#include "IEventReceiver.h" #include "IEventReceiver.h"
...@@ -42,7 +42,7 @@ namespace irr ...@@ -42,7 +42,7 @@ namespace irr
#ifdef _IRR_COMPILE_WITH_OPENGL_ #ifdef _IRR_COMPILE_WITH_OPENGL_
IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params, IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params,
io::IFileSystem* io); io::IFileSystem* io, CIrrDeviceSDL* device);
#endif #endif
} // end namespace video } // end namespace video
...@@ -52,8 +52,6 @@ namespace irr ...@@ -52,8 +52,6 @@ namespace irr
namespace irr namespace irr
{ {
const char* wmDeleteWindow = "WM_DELETE_WINDOW";
//! constructor //! constructor
CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param) CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
: CIrrDeviceStub(param), : CIrrDeviceStub(param),
...@@ -107,7 +105,7 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param) ...@@ -107,7 +105,7 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
SDL_EnableUNICODE(1); SDL_EnableUNICODE(1);
(void)SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); (void)SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
if ( CreationParams.Fullscreen ) if ( CreationParams.Fullscreen )
SDL_Flags |= SDL_FULLSCREEN; SDL_Flags |= SDL_FULLSCREEN;
if (CreationParams.DriverType == video::EDT_OPENGL) if (CreationParams.DriverType == video::EDT_OPENGL)
...@@ -265,7 +263,7 @@ void CIrrDeviceSDL::createDriver() ...@@ -265,7 +263,7 @@ void CIrrDeviceSDL::createDriver()
os::Printer::log("No Software driver support compiled in.", ELL_ERROR); os::Printer::log("No Software driver support compiled in.", ELL_ERROR);
#endif #endif
break; break;
case video::EDT_BURNINGSVIDEO: case video::EDT_BURNINGSVIDEO:
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
VideoDriver = video::createSoftwareDriver2(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this); VideoDriver = video::createSoftwareDriver2(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this);
...@@ -275,11 +273,11 @@ void CIrrDeviceSDL::createDriver() ...@@ -275,11 +273,11 @@ void CIrrDeviceSDL::createDriver()
break; break;
case video::EDT_OPENGL: case video::EDT_OPENGL:
#ifdef _IRR_COMPILE_WITH_OPENGL_ #ifdef _IRR_COMPILE_WITH_OPENGL_
VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem); VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, this);
#else #else
os::Printer::log("No OpenGL support compiled in.", ELL_ERROR); os::Printer::log("No OpenGL support compiled in.", ELL_ERROR);
#endif #endif
break; break;
case video::EDT_NULL: case video::EDT_NULL:
...@@ -381,7 +379,7 @@ bool CIrrDeviceSDL::run() ...@@ -381,7 +379,7 @@ bool CIrrDeviceSDL::run()
if (irrevent.MouseInput.Event != irr::EMIE_MOUSE_MOVED) if (irrevent.MouseInput.Event != irr::EMIE_MOUSE_MOVED)
{ {
postEventFromUser(irrevent); postEventFromUser(irrevent);
if ( irrevent.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN ) if ( irrevent.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN )
{ {
u32 clicks = checkSuccessiveClicks(irrevent.MouseInput.X, irrevent.MouseInput.Y); u32 clicks = checkSuccessiveClicks(irrevent.MouseInput.X, irrevent.MouseInput.Y);
...@@ -456,8 +454,8 @@ bool CIrrDeviceSDL::run() ...@@ -456,8 +454,8 @@ bool CIrrDeviceSDL::run()
case SDL_USEREVENT: case SDL_USEREVENT:
irrevent.EventType = irr::EET_USER_EVENT; irrevent.EventType = irr::EET_USER_EVENT;
irrevent.UserEvent.UserData1 = reinterpret_cast<s32>(SDL_event.user.data1); irrevent.UserEvent.UserData1 = *(reinterpret_cast<s32*>(&SDL_event.user.data1));
irrevent.UserEvent.UserData2 = reinterpret_cast<s32>(SDL_event.user.data2); irrevent.UserEvent.UserData2 = *(reinterpret_cast<s32*>(&SDL_event.user.data2));
postEventFromUser(irrevent); postEventFromUser(irrevent);
break; break;
...@@ -539,7 +537,7 @@ bool CIrrDeviceSDL::run() ...@@ -539,7 +537,7 @@ bool CIrrDeviceSDL::run()
{ {
joyevent.JoystickEvent.POV=65535; joyevent.JoystickEvent.POV=65535;
} }
// we map the number directly // we map the number directly
joyevent.JoystickEvent.Joystick=static_cast<u8>(i); joyevent.JoystickEvent.Joystick=static_cast<u8>(i);
// now post the event // now post the event
...@@ -609,7 +607,7 @@ void CIrrDeviceSDL::sleep(u32 timeMs, bool pauseTimer) ...@@ -609,7 +607,7 @@ void CIrrDeviceSDL::sleep(u32 timeMs, bool pauseTimer)
const bool wasStopped = Timer ? Timer->isStopped() : true; const bool wasStopped = Timer ? Timer->isStopped() : true;
if (pauseTimer && !wasStopped) if (pauseTimer && !wasStopped)
Timer->stop(); Timer->stop();
SDL_Delay(timeMs); SDL_Delay(timeMs);
if (pauseTimer && !wasStopped) if (pauseTimer && !wasStopped)
...@@ -946,21 +944,7 @@ void CIrrDeviceSDL::createKeyMap() ...@@ -946,21 +944,7 @@ void CIrrDeviceSDL::createKeyMap()
KeyMap.sort(); KeyMap.sort();
} }
extern "C" IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(const SIrrlichtCreationParameters& param)
{
CIrrDeviceSDL* dev = new CIrrDeviceSDL(param);
if (dev && !dev->getVideoDriver() && param.DriverType != video::EDT_NULL)
{
dev->drop();
dev = 0;
}
return dev;
}
} // end namespace irr } // end namespace irr
#endif // _IRR_USE_SDL_DEVICE_ #endif // _IRR_COMPILE_WITH_SDL_DEVICE_
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "IrrCompileConfig.h" #include "IrrCompileConfig.h"
#ifdef _IRR_USE_SDL_DEVICE_ #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
#include "IrrlichtDevice.h" #include "IrrlichtDevice.h"
#include "CIrrDeviceStub.h" #include "CIrrDeviceStub.h"
...@@ -52,7 +52,7 @@ namespace irr ...@@ -52,7 +52,7 @@ namespace irr
//! returns if window is minimized. //! returns if window is minimized.
bool isWindowMinimized() const; bool isWindowMinimized() const;
//! returns color format of the window. //! returns color format of the window.
video::ECOLOR_FORMAT getColorFormat() const; video::ECOLOR_FORMAT getColorFormat() const;
...@@ -72,7 +72,13 @@ namespace irr ...@@ -72,7 +72,13 @@ namespace irr
virtual void minimizeWindow(); virtual void minimizeWindow();
//! Activate any joysticks, and generate events for them. //! Activate any joysticks, and generate events for them.
virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo); virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo);
//! Get the device type
virtual E_DEVICE_TYPE getType() const
{
return EIDT_CONSOLE;
}
//! Implementation of the linux cursor control //! Implementation of the linux cursor control
class CCursorControl : public gui::ICursorControl class CCursorControl : public gui::ICursorControl
...@@ -149,7 +155,7 @@ namespace irr ...@@ -149,7 +155,7 @@ namespace irr
{ {
CursorPos.X = Device->MouseX; CursorPos.X = Device->MouseX;
CursorPos.Y = Device->MouseY; CursorPos.Y = Device->MouseY;
if (CursorPos.X < 0) if (CursorPos.X < 0)
CursorPos.X = 0; CursorPos.X = 0;
if (CursorPos.X > (s32)Device->Width) if (CursorPos.X > (s32)Device->Width)
...@@ -182,7 +188,7 @@ namespace irr ...@@ -182,7 +188,7 @@ namespace irr
s32 MouseX, MouseY; s32 MouseX, MouseY;
u32 MouseButtonStates; u32 MouseButtonStates;
u32 Width, Height; u32 Width, Height;
bool Close; bool Close;
...@@ -213,6 +219,6 @@ namespace irr ...@@ -213,6 +219,6 @@ namespace irr
} // end namespace irr } // end namespace irr
#endif // _IRR_USE_SDL_DEVICE_ #endif // _IRR_COMPILE_WITH_SDL_DEVICE_
#endif // __C_IRR_DEVICE_SDL_H_INCLUDED__ #endif // __C_IRR_DEVICE_SDL_H_INCLUDED__
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "IrrCompileConfig.h" #include "IrrCompileConfig.h"
#ifdef _IRR_USE_WINDOWS_DEVICE_ #ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
#include "CIrrDeviceWin32.h" #include "CIrrDeviceWin32.h"
#include "IEventReceiver.h" #include "IEventReceiver.h"
...@@ -34,7 +34,7 @@ namespace irr ...@@ -34,7 +34,7 @@ namespace irr
#endif #endif
#ifdef _IRR_COMPILE_WITH_OPENGL_ #ifdef _IRR_COMPILE_WITH_OPENGL_
IVideoDriver* createOpenGLDriver(const irr::SIrrlichtCreationParameters& params, io::IFileSystem* io); IVideoDriver* createOpenGLDriver(const irr::SIrrlichtCreationParameters& params, io::IFileSystem* io, this);
#endif #endif
} }
} // end namespace irr } // end namespace irr
...@@ -1123,24 +1123,7 @@ bool CIrrDeviceWin32::getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &bright ...@@ -1123,24 +1123,7 @@ bool CIrrDeviceWin32::getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &bright
} }
extern "C" IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(
const SIrrlichtCreationParameters& parameters)
{
CIrrDeviceWin32* dev = new CIrrDeviceWin32(parameters);
if (dev && !dev->getVideoDriver() && parameters.DriverType != video::EDT_NULL)
{
dev->closeDevice(); // destroy window
dev->run(); // consume quit message
dev->drop();
dev = 0;
}
return dev;
}
} // end namespace } // end namespace
#endif // _IRR_USE_WINDOWS_DEVICE_ #endif // _IRR_COMPILE_WITH_WINDOWS_DEVICE_
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#define __C_IRR_DEVICE_WIN32_H_INCLUDED__ #define __C_IRR_DEVICE_WIN32_H_INCLUDED__
#include "IrrCompileConfig.h" #include "IrrCompileConfig.h"
#ifdef _IRR_USE_WINDOWS_DEVICE_ #ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
#include "CIrrDeviceStub.h" #include "CIrrDeviceStub.h"
#include "IrrlichtDevice.h" #include "IrrlichtDevice.h"
...@@ -79,13 +79,19 @@ namespace irr ...@@ -79,13 +79,19 @@ namespace irr
virtual bool setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ); virtual bool setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast );
//! Get the current Gamma Value for the Display //! Get the current Gamma Value for the Display
virtual bool getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ); virtual bool getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast );
//! Get the device type
virtual E_DEVICE_TYPE getType() const
{
return EIDT_WIN32;
}
//! Compares to the last call of this function to return double and triple clicks. //! Compares to the last call of this function to return double and triple clicks.
//! \return Returns only 1,2 or 3. A 4th click will start with 1 again. //! \return Returns only 1,2 or 3. A 4th click will start with 1 again.
virtual u32 checkSuccessiveClicks(s32 mouseX, s32 mouseY) virtual u32 checkSuccessiveClicks(s32 mouseX, s32 mouseY)
{ {
// we just have to make it public // we just have to make it public
return CIrrDeviceStub::checkSuccessiveClicks(mouseX, mouseY); return CIrrDeviceStub::checkSuccessiveClicks(mouseX, mouseY);
} }
...@@ -141,7 +147,7 @@ namespace irr ...@@ -141,7 +147,7 @@ namespace irr
ShowCursor(false); // this only decreases an internal display counter in windows, so it might have to be called some more ShowCursor(false); // this only decreases an internal display counter in windows, so it might have to be called some more
} }
} }
} }
//! Returns if the cursor is currently visible. //! Returns if the cursor is currently visible.
virtual bool isVisible() const virtual bool isVisible() const
...@@ -311,6 +317,6 @@ namespace irr ...@@ -311,6 +317,6 @@ namespace irr
} // end namespace irr } // end namespace irr
#endif // _IRR_USE_WINDOWS_DEVICE_ #endif // _IRR_COMPILE_WITH_WINDOWS_DEVICE_
#endif // __C_IRR_DEVICE_WIN32_H_INCLUDED__ #endif // __C_IRR_DEVICE_WIN32_H_INCLUDED__
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "IrrCompileConfig.h" #include "IrrCompileConfig.h"
#ifdef _IRR_USE_WINDOWS_CE_DEVICE_ #ifdef _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_
#include "CIrrDeviceWinCE.h" #include "CIrrDeviceWinCE.h"
#include "IEventReceiver.h" #include "IEventReceiver.h"
...@@ -40,7 +40,7 @@ namespace irr ...@@ -40,7 +40,7 @@ namespace irr
#endif #endif
#ifdef _IRR_COMPILE_WITH_OPENGL_ #ifdef _IRR_COMPILE_WITH_OPENGL_
IVideoDriver* createOpenGLDriver(const irr::SIrrlichtCreationParameters& params, io::IFileSystem* io); IVideoDriver* createOpenGLDriver(const irr::SIrrlichtCreationParameters& params, io::IFileSystem* io, this);
#endif #endif
} }
} // end namespace irr } // end namespace irr
...@@ -310,7 +310,7 @@ CIrrDeviceWinCE::CIrrDeviceWinCE(const SIrrlichtCreationParameters& params) ...@@ -310,7 +310,7 @@ CIrrDeviceWinCE::CIrrDeviceWinCE(const SIrrlichtCreationParameters& params)
wc.lpszClassName = ClassName; wc.lpszClassName = ClassName;
// if there is an icon, load it // if there is an icon, load it
wc.hIcon = (HICON)LoadImageW(hInstance, L"irrlicht.ico", IMAGE_ICON, 0,0, 0); wc.hIcon = (HICON)LoadImageW(hInstance, L"irrlicht.ico", IMAGE_ICON, 0,0, 0);
RegisterClass(&wc); RegisterClass(&wc);
...@@ -468,7 +468,7 @@ void CIrrDeviceWinCE::createDriver() ...@@ -468,7 +468,7 @@ void CIrrDeviceWinCE::createDriver()
VideoDriver = video::createSoftwareDriver2(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this); 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
break; break;
case video::EDT_NULL: case video::EDT_NULL:
...@@ -526,7 +526,7 @@ void CIrrDeviceWinCE::sleep(u32 timeMs, bool pauseTimer) ...@@ -526,7 +526,7 @@ void CIrrDeviceWinCE::sleep(u32 timeMs, bool pauseTimer)
const bool wasStopped = Timer ? Timer->isStopped() : true; const bool wasStopped = Timer ? Timer->isStopped() : true;
if (pauseTimer && !wasStopped) if (pauseTimer && !wasStopped)
Timer->stop(); Timer->stop();
Sleep(timeMs); Sleep(timeMs);
if (pauseTimer && !wasStopped) if (pauseTimer && !wasStopped)
...@@ -587,7 +587,7 @@ typedef struct { ...@@ -587,7 +587,7 @@ typedef struct {
DWORD bV4AlphaMask; DWORD bV4AlphaMask;
DWORD bV4CSType; DWORD bV4CSType;
DWORD un[9]; DWORD un[9];
} BITMAPV4HEADER, *PBITMAPV4HEADER; } BITMAPV4HEADER, *PBITMAPV4HEADER;
#endif #endif
...@@ -711,7 +711,7 @@ video::IVideoModeList* CIrrDeviceWinCE::getVideoModeList() ...@@ -711,7 +711,7 @@ video::IVideoModeList* CIrrDeviceWinCE::getVideoModeList()
// enumerate video modes. // enumerate video modes.
DWORD i=0; DWORD i=0;
DEVMODE mode; DEVMODE mode;
memset(&mode, 0, sizeof(mode)); memset(&mode, 0, sizeof(mode));
mode.dmSize = sizeof(mode); mode.dmSize = sizeof(mode);
while (EnumDisplaySettings(NULL, i, &mode)) while (EnumDisplaySettings(NULL, i, &mode))
...@@ -783,25 +783,7 @@ void CIrrDeviceWinCE::minimizeWindow() ...@@ -783,25 +783,7 @@ void CIrrDeviceWinCE::minimizeWindow()
{ {
} }
IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(
const SIrrlichtCreationParameters& parameters)
{
CIrrDeviceWinCE* dev = new CIrrDeviceWinCE(parameters);
if (dev && !dev->getVideoDriver() && parameters.DriverType != video::EDT_NULL)
{
dev->closeDevice(); // destroy window
dev->run(); // consume quit message
dev->drop();
dev = 0;
}
return dev;
}
} // end namespace } // end namespace
#endif // _IRR_USE_WINDOWS_CE_DEVICE_ #endif // _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#define __C_IRR_DEVICE_WINCE_H_INCLUDED__ #define __C_IRR_DEVICE_WINCE_H_INCLUDED__
#include "IrrCompileConfig.h" #include "IrrCompileConfig.h"
#ifdef _IRR_USE_WINDOWS_CE_DEVICE_ #ifdef _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_
#include "CIrrDeviceStub.h" #include "CIrrDeviceStub.h"
#include "IrrlichtDevice.h" #include "IrrlichtDevice.h"
...@@ -70,7 +70,13 @@ namespace irr ...@@ -70,7 +70,13 @@ namespace irr
virtual void setResizable(bool resize=false); virtual void setResizable(bool resize=false);
//! Minimizes the window. //! Minimizes the window.
virtual void minimizeWindow(); virtual void minimizeWindow();
//! Get the device type
virtual E_DEVICE_TYPE getType() const
{
return EIDT_WINCE;
}
//! Implementation of the win32 cursor control //! Implementation of the win32 cursor control
class CCursorControl : public gui::ICursorControl class CCursorControl : public gui::ICursorControl
...@@ -135,7 +141,7 @@ namespace irr ...@@ -135,7 +141,7 @@ namespace irr
if (UseReferenceRect) if (UseReferenceRect)
{ {
SetCursorPos(ReferenceRect.UpperLeftCorner.X + x, SetCursorPos(ReferenceRect.UpperLeftCorner.X + x,
ReferenceRect.UpperLeftCorner.Y + y); ReferenceRect.UpperLeftCorner.Y + y);
} }
else else
...@@ -259,6 +265,5 @@ namespace irr ...@@ -259,6 +265,5 @@ namespace irr
} // end namespace irr } // end namespace irr
#endif #endif // _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_
#endif #endif // __C_IRR_DEVICE_WINCE_H_INCLUDED__
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#else #else
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#ifdef _IRR_USE_OSX_DEVICE_ #ifdef _IRR_COMPILE_WITH_OSX_DEVICE_
#include "MacOSX/OSXClipboard.h" #include "MacOSX/OSXClipboard.h"
#endif #endif
#ifdef _IRR_OSX_PLATFORM_ #ifdef _IRR_OSX_PLATFORM_
...@@ -21,14 +21,14 @@ ...@@ -21,14 +21,14 @@
#endif #endif
#endif #endif
#if defined(_IRR_USE_LINUX_DEVICE_) #if defined(_IRR_COMPILE_WITH_X11_DEVICE_)
#include "CIrrDeviceLinux.h" #include "CIrrDeviceLinux.h"
#endif #endif
namespace irr namespace irr
{ {
#if defined(_IRR_USE_LINUX_DEVICE_) #if defined(_IRR_COMPILE_WITH_X11_DEVICE_)
// constructor linux // constructor linux
COSOperator::COSOperator(const c8* osversion, CIrrDeviceLinux* device) COSOperator::COSOperator(const c8* osversion, CIrrDeviceLinux* device)
: IrrDeviceLinux(device) : IrrDeviceLinux(device)
...@@ -79,11 +79,11 @@ void COSOperator::copyToClipboard(const c8* text) const ...@@ -79,11 +79,11 @@ void COSOperator::copyToClipboard(const c8* text) const
CloseClipboard(); CloseClipboard();
// MacOSX version // MacOSX version
#elif defined(_IRR_USE_OSX_DEVICE_) #elif defined(_IRR_COMPILE_WITH_OSX_DEVICE_)
OSXCopyToClipboard(text); OSXCopyToClipboard(text);
#elif defined(_IRR_USE_LINUX_DEVICE_) #elif defined(_IRR_COMPILE_WITH_X11_DEVICE_)
if ( IrrDeviceLinux ) if ( IrrDeviceLinux )
IrrDeviceLinux->copyToClipboard(text); IrrDeviceLinux->copyToClipboard(text);
#else #else
...@@ -110,10 +110,10 @@ const c8* COSOperator::getTextFromClipboard() const ...@@ -110,10 +110,10 @@ const c8* COSOperator::getTextFromClipboard() const
CloseClipboard(); CloseClipboard();
return buffer; return buffer;
#elif defined(_IRR_USE_OSX_DEVICE_) #elif defined(_IRR_COMPILE_WITH_OSX_DEVICE_)
return (OSXCopyFromClipboard()); return (OSXCopyFromClipboard());
#elif defined(_IRR_USE_LINUX_DEVICE_) #elif defined(_IRR_COMPILE_WITH_X11_DEVICE_)
if ( IrrDeviceLinux ) if ( IrrDeviceLinux )
return IrrDeviceLinux->getTextFromClipboard(); return IrrDeviceLinux->getTextFromClipboard();
return 0; return 0;
......
...@@ -20,7 +20,7 @@ class COSOperator : public IOSOperator ...@@ -20,7 +20,7 @@ class COSOperator : public IOSOperator
public: public:
// constructor // constructor
#if defined(_IRR_USE_LINUX_DEVICE_) #if defined(_IRR_COMPILE_WITH_X11_DEVICE_)
COSOperator(const c8* osversion, CIrrDeviceLinux* device); COSOperator(const c8* osversion, CIrrDeviceLinux* device);
#endif #endif
COSOperator(const c8* osversion); COSOperator(const c8* osversion);
...@@ -50,7 +50,7 @@ private: ...@@ -50,7 +50,7 @@ private:
core::stringw OperatingSystem; core::stringw OperatingSystem;
#if defined(_IRR_USE_LINUX_DEVICE_) #if defined(_IRR_COMPILE_WITH_X11_DEVICE_)
CIrrDeviceLinux * IrrDeviceLinux; CIrrDeviceLinux * IrrDeviceLinux;
#endif #endif
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include "CImage.h" #include "CImage.h"
#include "os.h" #include "os.h"
#ifdef _IRR_USE_SDL_DEVICE_ #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
#include <SDL/SDL.h> #include <SDL/SDL.h>
#endif #endif
...@@ -29,17 +29,17 @@ namespace video ...@@ -29,17 +29,17 @@ namespace video
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// WINDOWS CONSTRUCTOR // WINDOWS CONSTRUCTOR
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
#ifdef _IRR_USE_WINDOWS_DEVICE_ #ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
//! Windows constructor and init code //! Windows constructor and init code
COpenGLDriver::COpenGLDriver(const irr::SIrrlichtCreationParameters& params, COpenGLDriver::COpenGLDriver(const irr::SIrrlichtCreationParameters& params,
io::IFileSystem* io) io::IFileSystem* io, CIrrDeviceWin32* device)
: CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(), : CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(),
CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true), CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true),
AntiAlias(params.AntiAlias), RenderTargetTexture(0), AntiAlias(params.AntiAlias), RenderTargetTexture(0),
CurrentRendertargetSize(0,0), ColorFormat(ECF_R8G8B8), CurrentRendertargetSize(0,0), ColorFormat(ECF_R8G8B8),
CurrentTarget(ERT_FRAME_BUFFER), CurrentTarget(ERT_FRAME_BUFFER),
Doublebuffer(params.Doublebuffer), Stereo(params.Stereobuffer), Doublebuffer(params.Doublebuffer), Stereo(params.Stereobuffer),
HDc(0), Window(static_cast<HWND>(params.WindowId)), HRc(0) HDc(0), Window(static_cast<HWND>(params.WindowId)), HRc(0), DeviceType(EIDT_WIN32)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("COpenGLDriver"); setDebugName("COpenGLDriver");
...@@ -354,12 +354,12 @@ bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params) ...@@ -354,12 +354,12 @@ bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params)
return true; return true;
} }
#endif //IRR_USE_WINDOWS_DEVICE_ #endif // _IRR_COMPILE_WITH_WINDOWS_DEVICE_
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// MacOSX CONSTRUCTOR // MacOSX CONSTRUCTOR
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
#ifdef _IRR_USE_OSX_DEVICE_ #ifdef _IRR_COMPILE_WITH_OSX_DEVICE_
//! Windows constructor and init code //! Windows constructor and init code
COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params, COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params,
io::IFileSystem* io, CIrrDeviceMacOSX *device) io::IFileSystem* io, CIrrDeviceMacOSX *device)
...@@ -369,7 +369,7 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params, ...@@ -369,7 +369,7 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params,
CurrentRendertargetSize(0,0), ColorFormat(ECF_R8G8B8), CurrentRendertargetSize(0,0), ColorFormat(ECF_R8G8B8),
CurrentTarget(ERT_FRAME_BUFFER), CurrentTarget(ERT_FRAME_BUFFER),
Doublebuffer(params.Doublebuffer), Stereo(params.Stereobuffer), Doublebuffer(params.Doublebuffer), Stereo(params.Stereobuffer),
_device(device) _device(device), DeviceType(EIDT_OSX)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("COpenGLDriver"); setDebugName("COpenGLDriver");
...@@ -382,16 +382,16 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params, ...@@ -382,16 +382,16 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params,
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// LINUX CONSTRUCTOR // LINUX CONSTRUCTOR
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
#ifdef _IRR_USE_LINUX_DEVICE_ #ifdef _IRR_COMPILE_WITH_X11_DEVICE_
//! Linux constructor and init code //! Linux constructor and init code
COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params, COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params,
io::IFileSystem* io) io::IFileSystem* io, CIrrDeviceLinux* device)
: CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(), : CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(),
CurrentRenderMode(ERM_NONE), ResetRenderStates(true), CurrentRenderMode(ERM_NONE), ResetRenderStates(true),
Transformation3DChanged(true), AntiAlias(params.AntiAlias), Transformation3DChanged(true), AntiAlias(params.AntiAlias),
RenderTargetTexture(0), CurrentRendertargetSize(0,0), ColorFormat(ECF_R8G8B8), RenderTargetTexture(0), CurrentRendertargetSize(0,0), ColorFormat(ECF_R8G8B8),
CurrentTarget(ERT_FRAME_BUFFER), CurrentTarget(ERT_FRAME_BUFFER),
Doublebuffer(params.Doublebuffer), Stereo(params.Stereobuffer) Doublebuffer(params.Doublebuffer), Stereo(params.Stereobuffer), DeviceType(EIDT_X11)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("COpenGLDriver"); setDebugName("COpenGLDriver");
...@@ -415,22 +415,22 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params, ...@@ -415,22 +415,22 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params,
#endif #endif
} }
#endif // _IRR_USE_LINUX_DEVICE_ #endif // _IRR_COMPILE_WITH_X11_DEVICE_
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// SDL CONSTRUCTOR // SDL CONSTRUCTOR
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
#ifdef _IRR_USE_SDL_DEVICE_ #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
//! SDL constructor and init code //! SDL constructor and init code
COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params, COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params,
io::IFileSystem* io) io::IFileSystem* io, CIrrDeviceSDL* device)
: CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(), : CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(),
CurrentRenderMode(ERM_NONE), ResetRenderStates(true), CurrentRenderMode(ERM_NONE), ResetRenderStates(true),
Transformation3DChanged(true), AntiAlias(params.AntiAlias), Transformation3DChanged(true), AntiAlias(params.AntiAlias),
RenderTargetTexture(0), CurrentRendertargetSize(0,0), ColorFormat(ECF_R8G8B8), RenderTargetTexture(0), CurrentRendertargetSize(0,0), ColorFormat(ECF_R8G8B8),
CurrentTarget(ERT_FRAME_BUFFER), CurrentTarget(ERT_FRAME_BUFFER),
Doublebuffer(params.Doublebuffer), Stereo(params.Stereobuffer) Doublebuffer(params.Doublebuffer), Stereo(params.Stereobuffer), DeviceType(EIDT_SDL)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("COpenGLDriver"); setDebugName("COpenGLDriver");
...@@ -439,7 +439,7 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params, ...@@ -439,7 +439,7 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params,
genericDriverInit(params.WindowSize, params.Stencilbuffer); genericDriverInit(params.WindowSize, params.Stencilbuffer);
} }
#endif // _IRR_USE_SDL_DEVICE_ #endif // _IRR_COMPILE_WITH_SDL_DEVICE_
//! destructor //! destructor
...@@ -454,18 +454,22 @@ COpenGLDriver::~COpenGLDriver() ...@@ -454,18 +454,22 @@ COpenGLDriver::~COpenGLDriver()
deleteAllTextures(); deleteAllTextures();
#ifdef _IRR_USE_WINDOWS_DEVICE_ #ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
if (HRc) if (DeviceType == EIDT_WIN32)
{ {
if (!wglMakeCurrent(0, 0))
os::Printer::log("Release of dc and rc failed.", ELL_WARNING);
if (!wglDeleteContext(HRc)) if (HRc)
os::Printer::log("Release of rendering context failed.", ELL_WARNING); {
} if (!wglMakeCurrent(0, 0))
os::Printer::log("Release of dc and rc failed.", ELL_WARNING);
if (HDc) if (!wglDeleteContext(HRc))
ReleaseDC(Window, HDc); os::Printer::log("Release of rendering context failed.", ELL_WARNING);
}
if (HDc)
ReleaseDC(Window, HDc);
}
#endif #endif
} }
...@@ -621,20 +625,38 @@ bool COpenGLDriver::endScene() ...@@ -621,20 +625,38 @@ bool COpenGLDriver::endScene()
glFlush(); glFlush();
#ifdef _IRR_USE_WINDOWS_DEVICE_ #ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
return SwapBuffers(HDc) == TRUE; if (DeviceType == EIDT_WIN32)
#elif defined(_IRR_USE_LINUX_DEVICE_) return SwapBuffers(HDc) == TRUE;
glXSwapBuffers((Display*)ExposedData.OpenGLLinux.X11Display, Drawable); #endif
return true;
#elif defined(_IRR_USE_OSX_DEVICE_) #ifdef _IRR_COMPILE_WITH_X11_DEVICE_
_device->flush(); if (DeviceType == EIDT_X11)
return true; {
#elif defined(_IRR_USE_SDL_DEVICE_) glXSwapBuffers((Display*)ExposedData.OpenGLLinux.X11Display, Drawable);
SDL_GL_SwapBuffers(); return true;
return true; }
#else #endif
#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_
if (DeviceType == EIDT_OSX)
{
_device->flush();
return true;
}
#endif
#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
if (DeviceType == EIDT_SDL)
{
SDL_GL_SwapBuffers();
return true;
}
#endif
// todo: console device present
return false; return false;
#endif
} }
...@@ -671,10 +693,13 @@ bool COpenGLDriver::beginScene(bool backBuffer, bool zBuffer, SColor color, ...@@ -671,10 +693,13 @@ bool COpenGLDriver::beginScene(bool backBuffer, bool zBuffer, SColor color,
{ {
CNullDriver::beginScene(backBuffer, zBuffer, color, windowId, sourceRect); CNullDriver::beginScene(backBuffer, zBuffer, color, windowId, sourceRect);
#if defined(_IRR_USE_SDL_DEVICE_) #if defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
// todo: SDL sets glFrontFace(GL_CCW) after driver creation, if (DeviceType == EIDT_SDL)
// it would be better if this was fixed elsewhere. {
glFrontFace(GL_CW); // todo: SDL sets glFrontFace(GL_CCW) after driver creation,
// it would be better if this was fixed elsewhere.
glFrontFace(GL_CW);
}
#endif #endif
clearBuffers(backBuffer, zBuffer, false, color); clearBuffers(backBuffer, zBuffer, false, color);
...@@ -3272,12 +3297,12 @@ namespace video ...@@ -3272,12 +3297,12 @@ namespace video
// ----------------------------------- // -----------------------------------
// WINDOWS VERSION // WINDOWS VERSION
// ----------------------------------- // -----------------------------------
#ifdef _IRR_USE_WINDOWS_DEVICE_ #ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params, IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params,
io::IFileSystem* io) io::IFileSystem* io, CIrrDeviceWin32* device)
{ {
#ifdef _IRR_COMPILE_WITH_OPENGL_ #ifdef _IRR_COMPILE_WITH_OPENGL_
COpenGLDriver* ogl = new COpenGLDriver(params, io); COpenGLDriver* ogl = new COpenGLDriver(params, io, device);
if (!ogl->initDriver(params)) if (!ogl->initDriver(params))
{ {
ogl->drop(); ogl->drop();
...@@ -3288,12 +3313,12 @@ IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params, ...@@ -3288,12 +3313,12 @@ IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params,
return 0; return 0;
#endif // _IRR_COMPILE_WITH_OPENGL_ #endif // _IRR_COMPILE_WITH_OPENGL_
} }
#endif // _IRR_USE_WINDOWS_DEVICE_ #endif // _IRR_COMPILE_WITH_WINDOWS_DEVICE_
// ----------------------------------- // -----------------------------------
// MACOSX VERSION // MACOSX VERSION
// ----------------------------------- // -----------------------------------
#if defined(_IRR_USE_OSX_DEVICE_) #if defined(_IRR_COMPILE_WITH_OSX_DEVICE_)
IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params, IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params,
io::IFileSystem* io, CIrrDeviceMacOSX *device) io::IFileSystem* io, CIrrDeviceMacOSX *device)
{ {
...@@ -3303,22 +3328,38 @@ IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params, ...@@ -3303,22 +3328,38 @@ IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params,
return 0; return 0;
#endif // _IRR_COMPILE_WITH_OPENGL_ #endif // _IRR_COMPILE_WITH_OPENGL_
} }
#endif // _IRR_USE_OSX_DEVICE_ #endif // _IRR_COMPILE_WITH_OSX_DEVICE_
// ----------------------------------- // -----------------------------------
// X11/SDL VERSION // X11 VERSION
// ----------------------------------- // -----------------------------------
#if defined(_IRR_USE_LINUX_DEVICE_) || defined(_IRR_USE_SDL_DEVICE_) #ifdef _IRR_COMPILE_WITH_X11_DEVICE_
IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params, IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params,
io::IFileSystem* io) io::IFileSystem* io, CIrrDeviceLinux* device)
{ {
#ifdef _IRR_COMPILE_WITH_OPENGL_ #ifdef _IRR_COMPILE_WITH_OPENGL_
return new COpenGLDriver(params, io); return new COpenGLDriver(params, io, device);
#else #else
return 0; return 0;
#endif // _IRR_COMPILE_WITH_OPENGL_ #endif // _IRR_COMPILE_WITH_OPENGL_
} }
#endif // _IRR_USE_LINUX_DEVICE_ #endif // _IRR_COMPILE_WITH_X11_DEVICE_
// -----------------------------------
// SDL VERSION
// -----------------------------------
#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params,
io::IFileSystem* io, CIrrDeviceSDL* device)
{
#ifdef _IRR_COMPILE_WITH_OPENGL_
return new COpenGLDriver(params, io, device);
#else
return 0;
#endif // _IRR_COMPILE_WITH_OPENGL_
}
#endif // _IRR_COMPILE_WITH_SDL_DEVICE_
} // end namespace } // end namespace
} // end namespace } // end namespace
......
...@@ -17,7 +17,12 @@ ...@@ -17,7 +17,12 @@
#include "COpenGLExtensionHandler.h" #include "COpenGLExtensionHandler.h"
namespace irr namespace irr
{ {
class CIrrDeviceWin32;
class CIrrDeviceLinux;
class CIrrDeviceSDL;
class CIrrDeviceMacOSX;
namespace video namespace video
{ {
class COpenGLTexture; class COpenGLTexture;
...@@ -26,13 +31,20 @@ namespace video ...@@ -26,13 +31,20 @@ namespace video
{ {
public: public:
#if defined(_IRR_WINDOWS_API_) || defined(_IRR_USE_LINUX_DEVICE_) || defined(_IRR_USE_SDL_DEVICE_) #ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io); COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceWin32* device);
#endif
#ifdef _IRR_COMPILE_WITH_X11_DEVICE_
COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceLinux* device);
#endif
#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceSDL* device);
#endif #endif
#ifdef _IRR_USE_OSX_DEVICE_ #ifdef _IRR_COMPILE_WITH_OSX_DEVICE_
COpenGLDriver(const SIrrlichtCreationParameters& params, COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceMacOSX *device);
io::IFileSystem* io, CIrrDeviceMacOSX *device);
#endif #endif
#ifdef _IRR_WINDOWS_API_ #ifdef _IRR_WINDOWS_API_
...@@ -392,12 +404,16 @@ namespace video ...@@ -392,12 +404,16 @@ namespace video
#ifdef _IRR_WINDOWS_API_ #ifdef _IRR_WINDOWS_API_
HDC HDc; // Private GDI Device Context HDC HDc; // Private GDI Device Context
HWND Window; HWND Window;
HGLRC HRc; // Permanent Rendering Context HGLRC HRc; // Permanent Rendering Context
#elif defined(_IRR_USE_LINUX_DEVICE_)
GLXDrawable Drawable;
#elif defined(_IRR_USE_OSX_DEVICE_)
CIrrDeviceMacOSX *_device;
#endif #endif
#ifdef _IRR_COMPILE_WITH_X11_DEVICE_
GLXDrawable Drawable;
#endif
#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_
CIrrDeviceMacOSX *_device;
#endif
E_DEVICE_TYPE DeviceType;
}; };
} // end namespace video } // end namespace video
......
...@@ -35,7 +35,7 @@ COpenGLExtensionHandler::COpenGLExtensionHandler() : ...@@ -35,7 +35,7 @@ COpenGLExtensionHandler::COpenGLExtensionHandler() :
pGlStencilFuncSeparate(0), pGlStencilOpSeparate(0), pGlStencilFuncSeparate(0), pGlStencilOpSeparate(0),
pGlStencilFuncSeparateATI(0), pGlStencilOpSeparateATI(0), pGlStencilFuncSeparateATI(0), pGlStencilOpSeparateATI(0),
pGlCompressedTexImage2D(0), pGlCompressedTexImage2D(0),
#ifdef _IRR_USE_WINDOWS_DEVICE_ #ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
wglSwapIntervalEXT(0), wglSwapIntervalEXT(0),
#elif defined(GLX_SGI_swap_control) #elif defined(GLX_SGI_swap_control)
glxSwapIntervalSGI(0), glxSwapIntervalSGI(0),
...@@ -186,10 +186,10 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer) ...@@ -186,10 +186,10 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
// vsync extension // vsync extension
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC) wglGetProcAddress("wglSwapIntervalEXT"); wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC) wglGetProcAddress("wglSwapIntervalEXT");
#elif defined(_IRR_USE_LINUX_DEVICE_) || defined (_IRR_USE_SDL_DEVICE_) #elif defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined (_IRR_COMPILE_WITH_SDL_DEVICE_)
#ifdef _IRR_OPENGL_USE_EXTPOINTER_ #ifdef _IRR_OPENGL_USE_EXTPOINTER_
#ifdef _IRR_USE_SDL_DEVICE_ #if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) && !defined(_IRR_COMPILE_WITH_X11_DEVICE_)
#define IRR_OGL_LOAD_EXTENSION(x) SDL_GL_GetProcAddress(reinterpret_cast<const char*>(x)) #define IRR_OGL_LOAD_EXTENSION(x) SDL_GL_GetProcAddress(reinterpret_cast<const char*>(x))
#else #else
// Accessing the correct function is quite complex // Accessing the correct function is quite complex
...@@ -322,7 +322,7 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer) ...@@ -322,7 +322,7 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
pGlCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC) pGlCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC)
IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glCompressedTexImage2D")); IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glCompressedTexImage2D"));
#if defined(GLX_SGI_swap_control) && !defined(_IRR_USE_SDL_DEVICE_) #if defined(GLX_SGI_swap_control) && !defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
// get vsync extension // get vsync extension
glxSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glXSwapIntervalSGI")); glxSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glXSwapIntervalSGI"));
#endif #endif
......
...@@ -24,10 +24,12 @@ ...@@ -24,10 +24,12 @@
#include "glext.h" #include "glext.h"
#endif #endif
#include "wglext.h" #include "wglext.h"
#ifdef _MSC_VER
#pragma comment(lib, "OpenGL32.lib") #ifdef _MSC_VER
#endif #pragma comment(lib, "OpenGL32.lib")
#elif defined(_IRR_USE_OSX_DEVICE_) #endif
#elif defined(_IRR_COMPILE_WITH_OSX_DEVICE_)
#include "CIrrDeviceMacOSX.h" #include "CIrrDeviceMacOSX.h"
#if defined(_IRR_OPENGL_USE_EXTPOINTER_) #if defined(_IRR_OPENGL_USE_EXTPOINTER_)
#define GL_GLEXT_LEGACY 1 #define GL_GLEXT_LEGACY 1
...@@ -36,7 +38,7 @@ ...@@ -36,7 +38,7 @@
#if defined(_IRR_OPENGL_USE_EXTPOINTER_) #if defined(_IRR_OPENGL_USE_EXTPOINTER_)
#include "glext.h" #include "glext.h"
#endif #endif
#elif defined(_IRR_USE_SDL_DEVICE_) #elif defined(_IRR_COMPILE_WITH_SDL_DEVICE_) && !defined(_IRR_COMPILE_WITH_X11_DEVICE_)
#if defined(_IRR_OPENGL_USE_EXTPOINTER_) #if defined(_IRR_OPENGL_USE_EXTPOINTER_)
#define GL_GLEXT_LEGACY 1 #define GL_GLEXT_LEGACY 1
#define GLX_GLXEXT_LEGACY 1 #define GLX_GLXEXT_LEGACY 1
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include <GL/gl.h> #include <GL/gl.h>
#elif defined(_IRR_OSX_PLATFORM_) #elif defined(_IRR_OSX_PLATFORM_)
#include <OpenGL/gl.h> #include <OpenGL/gl.h>
#elif defined(_IRR_USE_SDL_DEVICE_) #elif defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
#define NO_SDL_GLEXT #define NO_SDL_GLEXT
#include <SDL/SDL_video.h> #include <SDL/SDL_video.h>
#include <SDL/SDL_opengl.h> #include <SDL/SDL_opengl.h>
......
...@@ -24,9 +24,9 @@ ...@@ -24,9 +24,9 @@
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma comment(lib, "OpenGL32.lib") #pragma comment(lib, "OpenGL32.lib")
#endif #endif
#elif defined(_IRR_USE_OSX_DEVICE_) #elif defined(_IRR_OSX_PLATFORM_)
#include <OpenGL/gl.h> #include <OpenGL/gl.h>
#elif defined(_IRR_USE_SDL_DEVICE_) #elif defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
#define NO_SDL_GLEXT #define NO_SDL_GLEXT
#include <SDL/SDL_video.h> #include <SDL/SDL_video.h>
#include <SDL/SDL_opengl.h> #include <SDL/SDL_opengl.h>
...@@ -142,7 +142,7 @@ class COpenGLFBOTexture : public COpenGLTexture ...@@ -142,7 +142,7 @@ class COpenGLFBOTexture : public COpenGLTexture
public: public:
//! FrameBufferObject constructor //! FrameBufferObject constructor
COpenGLFBOTexture(const core::dimension2d<u32>& size, const core::string<c16>& name, COpenGLFBOTexture(const core::dimension2d<u32>& size, const core::string<c16>& name,
COpenGLDriver* driver = 0, const ECOLOR_FORMAT format = ECF_UNKNOWN); COpenGLDriver* driver = 0, const ECOLOR_FORMAT format = ECF_UNKNOWN);
//! destructor //! destructor
......
...@@ -723,10 +723,14 @@ ...@@ -723,10 +723,14 @@
<Unit filename="CIrrDeviceConsole.h" /> <Unit filename="CIrrDeviceConsole.h" />
<Unit filename="CIrrDeviceLinux.cpp" /> <Unit filename="CIrrDeviceLinux.cpp" />
<Unit filename="CIrrDeviceLinux.h" /> <Unit filename="CIrrDeviceLinux.h" />
<Unit filename="CIrrDeviceSDL.cpp" />
<Unit filename="CIrrDeviceSDL.h" />
<Unit filename="CIrrDeviceStub.cpp" /> <Unit filename="CIrrDeviceStub.cpp" />
<Unit filename="CIrrDeviceStub.h" /> <Unit filename="CIrrDeviceStub.h" />
<Unit filename="CIrrDeviceWin32.cpp" /> <Unit filename="CIrrDeviceWin32.cpp" />
<Unit filename="CIrrDeviceWin32.h" /> <Unit filename="CIrrDeviceWin32.h" />
<Unit filename="CIrrDeviceWinCE.cpp" />
<Unit filename="CIrrDeviceWinCE.h" />
<Unit filename="CIrrMeshFileLoader.cpp" /> <Unit filename="CIrrMeshFileLoader.cpp" />
<Unit filename="CIrrMeshFileLoader.h" /> <Unit filename="CIrrMeshFileLoader.h" />
<Unit filename="CIrrMeshWriter.cpp" /> <Unit filename="CIrrMeshWriter.cpp" />
...@@ -935,6 +939,8 @@ ...@@ -935,6 +939,8 @@
<Unit filename="ITriangleRenderer.h" /> <Unit filename="ITriangleRenderer.h" />
<Unit filename="IZBuffer.h" /> <Unit filename="IZBuffer.h" />
<Unit filename="Irrlicht.cpp" /> <Unit filename="Irrlicht.cpp" />
<Unit filename="MacOSX/CIrrDeviceMacOSX.h" />
<Unit filename="MacOSX/CIrrDeviceMacOSX.mm" />
<Unit filename="OctTree.h" /> <Unit filename="OctTree.h" />
<Unit filename="S2DVertex.h" /> <Unit filename="S2DVertex.h" />
<Unit filename="S4DVertex.h" /> <Unit filename="S4DVertex.h" />
......
...@@ -13,8 +13,33 @@ static const char* const copyright = "Irrlicht Engine (c) 2002-2009 Nikolaus Geb ...@@ -13,8 +13,33 @@ static const char* const copyright = "Irrlicht Engine (c) 2002-2009 Nikolaus Geb
#endif // _DEBUG #endif // _DEBUG
#endif #endif
#include "irrlicht.h"
#include "irrlicht.h" #ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
#include "CIrrDeviceWin32.h"
#endif
#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_
#include "MacOSX/CIrrDeviceMacOSX.h"
#endif
#ifdef _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_
#include "CIrrDeviceWinCE.h"
#endif
#ifdef _IRR_COMPILE_WITH_X11_DEVICE_
#include "CIrrDeviceLinux.h"
#endif
#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
#include "CIrrDeviceSDL.h"
#endif
#ifdef _IRR_COMPILE_WITH_CONSOLE_DEVICE_
#include "CIrrDeviceConsole.h"
#endif
namespace irr namespace irr
{ {
...@@ -35,6 +60,52 @@ namespace irr ...@@ -35,6 +60,52 @@ namespace irr
return createDeviceEx(p); return createDeviceEx(p);
} }
extern "C" IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(const SIrrlichtCreationParameters& params)
{
IrrlichtDevice* dev = 0;
#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
if (params.DeviceType == EIDT_WIN32 || (!dev && params.DeviceType == EIDT_BEST))
dev = new CIrrDeviceWin32(params);
#endif
#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_
if (params.DeviceType == EIDT_OSX || (!dev && params.DeviceType == EIDT_BEST))
dev = new CIrrDeviceMacOSX(params);
#endif
#ifdef _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_
if (params.DeviceType == EIDT_WINCE || (!dev && params.DeviceType == EIDT_BEST))
dev = new CIrrDeviceWinCE(params);
#endif
#ifdef _IRR_COMPILE_WITH_X11_DEVICE_
if (params.DeviceType == EIDT_X11 || (!dev && params.DeviceType == EIDT_BEST))
dev = new CIrrDeviceLinux(params);
#endif
#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
if (params.DeviceType == EIDT_SDL || (!dev && params.DeviceType == EIDT_BEST))
dev = new CIrrDeviceSDL(params);
#endif
#ifdef _IRR_COMPILE_WITH_CONSOLE_DEVICE_
if (params.DeviceType == EIDT_CONSOLE || (!dev && params.DeviceType == EIDT_BEST))
dev = new CIrrDeviceConsole(params);
#endif
if (dev && !dev->getVideoDriver() && params.DriverType != video::EDT_NULL)
{
dev->closeDevice(); // destroy window
dev->run(); // consume quit message
dev->drop();
dev = 0;
}
return dev;
}
namespace core namespace core
{ {
......
...@@ -64,10 +64,10 @@ namespace irr ...@@ -64,10 +64,10 @@ namespace irr
//! Sets if the window should be resizable in windowed mode. //! Sets if the window should be resizable in windowed mode.
virtual void setResizable(bool resize); virtual void setResizable(bool resize);
//! Returns true if the window is resizable, false if not //! Returns true if the window is resizable, false if not
virtual bool isResizable() const; virtual bool isResizable() const;
//! Minimizes the window if possible //! Minimizes the window if possible
virtual void minimizeWindow(); virtual void minimizeWindow();
...@@ -78,6 +78,12 @@ namespace irr ...@@ -78,6 +78,12 @@ namespace irr
//! supported by the gfx adapter. //! supported by the gfx adapter.
virtual video::IVideoModeList* getVideoModeList(); virtual video::IVideoModeList* getVideoModeList();
//! Get the device type
virtual E_DEVICE_TYPE getType() const
{
return EIDT_OSX;
}
void flush(); void flush();
void setMouseLocation(int x, int y); void setMouseLocation(int x, int y);
void setResize(int width, int height); void setResize(int width, int height);
...@@ -93,13 +99,13 @@ namespace irr ...@@ -93,13 +99,13 @@ namespace irr
{ {
public: public:
CCursorControl(const core::dimension2d<u32>& wsize, CIrrDeviceMacOSX *device) CCursorControl(const core::dimension2d<u32>& wsize, CIrrDeviceMacOSX *device)
: WindowSize(wsize), IsVisible(true), InvWindowSize(0.0f, 0.0f), Device(device), UseReferenceRect(false) : WindowSize(wsize), IsVisible(true), InvWindowSize(0.0f, 0.0f), Device(device), UseReferenceRect(false)
{ {
CursorPos.X = CursorPos.Y = 0; CursorPos.X = CursorPos.Y = 0;
if (WindowSize.Width!=0) if (WindowSize.Width!=0)
InvWindowSize.Width = 1.0f / WindowSize.Width; InvWindowSize.Width = 1.0f / WindowSize.Width;
if (WindowSize.Height!=0) if (WindowSize.Height!=0)
InvWindowSize.Height = 1.0f / WindowSize.Height; InvWindowSize.Height = 1.0f / WindowSize.Height;
} }
...@@ -222,7 +228,7 @@ namespace irr ...@@ -222,7 +228,7 @@ namespace irr
ScreenHeight; ScreenHeight;
bool IsActive; bool IsActive;
NSBitmapImageRep *SoftwareDriverTarget; NSBitmapImageRep *SoftwareDriverTarget;
bool IsSoftwareRenderer, bool IsSoftwareRenderer,
IsShiftDown, IsShiftDown,
IsControlDown, IsControlDown,
IsResizable; IsResizable;
......
...@@ -1436,19 +1436,6 @@ video::IVideoModeList* CIrrDeviceMacOSX::getVideoModeList() ...@@ -1436,19 +1436,6 @@ video::IVideoModeList* CIrrDeviceMacOSX::getVideoModeList()
return &VideoModeList; return &VideoModeList;
} }
extern "C" IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(const SIrrlichtCreationParameters& param)
{
CIrrDeviceMacOSX* dev = new CIrrDeviceMacOSX(param);
if (dev && !dev->getVideoDriver() && param.DriverType != video::EDT_NULL)
{
dev->drop();
dev = 0;
}
return dev;
}
} // end namespace } // end namespace
#endif // _IRR_USE_OSX_DEVICE_ #endif // _IRR_USE_OSX_DEVICE_
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "IrrCompileConfig.h" #include "IrrCompileConfig.h"
#include "irrMath.h" #include "irrMath.h"
#if defined(_IRR_USE_SDL_DEVICE_) #if defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
#include <SDL/SDL_endian.h> #include <SDL/SDL_endian.h>
#define bswap_16(X) SDL_Swap16(X) #define bswap_16(X) SDL_Swap16(X)
#define bswap_32(X) SDL_Swap32(X) #define bswap_32(X) SDL_Swap32(X)
...@@ -85,7 +85,7 @@ namespace os ...@@ -85,7 +85,7 @@ namespace os
// disable hires timer on multiple core systems, bios bugs result in bad hires timers. // disable hires timer on multiple core systems, bios bugs result in bad hires timers.
SYSTEM_INFO sysinfo; SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo); GetSystemInfo(&sysinfo);
MultiCore = (sysinfo.dwNumberOfProcessors > 1); MultiCore = (sysinfo.dwNumberOfProcessors > 1);
#endif #endif
HighPerformanceTimerSupport = QueryPerformanceFrequency(&HighPerformanceFreq); HighPerformanceTimerSupport = QueryPerformanceFrequency(&HighPerformanceFreq);
initVirtualTimer(); initVirtualTimer();
...@@ -96,11 +96,11 @@ namespace os ...@@ -96,11 +96,11 @@ namespace os
if (HighPerformanceTimerSupport) if (HighPerformanceTimerSupport)
{ {
#if !defined(_WIN32_WCE) && !defined (_IRR_XBOX_PLATFORM_) #if !defined(_WIN32_WCE) && !defined (_IRR_XBOX_PLATFORM_)
// Avoid potential timing inaccuracies across multiple cores by // Avoid potential timing inaccuracies across multiple cores by
// temporarily setting the affinity of this process to one core. // temporarily setting the affinity of this process to one core.
DWORD_PTR affinityMask; DWORD_PTR affinityMask;
if(MultiCore) if(MultiCore)
affinityMask = SetThreadAffinityMask(GetCurrentThread(), 1); affinityMask = SetThreadAffinityMask(GetCurrentThread(), 1);
#endif #endif
LARGE_INTEGER nTime; LARGE_INTEGER nTime;
BOOL queriedOK = QueryPerformanceCounter(&nTime); BOOL queriedOK = QueryPerformanceCounter(&nTime);
......
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