mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-10 07:49:57 -04:00
Fix display lists with non-triangle draw modes, move mesh builder state updating to OnNewMapLoaded.
This commit is contained in:
parent
e1ba6f7b11
commit
d0f6fb0360
@ -319,21 +319,21 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
if( format == VertexFormat.VertexPos3f ) {
|
if( format == VertexFormat.VertexPos3f ) {
|
||||||
fixed( Vector3* p = (vertices as Vector3[]) ) {
|
fixed( Vector3* p = (vertices as Vector3[]) ) {
|
||||||
GL.VertexPointer( 3, VertexPointerType.Float, stride, (IntPtr)( 0 + (byte*)p ) );
|
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 ) {
|
} else if( format == VertexFormat.VertexPos3fCol4b ) {
|
||||||
GL.EnableClientState( ArrayCap.ColorArray );
|
GL.EnableClientState( ArrayCap.ColorArray );
|
||||||
fixed( VertexPos3fCol4b* p = (vertices as VertexPos3fCol4b[]) ) {
|
fixed( VertexPos3fCol4b* p = (vertices as VertexPos3fCol4b[]) ) {
|
||||||
GL.VertexPointer( 3, VertexPointerType.Float, stride, (IntPtr)( 0 + (byte*)p ) );
|
GL.VertexPointer( 3, VertexPointerType.Float, stride, (IntPtr)( 0 + (byte*)p ) );
|
||||||
GL.ColorPointer( 4, ColorPointerType.UnsignedByte, stride, (IntPtr)( 12 + (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 ) {
|
} else if( format == VertexFormat.VertexPos3fTex2f ) {
|
||||||
GL.EnableClientState( ArrayCap.TextureCoordArray );
|
GL.EnableClientState( ArrayCap.TextureCoordArray );
|
||||||
fixed( VertexPos3fTex2f* p = (vertices as VertexPos3fTex2f[]) ) {
|
fixed( VertexPos3fTex2f* p = (vertices as VertexPos3fTex2f[]) ) {
|
||||||
GL.VertexPointer( 3, VertexPointerType.Float, stride, (IntPtr)( 0 + (byte*)p) );
|
GL.VertexPointer( 3, VertexPointerType.Float, stride, (IntPtr)( 0 + (byte*)p) );
|
||||||
GL.TexCoordPointer( 2, TexCoordPointerType.Float, stride, (IntPtr)( 12 + (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 ) {
|
} else if( format == VertexFormat.VertexPos3fTex2fCol4b ) {
|
||||||
GL.EnableClientState( ArrayCap.ColorArray );
|
GL.EnableClientState( ArrayCap.ColorArray );
|
||||||
@ -342,7 +342,7 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
GL.VertexPointer( 3, VertexPointerType.Float, stride, (IntPtr)( 0 + (byte*)p ) );
|
GL.VertexPointer( 3, VertexPointerType.Float, stride, (IntPtr)( 0 + (byte*)p ) );
|
||||||
GL.TexCoordPointer( 2, TexCoordPointerType.Float, stride, (IntPtr)( 12 + (byte*)p ) );
|
GL.TexCoordPointer( 2, TexCoordPointerType.Float, stride, (IntPtr)( 12 + (byte*)p ) );
|
||||||
GL.ColorPointer( 4, ColorPointerType.UnsignedByte, stride, (IntPtr)( 20 + (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 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,14 +96,7 @@ namespace ClassicalSharp {
|
|||||||
return allAir || allSolid;
|
return allAir || allSolid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChunkDrawInfo[] GetDrawInfo( int x, int y, int z, Map map ) {
|
public ChunkDrawInfo[] GetDrawInfo( int x, int y, int z ) {
|
||||||
this.map = map;
|
|
||||||
width = map.Width;
|
|
||||||
height = map.Height;
|
|
||||||
length = map.Length;
|
|
||||||
maxX = width - 1;
|
|
||||||
maxY = height - 1;
|
|
||||||
maxZ = length - 1;
|
|
||||||
BuildChunk( x, y, z );
|
BuildChunk( x, y, z );
|
||||||
return GetChunkInfo( x, y, z );
|
return GetChunkInfo( x, y, z );
|
||||||
}
|
}
|
||||||
@ -373,6 +366,13 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public virtual void OnNewMapLoaded() {
|
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 );
|
protected abstract ChunkDrawInfo[] GetChunkInfo( int x, int y, int z );
|
||||||
|
@ -296,7 +296,7 @@ namespace ClassicalSharp {
|
|||||||
if( info.DrawInfo == null ) {
|
if( info.DrawInfo == null ) {
|
||||||
if( inRange && chunksUpdatedThisFrame < 4 ) {
|
if( inRange && chunksUpdatedThisFrame < 4 ) {
|
||||||
Window.ChunkUpdates++;
|
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++;
|
chunksUpdatedThisFrame++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user