diff --git a/ClassicalSharp/Entities/Player.Rendering.cs b/ClassicalSharp/Entities/Player.Rendering.cs index 1ec04dd81..983dc3442 100644 --- a/ClassicalSharp/Entities/Player.Rendering.cs +++ b/ClassicalSharp/Entities/Player.Rendering.cs @@ -23,7 +23,7 @@ namespace ClassicalSharp { using( Font font = new Font( "Arial", 14 ) ) { DrawTextArgs args = new DrawTextArgs( DisplayName, font, true ); - nameTex = game.Drawer2D.MakeTextTexture( ref args, 0, 0 ); + nameTex = game.Drawer2D.MakeBitmappedTextTexture( ref args, 0, 0 ); } } diff --git a/ClassicalSharp/GraphicsAPI/OpenGLApi.cs b/ClassicalSharp/GraphicsAPI/OpenGLApi.cs index faac3fbf6..a9751bc57 100644 --- a/ClassicalSharp/GraphicsAPI/OpenGLApi.cs +++ b/ClassicalSharp/GraphicsAPI/OpenGLApi.cs @@ -231,18 +231,16 @@ namespace ClassicalSharp.GraphicsAPI { int batchStride; public override void DrawDynamicVb( DrawMode mode, int id, T[] vertices, int count ) { - int sizeInBytes = count * batchStride; GL.BindBuffer( BufferTarget.ArrayBuffer, id ); - GL.BufferSubData( BufferTarget.ArrayBuffer, IntPtr.Zero, new IntPtr( sizeInBytes ), vertices ); + GL.BufferSubData( BufferTarget.ArrayBuffer, IntPtr.Zero, new IntPtr( count * batchStride ), vertices ); setupBatchFunc(); GL.DrawArrays( modeMappings[(int)mode], 0, count ); } public override void DrawDynamicIndexedVb( DrawMode mode, int id, T[] vertices, int vCount, int indicesCount ) { - int sizeInBytes = vCount * batchStride; GL.BindBuffer( BufferTarget.ArrayBuffer, id ); - GL.BufferSubData( BufferTarget.ArrayBuffer, IntPtr.Zero, new IntPtr( sizeInBytes ), vertices ); + GL.BufferSubData( BufferTarget.ArrayBuffer, IntPtr.Zero, new IntPtr( vCount * batchStride ), vertices ); setupBatchFunc(); GL.DrawElements( modeMappings[(int)mode], indicesCount, indexType, zero ); diff --git a/ClassicalSharp/Rendering/WeatherRenderer.cs b/ClassicalSharp/Rendering/WeatherRenderer.cs index e91a2c8b5..81826ab48 100644 --- a/ClassicalSharp/Rendering/WeatherRenderer.cs +++ b/ClassicalSharp/Rendering/WeatherRenderer.cs @@ -46,8 +46,11 @@ namespace ClassicalSharp { MakeRainForSquare( pos.X + dx, rainY, height, pos.Z + dz, col, ref index ); } } - graphics.BeginVbBatch( VertexFormat.Pos3fTex2fCol4b ); - graphics.DrawDynamicIndexedVb( DrawMode.Triangles, weatherVb, vertices, index, index * 6 / 4 ); + // fixes crashing on nVidia cards in OpenGL builds. + if( index > 0 ) { + graphics.BeginVbBatch( VertexFormat.Pos3fTex2fCol4b ); + graphics.DrawDynamicIndexedVb( DrawMode.Triangles, weatherVb, vertices, index, index * 6 / 4 ); + } graphics.AlphaBlending = false; graphics.Texturing = false; graphics.DepthWrite = true; @@ -55,7 +58,7 @@ namespace ClassicalSharp { float AlphaAt( float x ) { // Wolfram Alpha: fit {0,178},{1,169},{4,147},{9,114},{16,59},{25,9} - return (float)( 0.05 * x * x - 8 * x + 178 ); + return 0.05f * x * x - 8 * x + 178; } void MakeRainForSquare( int x, int y, int height, int z, FastColour col, ref int index ) { @@ -63,12 +66,12 @@ namespace ClassicalSharp { float v2 = height / 6f + v1; vertices[index++] = new VertexPos3fTex2fCol4b( x, y, z, 0, v2, col ); - vertices[index++] = new VertexPos3fTex2fCol4b( x, y + height, z, 0, v1, col ); + vertices[index++] = new VertexPos3fTex2fCol4b( x, y + height, z, 0, v1, col ); vertices[index++] = new VertexPos3fTex2fCol4b( x + 1, y + height, z + 1, 2, v1, col ); - vertices[index++] = new VertexPos3fTex2fCol4b( x + 1, y, z + 1, 2, v2, col ); + vertices[index++] = new VertexPos3fTex2fCol4b( x + 1, y, z + 1, 2, v2, col ); vertices[index++] = new VertexPos3fTex2fCol4b( x + 1, y, z, 2, v2, col ); - vertices[index++] = new VertexPos3fTex2fCol4b( x + 1, y + height, z, 2, v1, col ); + vertices[index++] = new VertexPos3fTex2fCol4b( x + 1, y + height, z, 2, v1, col ); vertices[index++] = new VertexPos3fTex2fCol4b( x, y + height, z + 1, 0, v1, col ); vertices[index++] = new VertexPos3fTex2fCol4b( x, y, z + 1, 0, v2, col ); } @@ -104,7 +107,7 @@ namespace ClassicalSharp { int GetRainHeight( int x, int z ) { if( x < 0 || z < 0 || x >= width || z >= length ) return map.EdgeHeight - 1; int index = ( x * length ) + z; - int height = heightmap[index]; + int height = heightmap[index]; return height == short.MaxValue ? CalcHeightAt( x, maxY, z, index ) : height; } @@ -117,7 +120,7 @@ namespace ClassicalSharp { return y; } mapIndex -= oneY; - } + } heightmap[index] = -1; return -1; } diff --git a/Launcher2/Gui/Screens/MainScreen.cs b/Launcher2/Gui/Screens/MainScreen.cs index c8b0af102..525354d5d 100644 --- a/Launcher2/Gui/Screens/MainScreen.cs +++ b/Launcher2/Gui/Screens/MainScreen.cs @@ -67,12 +67,9 @@ namespace Launcher2 { buttonWidth, buttonHeight, 0, -50, (x, y) => game.SetScreen( new DirectConnectScreen( game ) ) ); - MakeButtonAt( "Singleplayer", Anchor.LeftOrTop, Anchor.BottomOrRight, - sideButtonWidth, buttonHeight, 10, -10, + MakeButtonAt( "Singleplayer", Anchor.Centre, Anchor.Centre, + buttonWidth, buttonHeight, 0, 0, (x, y) => Client.Start( "default.zip" ) ); - - MakeButtonAt( "Resume", Anchor.BottomOrRight, Anchor.BottomOrRight, - sideButtonWidth, buttonHeight, -10, -10, null ); } const int buttonWidth = 220, buttonHeight = 35, sideButtonWidth = 150;