mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 01:55:19 -04:00
Fix compliation on Mono not working on normal .NET 4.
This commit is contained in:
parent
9d907b333b
commit
2096a554f3
@ -23,14 +23,10 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
DataBuffer[] vBuffers = new DataBuffer[vBufferSize];
|
DataBuffer[] vBuffers = new DataBuffer[vBufferSize];
|
||||||
DynamicDataBuffer[] dynamicvBuffers = new DynamicDataBuffer[iBufferSize];
|
DynamicDataBuffer[] dynamicvBuffers = new DynamicDataBuffer[iBufferSize];
|
||||||
DataBuffer[] iBuffers = new DataBuffer[iBufferSize];
|
DataBuffer[] iBuffers = new DataBuffer[iBufferSize];
|
||||||
MatrixStack viewStack, projStack, texStack;
|
|
||||||
MatrixStack curStack;
|
MatrixStack viewStack, projStack, texStack, curStack;
|
||||||
PrimitiveType[] modeMappings = {
|
PrimitiveType[] modeMappings;
|
||||||
PrimitiveType.TriangleList, PrimitiveType.LineList,
|
Format[] depthFormats, viewFormats;
|
||||||
PrimitiveType.TriangleStrip,
|
|
||||||
};
|
|
||||||
static Format[] depthFormats = { Format.D32, Format.D24X8, Format.D24S8, Format.D24X4S4, Format.D16, Format.D15S1 };
|
|
||||||
static Format[] viewFormats = { Format.X8R8G8B8, Format.R5G6B5, Format.X1R5G5B5 };
|
|
||||||
Format depthFormat, viewFormat;
|
Format depthFormat, viewFormat;
|
||||||
CreateFlags createFlags = CreateFlags.HardwareVertexProcessing;
|
CreateFlags createFlags = CreateFlags.HardwareVertexProcessing;
|
||||||
|
|
||||||
@ -38,6 +34,7 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
IntPtr windowHandle = ((WinWindowInfo)game.WindowInfo).WindowHandle;
|
IntPtr windowHandle = ((WinWindowInfo)game.WindowInfo).WindowHandle;
|
||||||
d3d = new Direct3D();
|
d3d = new Direct3D();
|
||||||
int adapter = d3d.Adapters[0].Adapter;
|
int adapter = d3d.Adapters[0].Adapter;
|
||||||
|
InitFields();
|
||||||
FindCompatibleFormat( adapter );
|
FindCompatibleFormat( adapter );
|
||||||
|
|
||||||
PresentParameters args = GetPresentArgs( 640, 480 );
|
PresentParameters args = GetPresentArgs( 640, 480 );
|
||||||
@ -92,10 +89,7 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Compare[] compareFuncs = {
|
Compare[] compareFuncs;
|
||||||
Compare.Always, Compare.NotEqual, Compare.Never, Compare.Less,
|
|
||||||
Compare.LessEqual, Compare.Equal, Compare.GreaterEqual, Compare.Greater,
|
|
||||||
};
|
|
||||||
Compare alphaTestFunc;
|
Compare alphaTestFunc;
|
||||||
int alphaTestRef;
|
int alphaTestRef;
|
||||||
public override void AlphaTestFunc( CompareFunc func, float value ) {
|
public override void AlphaTestFunc( CompareFunc func, float value ) {
|
||||||
@ -105,11 +99,7 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
device.SetRenderState( RenderState.AlphaRef, alphaTestRef );
|
device.SetRenderState( RenderState.AlphaRef, alphaTestRef );
|
||||||
}
|
}
|
||||||
|
|
||||||
Blend[] blendFuncs = {
|
Blend[] blendFuncs;
|
||||||
Blend.Zero, Blend.One,
|
|
||||||
Blend.SourceAlpha, Blend.InverseSourceAlpha,
|
|
||||||
Blend.DestinationAlpha, Blend.InverseDestinationAlpha,
|
|
||||||
};
|
|
||||||
Blend srcBlendFunc, dstBlendFunc;
|
Blend srcBlendFunc, dstBlendFunc;
|
||||||
public override void AlphaBlendFunc( BlendFunc srcFunc, BlendFunc dstFunc ) {
|
public override void AlphaBlendFunc( BlendFunc srcFunc, BlendFunc dstFunc ) {
|
||||||
srcBlendFunc = blendFuncs[(int)srcFunc];
|
srcBlendFunc = blendFuncs[(int)srcFunc];
|
||||||
@ -150,7 +140,7 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
device.SetRenderState( RenderState.FogEnd, value );
|
device.SetRenderState( RenderState.FogEnd, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
FogMode[] modes = { FogMode.Linear, FogMode.Exponential, FogMode.ExponentialSquared };
|
FogMode[] modes;
|
||||||
FogMode fogTableMode;
|
FogMode fogTableMode;
|
||||||
public override void SetFogMode( Fog fogMode ) {
|
public override void SetFogMode( Fog fogMode ) {
|
||||||
FogMode newMode = modes[(int)fogMode];
|
FogMode newMode = modes[(int)fogMode];
|
||||||
@ -255,12 +245,7 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
|
|
||||||
#region Vertex buffers
|
#region Vertex buffers
|
||||||
|
|
||||||
D3D.VertexFormat[] formatMapping = {
|
D3D.VertexFormat[] formatMapping;
|
||||||
D3D.VertexFormat.Position | D3D.VertexFormat.Texture2,
|
|
||||||
D3D.VertexFormat.Position | D3D.VertexFormat.Diffuse,
|
|
||||||
D3D.VertexFormat.Position | D3D.VertexFormat.Texture2 | D3D.VertexFormat.Diffuse,
|
|
||||||
};
|
|
||||||
|
|
||||||
public override int CreateVb<T>( T[] vertices, VertexFormat format, int count ) {
|
public override int CreateVb<T>( T[] vertices, VertexFormat format, int count ) {
|
||||||
int size = count * strideSizes[(int)format];
|
int size = count * strideSizes[(int)format];
|
||||||
DataBuffer buffer = device.CreateVertexBuffer( size, Usage.None, formatMapping[(int)format], Pool.Managed );
|
DataBuffer buffer = device.CreateVertexBuffer( size, Usage.None, formatMapping[(int)format], Pool.Managed );
|
||||||
@ -577,6 +562,55 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
tempSurface.UnlockRectangle();
|
tempSurface.UnlockRectangle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InitFields() {
|
||||||
|
// See comment in Game() constructor
|
||||||
|
#if !__MonoCS__
|
||||||
|
modeMappings = new [] { PrimitiveType.TriangleList, PrimitiveType.LineList };
|
||||||
|
depthFormats = new [] { Format.D32, Format.D24X8, Format.D24S8, Format.D24X4S4, Format.D16, Format.D15S1 };
|
||||||
|
viewFormats = new [] { Format.X8R8G8B8, Format.R8G8B8, Format.R5G6B5, Format.X1R5G5B5 };
|
||||||
|
|
||||||
|
compareFuncs = new [] {
|
||||||
|
Compare.Always, Compare.NotEqual, Compare.Never, Compare.Less,
|
||||||
|
Compare.LessEqual, Compare.Equal, Compare.GreaterEqual, Compare.Greater,
|
||||||
|
};
|
||||||
|
blendFuncs = new [] {
|
||||||
|
Blend.Zero, Blend.One, Blend.SourceAlpha, Blend.InverseSourceAlpha,
|
||||||
|
Blend.DestinationAlpha, Blend.InverseDestinationAlpha,
|
||||||
|
};
|
||||||
|
formatMapping = new [] {
|
||||||
|
D3D.VertexFormat.Position | D3D.VertexFormat.Texture2,
|
||||||
|
D3D.VertexFormat.Position | D3D.VertexFormat.Diffuse,
|
||||||
|
D3D.VertexFormat.Position | D3D.VertexFormat.Texture2 | D3D.VertexFormat.Diffuse,
|
||||||
|
};
|
||||||
|
modes = new [] { FogMode.Linear, FogMode.Exponential, FogMode.ExponentialSquared };
|
||||||
|
|
||||||
|
#else
|
||||||
|
modeMappings = new PrimitiveType[2];
|
||||||
|
modeMappings[0] = PrimitiveType.TriangleList; modeMappings[1] = PrimitiveType.LineList;
|
||||||
|
depthFormats = new Format[6];
|
||||||
|
depthFormats[0] = Format.D32; depthFormats[1] = Format.D24X8; depthFormats[2] = Format.D24S8;
|
||||||
|
depthFormats[3] = Format.D24X4S4; depthFormats[4] = Format.D16; depthFormats[5] = Format.D15S1;
|
||||||
|
viewFormats = new Format[3];
|
||||||
|
viewFormats[0] = Format.X8R8G8B8; viewFormats[1] = Format.R8G8B8;
|
||||||
|
viewFormats[2] = Format.R5G6B5; viewFormats[3] = Format.X1R5G5B5;
|
||||||
|
|
||||||
|
compareFuncs = new Compare[8];
|
||||||
|
compareFuncs[0] = Compare.Always; compareFuncs[1] = Compare.NotEqual; compareFuncs[2] = Compare.Never;
|
||||||
|
compareFuncs[3] = Compare.Less; compareFuncs[4] = Compare.LessEqual; compareFuncs[5] = Compare.Equal;
|
||||||
|
compareFuncs[6] = Compare.GreaterEqual; compareFuncs[7] = Compare.Equal;
|
||||||
|
blendFuncs = new Blend[6];
|
||||||
|
blendFuncs[0] = Blend.Zero; blendFuncs[1] = Blend.One; blendFuncs[2] = Blend.SourceAlpha;
|
||||||
|
blendFuncs[3] = Blend.InverseSourceAlpha; blendFuncs[4] = Blend.DestinationAlpha;
|
||||||
|
blendFuncs[5] = Blend.InverseDestinationAlpha;
|
||||||
|
formatMapping = new D3D.VertexFormat[3];
|
||||||
|
formatMapping[0] = D3D.VertexFormat.Position | D3D.VertexFormat.Texture2;
|
||||||
|
formatMapping[1] = D3D.VertexFormat.Position | D3D.VertexFormat.Diffuse;
|
||||||
|
formatMapping[2] = D3D.VertexFormat.Position | D3D.VertexFormat.Texture2 | D3D.VertexFormat.Diffuse;
|
||||||
|
modes = new FogMode[3];
|
||||||
|
modes[0] = FogMode.Linear; modes[1] = FogMode.Exponential; modes[2] = FogMode.ExponentialSquared;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
@ -419,7 +419,7 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
void InitFields() {
|
void InitFields() {
|
||||||
// See comment in Game() constructor
|
// See comment in Game() constructor
|
||||||
#if !__MonoCS__
|
#if !__MonoCS__
|
||||||
modeMappings = new [] { BeginMode.Triangles, BeginMode.Lines, BeginMode.TriangleStrip };
|
modeMappings = new [] { BeginMode.Triangles, BeginMode.Lines };
|
||||||
blendFuncs = new [] {
|
blendFuncs = new [] {
|
||||||
BlendingFactor.Zero, BlendingFactor.One,
|
BlendingFactor.Zero, BlendingFactor.One,
|
||||||
BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha,
|
BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha,
|
||||||
@ -432,9 +432,8 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
fogModes = new [] { FogMode.Linear, FogMode.Exp, FogMode.Exp2 };
|
fogModes = new [] { FogMode.Linear, FogMode.Exp, FogMode.Exp2 };
|
||||||
matrixModes = new [] { MatrixMode.Projection, MatrixMode.Modelview, MatrixMode.Texture };
|
matrixModes = new [] { MatrixMode.Projection, MatrixMode.Modelview, MatrixMode.Texture };
|
||||||
#else
|
#else
|
||||||
modeMappings = new BeginMode[3];
|
modeMappings = new BeginMode[2];
|
||||||
modeMappings[0] = BeginMode.Triangles; modeMappings[1] = BeginMode.Lines;
|
modeMappings[0] = BeginMode.Triangles; modeMappings[1] = BeginMode.Lines;
|
||||||
modeMappings[2] = BeginMode.TriangleStrip;
|
|
||||||
blendFuncs = new BlendingFactor[6];
|
blendFuncs = new BlendingFactor[6];
|
||||||
blendFuncs[0] = BlendingFactor.Zero; blendFuncs[1] = BlendingFactor.One;
|
blendFuncs[0] = BlendingFactor.Zero; blendFuncs[1] = BlendingFactor.One;
|
||||||
blendFuncs[2] = BlendingFactor.SrcAlpha; blendFuncs[3] = BlendingFactor.OneMinusSrcAlpha;
|
blendFuncs[2] = BlendingFactor.SrcAlpha; blendFuncs[3] = BlendingFactor.OneMinusSrcAlpha;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user