Commit 8060c6c9 authored by bitplane's avatar bitplane

resizing software devices in linux. Need to keep hold of XVisualInfo until...

resizing software devices in linux. Need to keep hold of XVisualInfo until window destruction, so we can use it to make new XImages when the window is resized

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@849 dfc29bdd-3216-0410-991c-e03cc46cb475
parent c2b3d99f
...@@ -44,10 +44,10 @@ CIrrDeviceLinux::CIrrDeviceLinux(video::E_DRIVER_TYPE driverType, ...@@ -44,10 +44,10 @@ CIrrDeviceLinux::CIrrDeviceLinux(video::E_DRIVER_TYPE driverType,
const char* version) const char* version)
: CIrrDeviceStub(version, receiver), : CIrrDeviceStub(version, receiver),
#ifdef _IRR_COMPILE_WITH_X11_ #ifdef _IRR_COMPILE_WITH_X11_
display(0), screennr(0), window(0), StdHints(0), SoftwareImage(0), display(0), visual(0), screennr(0), window(0), StdHints(0), SoftwareImage(0),
#endif #endif
Fullscreen(fullscreen), StencilBuffer(sbuffer), AntiAlias(antiAlias), DriverType(driverType), Fullscreen(fullscreen), StencilBuffer(sbuffer), AntiAlias(antiAlias), DriverType(driverType),
Width(windowSize.Width), Height(windowSize.Height), Depth(24), Width(windowSize.Width), Height(windowSize.Height), Depth(24),
Close(false), WindowActive(false), WindowMinimized(false), UseXVidMode(false), UseXRandR(false), UseGLXWindow(false) Close(false), WindowActive(false), WindowMinimized(false), UseXVidMode(false), UseXRandR(false), UseGLXWindow(false)
{ {
#ifdef _DEBUG #ifdef _DEBUG
...@@ -137,6 +137,9 @@ CIrrDeviceLinux::~CIrrDeviceLinux() ...@@ -137,6 +137,9 @@ CIrrDeviceLinux::~CIrrDeviceLinux()
XDestroyWindow(display,window); XDestroyWindow(display,window);
XCloseDisplay(display); XCloseDisplay(display);
} }
if (visual)
XFree(visual);
#endif // #ifdef _IRR_COMPILE_WITH_X11_ #endif // #ifdef _IRR_COMPILE_WITH_X11_
} }
...@@ -259,9 +262,6 @@ bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize, ...@@ -259,9 +262,6 @@ bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize,
Fullscreen = false; Fullscreen = false;
} }
} }
// get visual
XVisualInfo* visual = 0;
#ifdef _IRR_COMPILE_WITH_OPENGL_ #ifdef _IRR_COMPILE_WITH_OPENGL_
...@@ -593,7 +593,6 @@ bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize, ...@@ -593,7 +593,6 @@ bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize,
SoftwareImage->data = (char*) malloc(SoftwareImage->bytes_per_line * SoftwareImage->height * sizeof(char)); SoftwareImage->data = (char*) malloc(SoftwareImage->bytes_per_line * SoftwareImage->height * sizeof(char));
} }
XFree(visual);
#endif // #ifdef _IRR_COMPILE_WITH_X11_ #endif // #ifdef _IRR_COMPILE_WITH_X11_
return true; return true;
} }
...@@ -681,6 +680,21 @@ bool CIrrDeviceLinux::run() ...@@ -681,6 +680,21 @@ bool CIrrDeviceLinux::run()
{ {
Width = event.xconfigure.width; Width = event.xconfigure.width;
Height = event.xconfigure.height; Height = event.xconfigure.height;
// resize image data
if (DriverType == video::EDT_SOFTWARE || DriverType == video::EDT_BURNINGSVIDEO)
{
XDestroyImage(SoftwareImage);
SoftwareImage = XCreateImage(display,
visual->visual, visual->depth,
ZPixmap, 0, 0, Width, Height,
BitmapPad(display), 0);
// use malloc because X will free it later on
SoftwareImage->data = (char*) malloc(SoftwareImage->bytes_per_line * SoftwareImage->height * sizeof(char));
}
if (VideoDriver) if (VideoDriver)
VideoDriver->OnResize(core::dimension2d<s32>(Width, Height)); VideoDriver->OnResize(core::dimension2d<s32>(Width, Height));
} }
......
...@@ -290,6 +290,7 @@ namespace irr ...@@ -290,6 +290,7 @@ namespace irr
#ifdef _IRR_COMPILE_WITH_X11_ #ifdef _IRR_COMPILE_WITH_X11_
Display *display; Display *display;
XVisualInfo* visual;
int screennr; int screennr;
Window window; Window window;
XSetWindowAttributes attributes; XSetWindowAttributes attributes;
......
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