Fix crashing of client on all platforms, fix new launcher crashing on linux.

This commit is contained in:
UnknownShadow200 2015-10-21 19:23:42 +11:00
parent 7cf129963d
commit d06bca9dba
3 changed files with 3 additions and 8 deletions

View File

@ -44,7 +44,7 @@ namespace ClassicalSharp {
elementsPerAtlas1D = Math.Min( elementsPerFullAtlas, totalElements ); elementsPerAtlas1D = Math.Min( elementsPerFullAtlas, totalElements );
int atlas1DHeight = Utils.NextPowerOf2( elementsPerAtlas1D * atlas2D.elementSize ); int atlas1DHeight = Utils.NextPowerOf2( elementsPerAtlas1D * atlas2D.elementSize );
Convert2DTo1D( atlas2D, atlasesCount, elementsPerAtlas1D ); Convert2DTo1D( atlas2D, atlasesCount, atlas1DHeight );
elementsPerBitmap = atlas1DHeight / atlas2D.elementSize; elementsPerBitmap = atlas1DHeight / atlas2D.elementSize;
invElementSize = 1f / elementsPerBitmap; invElementSize = 1f / elementsPerBitmap;
} }
@ -63,10 +63,8 @@ namespace ClassicalSharp {
void Make1DTexture( int i, FastBitmap atlas, TerrainAtlas2D atlas2D, int atlas1DHeight, ref int index ) { void Make1DTexture( int i, FastBitmap atlas, TerrainAtlas2D atlas2D, int atlas1DHeight, ref int index ) {
int elemSize = atlas2D.elementSize; int elemSize = atlas2D.elementSize;
using( Bitmap atlas1d = new Bitmap( atlas2D.elementSize, atlas1DHeight ) ) { using( Bitmap atlas1d = new Bitmap( atlas2D.elementSize, atlas1DHeight ) ) {
using( FastBitmap dst = new FastBitmap( atlas1d, true ) ) { using( FastBitmap dst = new FastBitmap( atlas1d, true ) ) {
for( int index1D = 0; index1D < elementsPerAtlas1D; index1D++ ) { for( int index1D = 0; index1D < elementsPerAtlas1D; index1D++ ) {
if( index >= 256 ) break;
FastBitmap.MovePortion( (index & 0x0F) * elemSize, (index >> 4) * elemSize, FastBitmap.MovePortion( (index & 0x0F) * elemSize, (index >> 4) * elemSize,
0, index1D * elemSize, atlas, dst, elemSize ); 0, index1D * elemSize, atlas, dst, elemSize );
index++; index++;

View File

@ -55,7 +55,7 @@ namespace Launcher2 {
fastBmp.Width, fastBmp.Height, 32, 0 ); fastBmp.Width, fastBmp.Height, 32, 0 );
API.XPutImage( API.DefaultDisplay, x11Info.WindowHandle, gc, image, API.XPutImage( API.DefaultDisplay, x11Info.WindowHandle, gc, image,
0, 0, 0, 0, fastBmp.Width, fastBmp.Height ); 0, 0, 0, 0, fastBmp.Width, fastBmp.Height );
API.XDestroyImage( image ); API.XFree( image );
} }
} }
} }

View File

@ -44,9 +44,6 @@ namespace OpenTK.Platform.X11 {
public extern static Bool XCheckWindowEvent(Display display, Window w, EventMask event_mask, ref XEvent event_return); public extern static Bool XCheckWindowEvent(Display display, Window w, EventMask event_mask, ref XEvent event_return);
[DllImport("libX11"), SuppressUnmanagedCodeSecurity] [DllImport("libX11"), SuppressUnmanagedCodeSecurity]
public extern static Bool XCheckTypedWindowEvent(Display display, Window w, XEventName event_type, ref XEvent event_return); public extern static Bool XCheckTypedWindowEvent(Display display, Window w, XEventName event_type, ref XEvent event_return);
[DllImport("libX11"), SuppressUnmanagedCodeSecurity]
public extern static int XDestroyImage(IntPtr image);
[DllImport("libX11"), SuppressUnmanagedCodeSecurity] [DllImport("libX11"), SuppressUnmanagedCodeSecurity]
public extern static int XDestroyWindow(IntPtr display, IntPtr window); public extern static int XDestroyWindow(IntPtr display, IntPtr window);