Fix display lists with non-triangle draw modes, move mesh builder state updating to OnNewMapLoaded.

This commit is contained in:
UnknownShadow200 2015-01-01 15:29:32 +11:00
parent e1ba6f7b11
commit d0f6fb0360
3 changed files with 13 additions and 13 deletions

View file

@ -319,21 +319,21 @@ namespace ClassicalSharp.GraphicsAPI {
if( format == VertexFormat.VertexPos3f ) {
fixed( Vector3* p = (vertices as Vector3[]) ) {
GL.VertexPointer( 3, VertexPointerType.Float, stride, (IntPtr)( 0 + (byte*)p ) );
GL.DrawArrays( BeginMode.Triangles, 0, count );
GL.DrawArrays( modeMappings[(int)mode], 0, count );
}
} else if( format == VertexFormat.VertexPos3fCol4b ) {
GL.EnableClientState( ArrayCap.ColorArray );
fixed( VertexPos3fCol4b* p = (vertices as VertexPos3fCol4b[]) ) {
GL.VertexPointer( 3, VertexPointerType.Float, stride, (IntPtr)( 0 + (byte*)p ) );
GL.ColorPointer( 4, ColorPointerType.UnsignedByte, stride, (IntPtr)( 12 + (byte*)p ) );
GL.DrawArrays( BeginMode.Triangles, 0, count );
GL.DrawArrays( modeMappings[(int)mode], 0, count );
}
} else if( format == VertexFormat.VertexPos3fTex2f ) {
GL.EnableClientState( ArrayCap.TextureCoordArray );
fixed( VertexPos3fTex2f* p = (vertices as VertexPos3fTex2f[]) ) {
GL.VertexPointer( 3, VertexPointerType.Float, stride, (IntPtr)( 0 + (byte*)p) );
GL.TexCoordPointer( 2, TexCoordPointerType.Float, stride, (IntPtr)( 12 + (byte*)p ) );
GL.DrawArrays( BeginMode.Triangles, 0, count );
GL.DrawArrays( modeMappings[(int)mode], 0, count );
}
} else if( format == VertexFormat.VertexPos3fTex2fCol4b ) {
GL.EnableClientState( ArrayCap.ColorArray );
@ -342,7 +342,7 @@ namespace ClassicalSharp.GraphicsAPI {
GL.VertexPointer( 3, VertexPointerType.Float, stride, (IntPtr)( 0 + (byte*)p ) );
GL.TexCoordPointer( 2, TexCoordPointerType.Float, stride, (IntPtr)( 12 + (byte*)p ) );
GL.ColorPointer( 4, ColorPointerType.UnsignedByte, stride, (IntPtr)( 20 + (byte*)p ) );
GL.DrawArrays( BeginMode.Triangles, 0, count );
GL.DrawArrays( modeMappings[(int)mode], 0, count );
}
}

View file

@ -96,14 +96,7 @@ namespace ClassicalSharp {
return allAir || allSolid;
}
public ChunkDrawInfo[] GetDrawInfo( int x, int y, int z, Map map ) {
this.map = map;
width = map.Width;
height = map.Height;
length = map.Length;
maxX = width - 1;
maxY = height - 1;
maxZ = length - 1;
public ChunkDrawInfo[] GetDrawInfo( int x, int y, int z ) {
BuildChunk( x, y, z );
return GetChunkInfo( x, y, z );
}
@ -373,6 +366,13 @@ namespace ClassicalSharp {
}
public virtual void OnNewMapLoaded() {
map = Window.Map;
width = map.Width;
height = map.Height;
length = map.Length;
maxX = width - 1;
maxY = height - 1;
maxZ = length - 1;
}
protected abstract ChunkDrawInfo[] GetChunkInfo( int x, int y, int z );

View file

@ -296,7 +296,7 @@ namespace ClassicalSharp {
if( info.DrawInfo == null ) {
if( inRange && chunksUpdatedThisFrame < 4 ) {
Window.ChunkUpdates++;
info.DrawInfo = builder.GetDrawInfo( loc.X, loc.Y, loc.Z, Window.Map );
info.DrawInfo = builder.GetDrawInfo( loc.X, loc.Y, loc.Z );
chunksUpdatedThisFrame++;
}
}