mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 18:15:28 -04:00
Fix crashing when rainy but not drawing any vertices on nVidia cards, use default.png font for player names.
This commit is contained in:
parent
db61780273
commit
42e86be6f0
@ -23,7 +23,7 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
using( Font font = new Font( "Arial", 14 ) ) {
|
using( Font font = new Font( "Arial", 14 ) ) {
|
||||||
DrawTextArgs args = new DrawTextArgs( DisplayName, font, true );
|
DrawTextArgs args = new DrawTextArgs( DisplayName, font, true );
|
||||||
nameTex = game.Drawer2D.MakeTextTexture( ref args, 0, 0 );
|
nameTex = game.Drawer2D.MakeBitmappedTextTexture( ref args, 0, 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,18 +231,16 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
|
|
||||||
int batchStride;
|
int batchStride;
|
||||||
public override void DrawDynamicVb<T>( DrawMode mode, int id, T[] vertices, int count ) {
|
public override void DrawDynamicVb<T>( DrawMode mode, int id, T[] vertices, int count ) {
|
||||||
int sizeInBytes = count * batchStride;
|
|
||||||
GL.BindBuffer( BufferTarget.ArrayBuffer, id );
|
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();
|
setupBatchFunc();
|
||||||
GL.DrawArrays( modeMappings[(int)mode], 0, count );
|
GL.DrawArrays( modeMappings[(int)mode], 0, count );
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DrawDynamicIndexedVb<T>( DrawMode mode, int id, T[] vertices, int vCount, int indicesCount ) {
|
public override void DrawDynamicIndexedVb<T>( DrawMode mode, int id, T[] vertices, int vCount, int indicesCount ) {
|
||||||
int sizeInBytes = vCount * batchStride;
|
|
||||||
GL.BindBuffer( BufferTarget.ArrayBuffer, id );
|
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();
|
setupBatchFunc();
|
||||||
GL.DrawElements( modeMappings[(int)mode], indicesCount, indexType, zero );
|
GL.DrawElements( modeMappings[(int)mode], indicesCount, indexType, zero );
|
||||||
|
@ -46,8 +46,11 @@ namespace ClassicalSharp {
|
|||||||
MakeRainForSquare( pos.X + dx, rainY, height, pos.Z + dz, col, ref index );
|
MakeRainForSquare( pos.X + dx, rainY, height, pos.Z + dz, col, ref index );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
graphics.BeginVbBatch( VertexFormat.Pos3fTex2fCol4b );
|
// fixes crashing on nVidia cards in OpenGL builds.
|
||||||
graphics.DrawDynamicIndexedVb( DrawMode.Triangles, weatherVb, vertices, index, index * 6 / 4 );
|
if( index > 0 ) {
|
||||||
|
graphics.BeginVbBatch( VertexFormat.Pos3fTex2fCol4b );
|
||||||
|
graphics.DrawDynamicIndexedVb( DrawMode.Triangles, weatherVb, vertices, index, index * 6 / 4 );
|
||||||
|
}
|
||||||
graphics.AlphaBlending = false;
|
graphics.AlphaBlending = false;
|
||||||
graphics.Texturing = false;
|
graphics.Texturing = false;
|
||||||
graphics.DepthWrite = true;
|
graphics.DepthWrite = true;
|
||||||
@ -55,7 +58,7 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
float AlphaAt( float x ) {
|
float AlphaAt( float x ) {
|
||||||
// Wolfram Alpha: fit {0,178},{1,169},{4,147},{9,114},{16,59},{25,9}
|
// 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 ) {
|
void MakeRainForSquare( int x, int y, int height, int z, FastColour col, ref int index ) {
|
||||||
|
@ -67,12 +67,9 @@ namespace Launcher2 {
|
|||||||
buttonWidth, buttonHeight, 0, -50,
|
buttonWidth, buttonHeight, 0, -50,
|
||||||
(x, y) => game.SetScreen( new DirectConnectScreen( game ) ) );
|
(x, y) => game.SetScreen( new DirectConnectScreen( game ) ) );
|
||||||
|
|
||||||
MakeButtonAt( "Singleplayer", Anchor.LeftOrTop, Anchor.BottomOrRight,
|
MakeButtonAt( "Singleplayer", Anchor.Centre, Anchor.Centre,
|
||||||
sideButtonWidth, buttonHeight, 10, -10,
|
buttonWidth, buttonHeight, 0, 0,
|
||||||
(x, y) => Client.Start( "default.zip" ) );
|
(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;
|
const int buttonWidth = 220, buttonHeight = 35, sideButtonWidth = 150;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user