Changed the device creation to make more use of SIrrlichtCreationParameters. This should increase maintainability and ease addition of more configurable properties. The windows devices need to be adapted still, but should compile for now...
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1369 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
93ec1e0a4d
commit
f8010d7289
|
@ -41,9 +41,6 @@ namespace irr
|
|||
{
|
||||
public:
|
||||
|
||||
//! Destructor
|
||||
virtual ~IrrlichtDevice() {}
|
||||
|
||||
//! Runs the device.
|
||||
/** Also increments the virtual timer by calling
|
||||
ITimer::tick();. You can prevent this
|
||||
|
|
|
@ -37,19 +37,12 @@ namespace irr
|
|||
const char* wmDeleteWindow = "WM_DELETE_WINDOW";
|
||||
|
||||
//! constructor
|
||||
CIrrDeviceLinux::CIrrDeviceLinux(video::E_DRIVER_TYPE driverType,
|
||||
const core::dimension2d<s32>& windowSize,
|
||||
u32 bits, bool fullscreen,
|
||||
bool sbuffer, bool vsync, bool antiAlias,
|
||||
IEventReceiver* receiver,
|
||||
Window externalWindow,
|
||||
const char* version)
|
||||
: CIrrDeviceStub(version, receiver),
|
||||
CIrrDeviceLinux::CIrrDeviceLinux(const SIrrlichtCreationParameters& param)
|
||||
: CIrrDeviceStub(param),
|
||||
#ifdef _IRR_COMPILE_WITH_X11_
|
||||
display(0), visual(0), screennr(0), window(0), StdHints(0), SoftwareImage(0),
|
||||
#endif
|
||||
Fullscreen(fullscreen), StencilBuffer(sbuffer), AntiAlias(antiAlias), DriverType(driverType),
|
||||
Width(windowSize.Width), Height(windowSize.Height), Depth(24),
|
||||
Width(param.WindowSize.Width), Height(param.WindowSize.Height), Depth(24),
|
||||
Close(false), WindowActive(false), WindowMinimized(false), UseXVidMode(false), UseXRandR(false), UseGLXWindow(false), AutorepeatSupport(0)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
|
@ -77,18 +70,18 @@ CIrrDeviceLinux::CIrrDeviceLinux(video::E_DRIVER_TYPE driverType,
|
|||
createKeyMap();
|
||||
|
||||
// create window
|
||||
if (driverType != video::EDT_NULL)
|
||||
if (CreationParams.DriverType != video::EDT_NULL)
|
||||
{
|
||||
// create the window, only if we do not use the null device
|
||||
if (!createWindow(windowSize, bits, externalWindow))
|
||||
if (!createWindow())
|
||||
return;
|
||||
}
|
||||
|
||||
// create cursor control
|
||||
CursorControl = new CCursorControl(this, driverType == video::EDT_NULL);
|
||||
CursorControl = new CCursorControl(this, CreationParams.DriverType == video::EDT_NULL);
|
||||
|
||||
// create driver
|
||||
createDriver(windowSize, vsync);
|
||||
createDriver();
|
||||
|
||||
if (!VideoDriver)
|
||||
return;
|
||||
|
@ -97,7 +90,6 @@ CIrrDeviceLinux::CIrrDeviceLinux(video::E_DRIVER_TYPE driverType,
|
|||
}
|
||||
|
||||
|
||||
|
||||
//! destructor
|
||||
CIrrDeviceLinux::~CIrrDeviceLinux()
|
||||
{
|
||||
|
@ -119,14 +111,14 @@ CIrrDeviceLinux::~CIrrDeviceLinux()
|
|||
#endif // #ifdef _IRR_COMPILE_WITH_OPENGL_
|
||||
|
||||
#ifdef _IRR_LINUX_X11_VIDMODE_
|
||||
if (UseXVidMode && Fullscreen)
|
||||
if (UseXVidMode && CreationParams.Fullscreen)
|
||||
{
|
||||
XF86VidModeSwitchToMode(display, screennr, &oldVideoMode);
|
||||
XF86VidModeSetViewPort(display, screennr, 0, 0);
|
||||
}
|
||||
#endif
|
||||
#ifdef _IRR_LINUX_X11_RANDR_
|
||||
if (UseXRandR && Fullscreen)
|
||||
if (UseXRandR && CreationParams.Fullscreen)
|
||||
{
|
||||
XRRScreenConfiguration *config=XRRGetScreenInfo(display,DefaultRootWindow(display));
|
||||
XRRSetScreenConfig(display,config,DefaultRootWindow(display),oldRandrMode,oldRandrRotation,CurrentTime);
|
||||
|
@ -134,7 +126,7 @@ CIrrDeviceLinux::~CIrrDeviceLinux()
|
|||
}
|
||||
#endif
|
||||
|
||||
if (DriverType == video::EDT_SOFTWARE || DriverType == video::EDT_BURNINGSVIDEO)
|
||||
if (CreationParams.DriverType == video::EDT_SOFTWARE || CreationParams.DriverType == video::EDT_BURNINGSVIDEO)
|
||||
XDestroyImage(SoftwareImage);
|
||||
XDestroyWindow(display,window);
|
||||
XCloseDisplay(display);
|
||||
|
@ -160,12 +152,8 @@ int IrrPrintXError(Display *display, XErrorEvent *event)
|
|||
|
||||
|
||||
|
||||
bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize,
|
||||
u32 bits, Window externalWindow)
|
||||
bool CIrrDeviceLinux::createWindow()
|
||||
{
|
||||
Width = windowSize.Width;
|
||||
Height = windowSize.Height;
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_X11_
|
||||
#ifdef _DEBUG
|
||||
os::Printer::log("Creating X window...", ELL_INFORMATION);
|
||||
|
@ -183,7 +171,7 @@ bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize,
|
|||
|
||||
// query extension
|
||||
|
||||
if (Fullscreen)
|
||||
if (CreationParams.Fullscreen)
|
||||
{
|
||||
s32 eventbase, errorbase;
|
||||
s32 bestMode = -1;
|
||||
|
@ -228,7 +216,7 @@ bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize,
|
|||
else
|
||||
{
|
||||
os::Printer::log("Could not find specified video mode, running windowed.", ELL_WARNING);
|
||||
Fullscreen = false;
|
||||
CreationParams.Fullscreen = false;
|
||||
}
|
||||
|
||||
XFree(modes);
|
||||
|
@ -269,7 +257,7 @@ bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize,
|
|||
{
|
||||
os::Printer::log("VidMode or RandR extension must be installed to allow Irrlicht "
|
||||
"to switch to fullscreen mode. Running in windowed mode instead.", ELL_WARNING);
|
||||
Fullscreen = false;
|
||||
CreationParams.Fullscreen = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -279,7 +267,7 @@ bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize,
|
|||
GLXFBConfig glxFBConfig;
|
||||
int major, minor;
|
||||
bool isAvailableGLX=false;
|
||||
if (DriverType==video::EDT_OPENGL)
|
||||
if (CreationParams.DriverType==video::EDT_OPENGL)
|
||||
{
|
||||
isAvailableGLX=glXQueryExtension(display,&major,&minor);
|
||||
if (isAvailableGLX && glXQueryVersion(display, &major, &minor))
|
||||
|
@ -294,7 +282,7 @@ bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize,
|
|||
GLX_RED_SIZE, 4,
|
||||
GLX_GREEN_SIZE, 4,
|
||||
GLX_BLUE_SIZE, 4,
|
||||
GLX_ALPHA_SIZE, 4,
|
||||
GLX_ALPHA_SIZE, 0,
|
||||
GLX_DEPTH_SIZE, 16,
|
||||
GLX_DOUBLEBUFFER, GL_TRUE,
|
||||
GLX_STENCIL_SIZE, 1,
|
||||
|
@ -305,15 +293,15 @@ bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize,
|
|||
|
||||
GLXFBConfig *configList=0;
|
||||
int nitems=0;
|
||||
if (!AntiAlias)
|
||||
if (!CreationParams.AntiAlias)
|
||||
{
|
||||
visualAttrBuffer[17] = GL_FALSE;
|
||||
visualAttrBuffer[19] = 0;
|
||||
}
|
||||
if (StencilBuffer)
|
||||
if (CreationParams.Stencilbuffer)
|
||||
{
|
||||
configList=glXChooseFBConfig(display, screennr, visualAttrBuffer,&nitems);
|
||||
if (!configList && AntiAlias)
|
||||
if (!configList && CreationParams.AntiAlias)
|
||||
{
|
||||
while (!configList && (visualAttrBuffer[19]>1))
|
||||
{
|
||||
|
@ -328,7 +316,7 @@ bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize,
|
|||
if (configList)
|
||||
{
|
||||
os::Printer::log("No FSAA available.", ELL_WARNING);
|
||||
AntiAlias=false;
|
||||
CreationParams.AntiAlias=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -342,13 +330,13 @@ bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize,
|
|||
// Next try without stencil buffer
|
||||
if (!configList)
|
||||
{
|
||||
if (StencilBuffer)
|
||||
if (CreationParams.Stencilbuffer)
|
||||
os::Printer::log("No stencilbuffer available, disabling stencil shadows.", ELL_WARNING);
|
||||
StencilBuffer = false;
|
||||
CreationParams.Stencilbuffer = false;
|
||||
visualAttrBuffer[15]=0;
|
||||
|
||||
configList=glXChooseFBConfig(display, screennr, visualAttrBuffer,&nitems);
|
||||
if (!configList && AntiAlias)
|
||||
if (!configList && CreationParams.AntiAlias)
|
||||
{
|
||||
while (!configList && (visualAttrBuffer[19]>1))
|
||||
{
|
||||
|
@ -363,7 +351,7 @@ bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize,
|
|||
if (configList)
|
||||
{
|
||||
os::Printer::log("No FSAA available.", ELL_WARNING);
|
||||
AntiAlias=false;
|
||||
CreationParams.AntiAlias=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -380,7 +368,7 @@ bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize,
|
|||
os::Printer::log("No doublebuffering available.", ELL_WARNING);
|
||||
visualAttrBuffer[13] = GL_FALSE;
|
||||
configList=glXChooseFBConfig(display, screennr, visualAttrBuffer,&nitems);
|
||||
if (!configList && AntiAlias)
|
||||
if (!configList && CreationParams.AntiAlias)
|
||||
{
|
||||
while (!configList && (visualAttrBuffer[19]>1))
|
||||
{
|
||||
|
@ -395,7 +383,7 @@ bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize,
|
|||
if (configList)
|
||||
{
|
||||
os::Printer::log("No FSAA available.", ELL_WARNING);
|
||||
AntiAlias=false;
|
||||
CreationParams.AntiAlias=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -423,21 +411,21 @@ bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize,
|
|||
GLX_RED_SIZE, 4,
|
||||
GLX_GREEN_SIZE, 4,
|
||||
GLX_BLUE_SIZE, 4,
|
||||
GLX_ALPHA_SIZE, 4,
|
||||
GLX_ALPHA_SIZE, 0,
|
||||
GLX_DEPTH_SIZE, 16,
|
||||
GLX_DOUBLEBUFFER, GL_TRUE,
|
||||
GLX_STENCIL_SIZE, 1,
|
||||
None
|
||||
};
|
||||
|
||||
if (StencilBuffer)
|
||||
if (CreationParams.Stencilbuffer)
|
||||
visual=glXChooseVisual(display, screennr, visualAttrBuffer);
|
||||
if (!visual)
|
||||
{
|
||||
if (StencilBuffer)
|
||||
if (CreationParams.Stencilbuffer)
|
||||
{
|
||||
os::Printer::log("No stencilbuffer available, disabling stencil shadows.", ELL_WARNING);
|
||||
StencilBuffer = false;
|
||||
CreationParams.Stencilbuffer = false;
|
||||
}
|
||||
visualAttrBuffer[15]=0;
|
||||
|
||||
|
@ -494,7 +482,7 @@ bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize,
|
|||
ButtonReleaseMask | KeyReleaseMask;
|
||||
|
||||
// create Window, either for Fullscreen or windowed mode
|
||||
if (Fullscreen)
|
||||
if (CreationParams.Fullscreen)
|
||||
{
|
||||
attributes.override_redirect = True;
|
||||
|
||||
|
@ -517,7 +505,7 @@ bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize,
|
|||
attributes.event_mask |= ExposureMask;
|
||||
attributes.event_mask |= FocusChangeMask;
|
||||
|
||||
if(!externalWindow)
|
||||
if(!CreationParams.WindowId)
|
||||
{
|
||||
window = XCreateWindow(display,
|
||||
RootWindow(display, visual->screen),
|
||||
|
@ -529,7 +517,7 @@ bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize,
|
|||
else
|
||||
{
|
||||
window = XCreateWindow(display,
|
||||
externalWindow,
|
||||
(Window)CreationParams.WindowId,
|
||||
0, 0, Width, Height, 0, visual->depth,
|
||||
InputOutput, visual->visual,
|
||||
CWBorderPixel | CWColormap | CWEventMask,
|
||||
|
@ -547,7 +535,7 @@ bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize,
|
|||
#ifdef _IRR_COMPILE_WITH_OPENGL_
|
||||
|
||||
// connect glx context to window
|
||||
if (isAvailableGLX && DriverType==video::EDT_OPENGL)
|
||||
if (isAvailableGLX && CreationParams.DriverType==video::EDT_OPENGL)
|
||||
{
|
||||
if (UseGLXWindow)
|
||||
{
|
||||
|
@ -605,7 +593,7 @@ bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize,
|
|||
// create an XImage for the software renderer
|
||||
//(thx to Nadav for some clues on how to do that!)
|
||||
|
||||
if (DriverType == video::EDT_SOFTWARE || DriverType == video::EDT_BURNINGSVIDEO)
|
||||
if (CreationParams.DriverType == video::EDT_SOFTWARE || CreationParams.DriverType == video::EDT_BURNINGSVIDEO)
|
||||
{
|
||||
SoftwareImage = XCreateImage(display,
|
||||
visual->visual, visual->depth,
|
||||
|
@ -622,16 +610,15 @@ bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize,
|
|||
|
||||
|
||||
//! create the driver
|
||||
void CIrrDeviceLinux::createDriver(const core::dimension2d<s32>& windowSize,
|
||||
bool vsync)
|
||||
void CIrrDeviceLinux::createDriver()
|
||||
{
|
||||
switch(DriverType)
|
||||
switch(CreationParams.DriverType)
|
||||
{
|
||||
#ifdef _IRR_COMPILE_WITH_X11_
|
||||
|
||||
case video::EDT_SOFTWARE:
|
||||
#ifdef _IRR_COMPILE_WITH_SOFTWARE_
|
||||
VideoDriver = video::createSoftwareDriver(windowSize, Fullscreen, FileSystem, this);
|
||||
VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this);
|
||||
#else
|
||||
os::Printer::log("No Software driver support compiled in.", ELL_ERROR);
|
||||
#endif
|
||||
|
@ -639,7 +626,7 @@ void CIrrDeviceLinux::createDriver(const core::dimension2d<s32>& windowSize,
|
|||
|
||||
case video::EDT_BURNINGSVIDEO:
|
||||
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
|
||||
VideoDriver = video::createSoftwareDriver2(windowSize, Fullscreen, FileSystem, this);
|
||||
VideoDriver = video::createSoftwareDriver2(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this);
|
||||
#else
|
||||
os::Printer::log("Burning's video driver was not compiled in.", ELL_ERROR);
|
||||
#endif
|
||||
|
@ -648,7 +635,7 @@ void CIrrDeviceLinux::createDriver(const core::dimension2d<s32>& windowSize,
|
|||
case video::EDT_OPENGL:
|
||||
#ifdef _IRR_COMPILE_WITH_OPENGL_
|
||||
if (Context)
|
||||
VideoDriver = video::createOpenGLDriver(windowSize, Fullscreen, StencilBuffer, FileSystem, vsync, AntiAlias);
|
||||
VideoDriver = video::createOpenGLDriver(CreationParams.WindowSize, CreationParams.Fullscreen, CreationParams.Stencilbuffer, FileSystem, CreationParams.Vsync, CreationParams.AntiAlias);
|
||||
#else
|
||||
os::Printer::log("No OpenGL support compiled in.", ELL_ERROR);
|
||||
#endif
|
||||
|
@ -661,7 +648,7 @@ void CIrrDeviceLinux::createDriver(const core::dimension2d<s32>& windowSize,
|
|||
break;
|
||||
|
||||
case video::EDT_NULL:
|
||||
VideoDriver = video::createNullDriver(FileSystem, windowSize);
|
||||
VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -669,7 +656,7 @@ void CIrrDeviceLinux::createDriver(const core::dimension2d<s32>& windowSize,
|
|||
break;
|
||||
#else
|
||||
case video::EDT_NULL:
|
||||
VideoDriver = video::createNullDriver(FileSystem, windowSize);
|
||||
VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
|
||||
break;
|
||||
default:
|
||||
os::Printer::log("No X11 support compiled in. Only Null driver available.", ELL_ERROR);
|
||||
|
@ -686,7 +673,7 @@ bool CIrrDeviceLinux::run()
|
|||
os::Timer::tick();
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_X11_
|
||||
if ((DriverType != video::EDT_NULL) && display)
|
||||
if ((CreationParams.DriverType != video::EDT_NULL) && display)
|
||||
{
|
||||
SEvent irrevent;
|
||||
|
||||
|
@ -706,7 +693,7 @@ bool CIrrDeviceLinux::run()
|
|||
Height = event.xconfigure.height;
|
||||
|
||||
// resize image data
|
||||
if (DriverType == video::EDT_SOFTWARE || DriverType == video::EDT_BURNINGSVIDEO)
|
||||
if (CreationParams.DriverType == video::EDT_SOFTWARE || CreationParams.DriverType == video::EDT_BURNINGSVIDEO)
|
||||
{
|
||||
XDestroyImage(SoftwareImage);
|
||||
|
||||
|
@ -814,11 +801,10 @@ bool CIrrDeviceLinux::run()
|
|||
case KeyPress:
|
||||
{
|
||||
SKeyMap mp;
|
||||
//mp.X11Key = XLookupKeysym(&event.xkey, 0);
|
||||
char buf[5]="\0\0\0\0";
|
||||
XLookupString(&event.xkey, buf, 4, &mp.X11Key, NULL);
|
||||
char buf[8]={0};
|
||||
XLookupString(&event.xkey, buf, sizeof(buf), &mp.X11Key, NULL);
|
||||
|
||||
s32 idx = KeyMap.binary_search(mp);
|
||||
const s32 idx = KeyMap.binary_search(mp);
|
||||
|
||||
if (idx != -1)
|
||||
irrevent.KeyInput.Key = (EKEY_CODE)KeyMap[idx].Win32Key;
|
||||
|
@ -829,7 +815,7 @@ bool CIrrDeviceLinux::run()
|
|||
}
|
||||
irrevent.EventType = irr::EET_KEY_INPUT_EVENT;
|
||||
irrevent.KeyInput.PressedDown = (event.type == KeyPress);
|
||||
mbtowc(&irrevent.KeyInput.Char, buf, 4);
|
||||
mbtowc(&irrevent.KeyInput.Char, buf, sizeof(buf));
|
||||
irrevent.KeyInput.Control = (event.xkey.state & ControlMask) != 0;
|
||||
irrevent.KeyInput.Shift = (event.xkey.state & ShiftMask) != 0;
|
||||
postEventFromUser(irrevent);
|
||||
|
@ -889,7 +875,7 @@ void CIrrDeviceLinux::sleep(u32 timeMs, bool pauseTimer=false)
|
|||
void CIrrDeviceLinux::setWindowCaption(const wchar_t* text)
|
||||
{
|
||||
#ifdef _IRR_COMPILE_WITH_X11_
|
||||
if (DriverType == video::EDT_NULL)
|
||||
if (CreationParams.DriverType == video::EDT_NULL)
|
||||
return;
|
||||
|
||||
XTextProperty txt;
|
||||
|
@ -907,7 +893,7 @@ void CIrrDeviceLinux::present(video::IImage* image, void* windowId, core::rect<s
|
|||
{
|
||||
#ifdef _IRR_COMPILE_WITH_X11_
|
||||
// this is only necessary for software drivers.
|
||||
if (DriverType != video::EDT_SOFTWARE && DriverType != video::EDT_BURNINGSVIDEO)
|
||||
if (CreationParams.DriverType != video::EDT_SOFTWARE && CreationParams.DriverType != video::EDT_BURNINGSVIDEO)
|
||||
return;
|
||||
|
||||
// thx to Nadav, who send me some clues of how to display the image
|
||||
|
@ -1033,7 +1019,7 @@ bool CIrrDeviceLinux::isWindowActive() const
|
|||
void CIrrDeviceLinux::setResizeAble(bool resize)
|
||||
{
|
||||
#ifdef _IRR_COMPILE_WITH_X11_
|
||||
if (DriverType == video::EDT_NULL)
|
||||
if (CreationParams.DriverType == video::EDT_NULL)
|
||||
return;
|
||||
|
||||
XUnmapWindow(display, window);
|
||||
|
@ -1335,17 +1321,7 @@ void CIrrDeviceLinux::createKeyMap()
|
|||
|
||||
IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(const SIrrlichtCreationParameters& param)
|
||||
{
|
||||
CIrrDeviceLinux* dev = new CIrrDeviceLinux(
|
||||
param.DriverType,
|
||||
param.WindowSize,
|
||||
param.Bits,
|
||||
param.Fullscreen,
|
||||
param.Stencilbuffer,
|
||||
param.Vsync,
|
||||
param.AntiAlias,
|
||||
param.EventReceiver,
|
||||
(Window)param.WindowId,
|
||||
param.SDK_version_do_not_use);
|
||||
CIrrDeviceLinux* dev = new CIrrDeviceLinux(param);
|
||||
|
||||
if (dev && !dev->getVideoDriver() && param.DriverType != video::EDT_NULL)
|
||||
{
|
||||
|
|
|
@ -47,10 +47,7 @@ namespace irr
|
|||
public:
|
||||
|
||||
//! constructor
|
||||
CIrrDeviceLinux(video::E_DRIVER_TYPE deviceType,
|
||||
const core::dimension2d<s32>& windowSize, u32 bits,
|
||||
bool fullscreen, bool stencilbuffer, bool vsync, bool antiAlias, IEventReceiver* receiver,
|
||||
Window window, const char* version);
|
||||
CIrrDeviceLinux(const SIrrlichtCreationParameters& param);
|
||||
|
||||
//! destructor
|
||||
virtual ~CIrrDeviceLinux();
|
||||
|
@ -87,11 +84,9 @@ namespace irr
|
|||
private:
|
||||
|
||||
//! create the driver
|
||||
void createDriver(const core::dimension2d<s32>& windowSize,
|
||||
bool vsync);
|
||||
void createDriver();
|
||||
|
||||
bool createWindow(const core::dimension2d<s32>& windowSize, u32 bits,
|
||||
Window externalWindow);
|
||||
bool createWindow();
|
||||
|
||||
void createKeyMap();
|
||||
|
||||
|
@ -308,11 +303,6 @@ namespace irr
|
|||
GLXContext Context;
|
||||
#endif
|
||||
#endif
|
||||
bool Fullscreen;
|
||||
bool StencilBuffer;
|
||||
bool AntiAlias;
|
||||
video::E_DRIVER_TYPE DriverType;
|
||||
|
||||
u32 Width, Height, Depth;
|
||||
bool Close;
|
||||
bool WindowActive;
|
||||
|
|
|
@ -37,17 +37,10 @@ namespace irr
|
|||
const char* wmDeleteWindow = "WM_DELETE_WINDOW";
|
||||
|
||||
//! constructor
|
||||
CIrrDeviceSDL::CIrrDeviceSDL(video::E_DRIVER_TYPE driverType,
|
||||
const core::dimension2d<s32>& windowSize,
|
||||
u32 bits,
|
||||
bool fullscreen, bool stencilbuffer, bool vsync,
|
||||
bool antiAlias, IEventReceiver* receiver,
|
||||
void* windowID, const char* version)
|
||||
: CIrrDeviceStub(version, receiver), Depth(bits),
|
||||
Fullscreen(fullscreen), Stencilbuffer(stencilbuffer), Vsync(vsync),
|
||||
AntiAlias(antiAlias), Resizeable(false),
|
||||
Screen((SDL_Surface*)windowID), SDL_Flags(SDL_HWSURFACE|SDL_ANYFORMAT),
|
||||
Width(windowSize.Width), Height(windowSize.Height), Close(0),
|
||||
CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
|
||||
: CIrrDeviceStub(param), Resizeable(false),
|
||||
Screen((SDL_Surface*)param.WindowId), SDL_Flags(SDL_HWSURFACE|SDL_ANYFORMAT),
|
||||
Width(param.WindowSize.Width), Height(param.WindowSize.Height), Close(0),
|
||||
WindowActive(false)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
|
@ -56,7 +49,7 @@ CIrrDeviceSDL::CIrrDeviceSDL(video::E_DRIVER_TYPE driverType,
|
|||
|
||||
// Initialize SDL... Timer for sleep, video for the obvious, and
|
||||
// noparachute prevents SDL from catching fatal errors.
|
||||
if ( SDL_Init( SDL_INIT_TIMER|SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE ) < 0 )
|
||||
if (SDL_Init( SDL_INIT_TIMER|SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE ) < 0)
|
||||
{
|
||||
os::Printer::log( "Unable to initialize SDL!", SDL_GetError());
|
||||
Close = 1;
|
||||
|
@ -81,31 +74,30 @@ CIrrDeviceSDL::CIrrDeviceSDL(video::E_DRIVER_TYPE driverType,
|
|||
// enable key to character translation
|
||||
SDL_EnableUNICODE(1);
|
||||
|
||||
if ( Fullscreen )
|
||||
if ( CreationParams.Fullscreen )
|
||||
SDL_Flags |= SDL_FULLSCREEN;
|
||||
if (driverType == video::EDT_OPENGL)
|
||||
if (CreationParams.DriverType == video::EDT_OPENGL)
|
||||
SDL_Flags |= SDL_OPENGL;
|
||||
else
|
||||
SDL_Flags |= SDL_DOUBLEBUF;
|
||||
// create window
|
||||
if (driverType != video::EDT_NULL)
|
||||
if (CreationParams.DriverType != video::EDT_NULL)
|
||||
{
|
||||
// create the window, only if we do not use the null device
|
||||
createWindow(driverType);
|
||||
createWindow();
|
||||
}
|
||||
|
||||
// create cursor control
|
||||
CursorControl = new CCursorControl(this);
|
||||
|
||||
// create driver
|
||||
createDriver(driverType, windowSize);
|
||||
createDriver();
|
||||
|
||||
if (VideoDriver)
|
||||
createGUIAndScene();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! destructor
|
||||
CIrrDeviceSDL::~CIrrDeviceSDL()
|
||||
{
|
||||
|
@ -115,15 +107,14 @@ CIrrDeviceSDL::~CIrrDeviceSDL()
|
|||
}
|
||||
|
||||
|
||||
|
||||
bool CIrrDeviceSDL::createWindow(video::E_DRIVER_TYPE driverType)
|
||||
bool CIrrDeviceSDL::createWindow()
|
||||
{
|
||||
if ( Close )
|
||||
return false;
|
||||
|
||||
if (driverType == video::EDT_OPENGL)
|
||||
if (CreationParams.DriverType == video::EDT_OPENGL)
|
||||
{
|
||||
if (Depth==16)
|
||||
if (CreationParams.Bits==16)
|
||||
{
|
||||
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
|
||||
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
|
||||
|
@ -135,12 +126,12 @@ bool CIrrDeviceSDL::createWindow(video::E_DRIVER_TYPE driverType)
|
|||
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );
|
||||
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
|
||||
}
|
||||
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, Depth);
|
||||
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, CreationParams.Bits);
|
||||
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
|
||||
}
|
||||
|
||||
if ( !Screen )
|
||||
Screen = SDL_SetVideoMode( Width, Height, Depth, SDL_Flags );
|
||||
Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags );
|
||||
if ( !Screen )
|
||||
{
|
||||
os::Printer::log( "Could not initialize display!" );
|
||||
|
@ -152,10 +143,9 @@ bool CIrrDeviceSDL::createWindow(video::E_DRIVER_TYPE driverType)
|
|||
|
||||
|
||||
//! create the driver
|
||||
void CIrrDeviceSDL::createDriver(video::E_DRIVER_TYPE driverType,
|
||||
const core::dimension2d<s32>& windowSize)
|
||||
void CIrrDeviceSDL::createDriver()
|
||||
{
|
||||
switch(driverType)
|
||||
switch(CreationParams.DriverType)
|
||||
{
|
||||
case video::EDT_DIRECT3D8:
|
||||
case video::EDT_DIRECT3D9:
|
||||
|
@ -164,7 +154,7 @@ void CIrrDeviceSDL::createDriver(video::E_DRIVER_TYPE driverType,
|
|||
|
||||
case video::EDT_SOFTWARE:
|
||||
#ifdef _IRR_COMPILE_WITH_SOFTWARE_
|
||||
VideoDriver = video::createSoftwareDriver(windowSize, Fullscreen, FileSystem, this);
|
||||
VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this);
|
||||
#else
|
||||
os::Printer::log("No Software driver support compiled in.", ELL_ERROR);
|
||||
#endif
|
||||
|
@ -172,7 +162,7 @@ void CIrrDeviceSDL::createDriver(video::E_DRIVER_TYPE driverType,
|
|||
|
||||
case video::EDT_BURNINGSVIDEO:
|
||||
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
|
||||
VideoDriver = video::createSoftwareDriver2(windowSize, Fullscreen, FileSystem, this);
|
||||
VideoDriver = video::createSoftwareDriver2(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this);
|
||||
#else
|
||||
os::Printer::log("Burning's video driver was not compiled in.", ELL_ERROR);
|
||||
#endif
|
||||
|
@ -180,14 +170,14 @@ void CIrrDeviceSDL::createDriver(video::E_DRIVER_TYPE driverType,
|
|||
|
||||
case video::EDT_OPENGL:
|
||||
#ifdef _IRR_COMPILE_WITH_OPENGL_
|
||||
VideoDriver = video::createOpenGLDriver(windowSize, Fullscreen, Stencilbuffer, FileSystem, Vsync, AntiAlias);
|
||||
VideoDriver = video::createOpenGLDriver(CreationParams.WindowSize, CreationParams.Fullscreen, CreationParams.Stencilbuffer, FileSystem, CreationParams.Vsync, CreationParams.AntiAlias);
|
||||
#else
|
||||
os::Printer::log("No OpenGL support compiled in.", ELL_ERROR);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case video::EDT_NULL:
|
||||
VideoDriver = video::createNullDriver(FileSystem, windowSize);
|
||||
VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -388,7 +378,7 @@ void CIrrDeviceSDL::setResizeAble(bool resize)
|
|||
else
|
||||
SDL_Flags &= ~SDL_RESIZABLE;
|
||||
SDL_FreeSurface(Screen);
|
||||
Screen = SDL_SetVideoMode( Width, Height, Depth, SDL_Flags );
|
||||
Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags );
|
||||
Resizeable = resize;
|
||||
}
|
||||
}
|
||||
|
@ -543,17 +533,7 @@ void CIrrDeviceSDL::createKeyMap()
|
|||
|
||||
IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(const SIrrlichtCreationParameters& param)
|
||||
{
|
||||
CIrrDeviceSDL* dev = new CIrrDeviceSDL(
|
||||
param.DriverType,
|
||||
param.WindowSize,
|
||||
param.Bits,
|
||||
param.Fullscreen,
|
||||
param.Stencilbuffer,
|
||||
param.Vsync,
|
||||
param.AntiAlias,
|
||||
param.EventReceiver,
|
||||
param.WindowId,
|
||||
param.SDK_version_do_not_use);
|
||||
CIrrDeviceSDL* dev = new CIrrDeviceSDL(param);
|
||||
|
||||
if (dev && !dev->getVideoDriver() && param.DriverType != video::EDT_NULL)
|
||||
{
|
||||
|
|
|
@ -26,11 +26,7 @@ namespace irr
|
|||
public:
|
||||
|
||||
//! constructor
|
||||
CIrrDeviceSDL(video::E_DRIVER_TYPE deviceType,
|
||||
const core::dimension2d<s32>& windowSize, u32 bits,
|
||||
bool fullscreen, bool stencilbuffer, bool vsync,
|
||||
bool antiAlias, IEventReceiver* receiver,
|
||||
void* windowID, const char* version);
|
||||
CIrrDeviceSDL(const SIrrlichtCreationParameters& param);
|
||||
|
||||
//! destructor
|
||||
virtual ~CIrrDeviceSDL();
|
||||
|
@ -156,19 +152,13 @@ namespace irr
|
|||
private:
|
||||
|
||||
//! create the driver
|
||||
void createDriver(video::E_DRIVER_TYPE driverType,
|
||||
const core::dimension2d<s32>& windowSize);
|
||||
void createDriver();
|
||||
|
||||
bool createWindow(video::E_DRIVER_TYPE driverType);
|
||||
bool createWindow();
|
||||
|
||||
void createKeyMap();
|
||||
|
||||
s32 MouseX, MouseY;
|
||||
u32 Depth;
|
||||
bool Fullscreen;
|
||||
bool Stencilbuffer;
|
||||
bool Vsync;
|
||||
bool AntiAlias;
|
||||
bool Resizeable;
|
||||
|
||||
SDL_Surface* Screen;
|
||||
|
|
|
@ -17,10 +17,10 @@ namespace irr
|
|||
{
|
||||
|
||||
//! constructor
|
||||
CIrrDeviceStub::CIrrDeviceStub(const char* version, IEventReceiver* recv)
|
||||
CIrrDeviceStub::CIrrDeviceStub(const SIrrlichtCreationParameters& params)
|
||||
: IrrlichtDevice(), VideoDriver(0), GUIEnvironment(0), SceneManager(0),
|
||||
Timer(0), CursorControl(0), UserReceiver(recv), Logger(0), Operator(0),
|
||||
FileSystem(io::createFileSystem()), InputReceivingSceneManager(0)
|
||||
Timer(0), CursorControl(0), UserReceiver(params.EventReceiver), Logger(0), Operator(0),
|
||||
FileSystem(0), InputReceivingSceneManager(0), CreationParams(params)
|
||||
{
|
||||
Timer = new CTimer();
|
||||
if (os::Printer::Logger)
|
||||
|
@ -37,11 +37,12 @@ CIrrDeviceStub::CIrrDeviceStub(const char* version, IEventReceiver* recv)
|
|||
|
||||
os::Printer::Logger = Logger;
|
||||
|
||||
FileSystem = io::createFileSystem();
|
||||
core::stringc s = "Irrlicht Engine version ";
|
||||
s.append(getVersion());
|
||||
os::Printer::log(s.c_str(), ELL_INFORMATION);
|
||||
|
||||
checkVersion(version);
|
||||
checkVersion(params.SDK_version_do_not_use);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "IrrlichtDevice.h"
|
||||
#include "IImagePresenter.h"
|
||||
#include "SIrrCreationParameters.h"
|
||||
#include "CVideoModeList.h"
|
||||
|
||||
namespace irr
|
||||
|
@ -52,7 +53,7 @@ namespace irr
|
|||
public:
|
||||
|
||||
//! constructor
|
||||
CIrrDeviceStub(const char* version, IEventReceiver* resv);
|
||||
CIrrDeviceStub(const SIrrlichtCreationParameters& param);
|
||||
|
||||
//! destructor
|
||||
virtual ~CIrrDeviceStub();
|
||||
|
@ -114,12 +115,13 @@ namespace irr
|
|||
scene::ISceneManager* SceneManager;
|
||||
ITimer* Timer;
|
||||
gui::ICursorControl* CursorControl;
|
||||
video::CVideoModeList VideoModeList;
|
||||
IEventReceiver* UserReceiver;
|
||||
CLogger* Logger;
|
||||
IOSOperator* Operator;
|
||||
io::IFileSystem* FileSystem;
|
||||
scene::ISceneManager* InputReceivingSceneManager;
|
||||
video::CVideoModeList VideoModeList;
|
||||
SIrrlichtCreationParameters CreationParams;
|
||||
};
|
||||
|
||||
} // end namespace irr
|
||||
|
|
|
@ -283,10 +283,9 @@ CIrrDeviceWin32::CIrrDeviceWin32(video::E_DRIVER_TYPE driverType,
|
|||
bool stencilbuffer, bool vsync,
|
||||
bool antiAlias,
|
||||
bool highPrecisionFPU,
|
||||
IEventReceiver* receiver,
|
||||
HWND externalWindow,
|
||||
const char* version)
|
||||
: CIrrDeviceStub(version, receiver), HWnd(0), ChangedToFullScreen(false),
|
||||
const SIrrlichtCreationParameters& params)
|
||||
: CIrrDeviceStub(param), HWnd(0), ChangedToFullScreen(false),
|
||||
FullScreen(fullscreen), IsNonNTWindows(false), Resized(false),
|
||||
ExternalWindow(false), Win32CursorControl(0)
|
||||
{
|
||||
|
@ -938,9 +937,8 @@ IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(
|
|||
parameters.Vsync,
|
||||
parameters.AntiAlias,
|
||||
parameters.HighPrecisionFPU,
|
||||
parameters.EventReceiver,
|
||||
reinterpret_cast<HWND>(parameters.WindowId),
|
||||
parameters.SDK_version_do_not_use);
|
||||
parameters);
|
||||
|
||||
if (dev && !dev->getVideoDriver() && parameters.DriverType != video::EDT_NULL)
|
||||
{
|
||||
|
|
|
@ -26,9 +26,8 @@ namespace irr
|
|||
core::dimension2d<s32> windowSize, u32 bits,
|
||||
bool fullscreen, bool stencilbuffer, bool vsync,
|
||||
bool antiAlias, bool highPrecisionFPU,
|
||||
IEventReceiver* receiver,
|
||||
HWND window,
|
||||
const char* version);
|
||||
const SIrrlichtCreationParameters& params);
|
||||
|
||||
//! destructor
|
||||
virtual ~CIrrDeviceWin32();
|
||||
|
|
|
@ -282,10 +282,9 @@ CIrrDeviceWinCE::CIrrDeviceWinCE(video::E_DRIVER_TYPE driverType,
|
|||
bool stencilbuffer, bool vsync,
|
||||
bool antiAlias,
|
||||
bool highPrecisionFPU,
|
||||
IEventReceiver* receiver,
|
||||
HWND externalWindow,
|
||||
const char* version)
|
||||
: CIrrDeviceStub(version, receiver), HWnd(0), ChangedToFullScreen(false),
|
||||
const SIrrlichtCreationParameters& params)
|
||||
: CIrrDeviceStub(params), HWnd(externalWindow), ChangedToFullScreen(false),
|
||||
FullScreen(fullscreen), Resized(false),
|
||||
ExternalWindow(false), Win32CursorControl(0)
|
||||
{
|
||||
|
@ -303,7 +302,7 @@ CIrrDeviceWinCE::CIrrDeviceWinCE(video::E_DRIVER_TYPE driverType,
|
|||
#endif
|
||||
|
||||
// create the window, only if we do not use the null device
|
||||
if (driverType != video::EDT_NULL && externalWindow==0)
|
||||
if (driverType != video::EDT_NULL && HWnd==0)
|
||||
{
|
||||
const wchar_t* ClassName = L"CIrrDeviceWinCE";
|
||||
|
||||
|
@ -361,7 +360,6 @@ CIrrDeviceWinCE::CIrrDeviceWinCE(video::E_DRIVER_TYPE driverType,
|
|||
// attach external window
|
||||
if (externalWindow)
|
||||
{
|
||||
HWnd = externalWindow;
|
||||
RECT r;
|
||||
GetWindowRect(HWnd, &r);
|
||||
windowSize.Width = r.right - r.left;
|
||||
|
@ -789,9 +787,8 @@ IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(
|
|||
parameters.Vsync,
|
||||
parameters.AntiAlias,
|
||||
parameters.HighPrecisionFPU,
|
||||
parameters.EventReceiver,
|
||||
reinterpret_cast<HWND>(parameters.WindowId),
|
||||
parameters.SDK_version_do_not_use);
|
||||
parameters);
|
||||
|
||||
if (dev && !dev->getVideoDriver() && parameters.DriverType != video::EDT_NULL)
|
||||
{
|
||||
|
|
|
@ -30,9 +30,8 @@ namespace irr
|
|||
core::dimension2d<s32> windowSize, u32 bits,
|
||||
bool fullscreen, bool stencilbuffer, bool vsync,
|
||||
bool antiAlias, bool highPrecisionFPU,
|
||||
IEventReceiver* receiver,
|
||||
HWND window,
|
||||
const char* version);
|
||||
const SIrrlichtCreationParameters& params);
|
||||
|
||||
//! destructor
|
||||
virtual ~CIrrDeviceWinCE();
|
||||
|
|
Loading…
Reference in New Issue