Commit f902b0a4 authored by hybrid's avatar hybrid

Always check the SoftwareImage pointer, and use the getVideoMode method.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1637 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 9bbe75de
...@@ -117,7 +117,7 @@ CIrrDeviceLinux::~CIrrDeviceLinux() ...@@ -117,7 +117,7 @@ CIrrDeviceLinux::~CIrrDeviceLinux()
os::Printer::log("Could not release glx context.", ELL_WARNING); os::Printer::log("Could not release glx context.", ELL_WARNING);
} }
glXDestroyContext(display, Context); glXDestroyContext(display, Context);
if (UseGLXWindow) if (glxWin)
glXDestroyWindow(display, glxWin); glXDestroyWindow(display, glxWin);
} }
#endif // #ifdef _IRR_COMPILE_WITH_OPENGL_ #endif // #ifdef _IRR_COMPILE_WITH_OPENGL_
...@@ -138,7 +138,7 @@ CIrrDeviceLinux::~CIrrDeviceLinux() ...@@ -138,7 +138,7 @@ CIrrDeviceLinux::~CIrrDeviceLinux()
} }
#endif #endif
if (CreationParams.DriverType == video::EDT_SOFTWARE || CreationParams.DriverType == video::EDT_BURNINGSVIDEO) if (SoftwareImage)
XDestroyImage(SoftwareImage); XDestroyImage(SoftwareImage);
XDestroyWindow(display,window); XDestroyWindow(display,window);
XCloseDisplay(display); XCloseDisplay(display);
...@@ -150,7 +150,6 @@ CIrrDeviceLinux::~CIrrDeviceLinux() ...@@ -150,7 +150,6 @@ CIrrDeviceLinux::~CIrrDeviceLinux()
} }
#if defined(_IRR_COMPILE_WITH_X11_) && defined(_DEBUG) #if defined(_IRR_COMPILE_WITH_X11_) && defined(_DEBUG)
int IrrPrintXError(Display *display, XErrorEvent *event) int IrrPrintXError(Display *display, XErrorEvent *event)
{ {
...@@ -189,6 +188,7 @@ bool CIrrDeviceLinux::createWindow() ...@@ -189,6 +188,7 @@ bool CIrrDeviceLinux::createWindow()
if (CreationParams.Fullscreen) if (CreationParams.Fullscreen)
{ {
getVideoModeList();
#if defined(_IRR_LINUX_X11_VIDMODE_) || defined(_IRR_LINUX_X11_RANDR_) #if defined(_IRR_LINUX_X11_VIDMODE_) || defined(_IRR_LINUX_X11_RANDR_)
s32 eventbase, errorbase; s32 eventbase, errorbase;
s32 bestMode = -1; s32 bestMode = -1;
...@@ -204,13 +204,7 @@ bool CIrrDeviceLinux::createWindow() ...@@ -204,13 +204,7 @@ bool CIrrDeviceLinux::createWindow()
XF86VidModeGetAllModeLines(display, screennr, &modeCount, &modes); XF86VidModeGetAllModeLines(display, screennr, &modeCount, &modes);
// save current video mode
oldVideoMode = *modes[0];
// find fitting mode // find fitting mode
VideoModeList.setDesktop(defaultDepth, core::dimension2d<s32>(
modes[0]->hdisplay, modes[0]->vdisplay));
for (s32 i = 0; i<modeCount; ++i) for (s32 i = 0; i<modeCount; ++i)
{ {
if (bestMode==-1 && modes[i]->hdisplay >= Width && modes[i]->vdisplay >= Height) if (bestMode==-1 && modes[i]->hdisplay >= Width && modes[i]->vdisplay >= Height)
...@@ -221,8 +215,6 @@ bool CIrrDeviceLinux::createWindow() ...@@ -221,8 +215,6 @@ bool CIrrDeviceLinux::createWindow()
modes[i]->hdisplay < modes[bestMode]->hdisplay && modes[i]->hdisplay < modes[bestMode]->hdisplay &&
modes[i]->vdisplay < modes[bestMode]->vdisplay) modes[i]->vdisplay < modes[bestMode]->vdisplay)
bestMode = i; bestMode = i;
VideoModeList.addMode(core::dimension2d<s32>(
modes[i]->hdisplay, modes[i]->vdisplay), defaultDepth);
} }
if (bestMode != -1) if (bestMode != -1)
{ {
...@@ -246,10 +238,7 @@ bool CIrrDeviceLinux::createWindow() ...@@ -246,10 +238,7 @@ bool CIrrDeviceLinux::createWindow()
{ {
s32 modeCount; s32 modeCount;
XRRScreenConfiguration *config=XRRGetScreenInfo(display,DefaultRootWindow(display)); XRRScreenConfiguration *config=XRRGetScreenInfo(display,DefaultRootWindow(display));
oldRandrMode=XRRConfigCurrentConfiguration(config,&oldRandrRotation);
XRRScreenSize *modes=XRRConfigSizes(config,&modeCount); XRRScreenSize *modes=XRRConfigSizes(config,&modeCount);
VideoModeList.setDesktop(defaultDepth, core::dimension2d<s32>(
modes[oldRandrMode].width, modes[oldRandrMode].height));
for (s32 i = 0; i<modeCount; ++i) for (s32 i = 0; i<modeCount; ++i)
{ {
if (bestMode==-1 && (u32)modes[i].width >= Width && (u32)modes[i].height >= Height) if (bestMode==-1 && (u32)modes[i].width >= Width && (u32)modes[i].height >= Height)
...@@ -260,8 +249,6 @@ bool CIrrDeviceLinux::createWindow() ...@@ -260,8 +249,6 @@ bool CIrrDeviceLinux::createWindow()
modes[i].width < modes[bestMode].width && modes[i].width < modes[bestMode].width &&
modes[i].height < modes[bestMode].height) modes[i].height < modes[bestMode].height)
bestMode = i; bestMode = i;
VideoModeList.addMode(core::dimension2d<s32>(
modes[i].width, modes[i].height), defaultDepth);
} }
if (bestMode != -1) if (bestMode != -1)
{ {
...@@ -630,7 +617,8 @@ bool CIrrDeviceLinux::createWindow() ...@@ -630,7 +617,8 @@ bool CIrrDeviceLinux::createWindow()
BitmapPad(display), 0); BitmapPad(display), 0);
// use malloc because X will free it later on // use malloc because X will free it later on
SoftwareImage->data = (char*) malloc(SoftwareImage->bytes_per_line * SoftwareImage->height * sizeof(char)); if (SoftwareImage)
SoftwareImage->data = (char*) malloc(SoftwareImage->bytes_per_line * SoftwareImage->height * sizeof(char));
} }
#endif // #ifdef _IRR_COMPILE_WITH_X11_ #endif // #ifdef _IRR_COMPILE_WITH_X11_
...@@ -721,7 +709,7 @@ bool CIrrDeviceLinux::run() ...@@ -721,7 +709,7 @@ bool CIrrDeviceLinux::run()
Height = event.xconfigure.height; Height = event.xconfigure.height;
// resize image data // resize image data
if (CreationParams.DriverType == video::EDT_SOFTWARE || CreationParams.DriverType == video::EDT_BURNINGSVIDEO) if (SoftwareImage)
{ {
XDestroyImage(SoftwareImage); XDestroyImage(SoftwareImage);
...@@ -731,7 +719,8 @@ bool CIrrDeviceLinux::run() ...@@ -731,7 +719,8 @@ bool CIrrDeviceLinux::run()
BitmapPad(display), 0); BitmapPad(display), 0);
// use malloc because X will free it later on // use malloc because X will free it later on
SoftwareImage->data = (char*) malloc(SoftwareImage->bytes_per_line * SoftwareImage->height * sizeof(char)); if (SoftwareImage)
SoftwareImage->data = (char*) malloc(SoftwareImage->bytes_per_line * SoftwareImage->height * sizeof(char));
} }
if (VideoDriver) if (VideoDriver)
...@@ -927,11 +916,11 @@ void CIrrDeviceLinux::setWindowCaption(const wchar_t* text) ...@@ -927,11 +916,11 @@ void CIrrDeviceLinux::setWindowCaption(const wchar_t* text)
//! presents a surface in the client area //! presents a surface in the client area
bool CIrrDeviceLinux::present(video::IImage* image, void* windowId, core::rect<s32>* srcRect ) bool CIrrDeviceLinux::present(video::IImage* image, void* windowId, core::rect<s32>* srcRect)
{ {
#ifdef _IRR_COMPILE_WITH_X11_ #ifdef _IRR_COMPILE_WITH_X11_
// this is only necessary for software drivers. // this is only necessary for software drivers.
if (CreationParams.DriverType != video::EDT_SOFTWARE && CreationParams.DriverType != video::EDT_BURNINGSVIDEO) if (!SoftwareImage)
return true; return true;
// thx to Nadav, who send me some clues of how to display the image // thx to Nadav, who send me some clues of how to display the image
......
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