Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
PrimitivesRenderer2D.cs
浏览该文件的文档.
1using Engine.Media;
2
3namespace Engine.Graphics {
4 public class PrimitivesRenderer2D : BasePrimitivesRenderer<FlatBatch2D, TexturedBatch2D, FontBatch2D> {
5 public static Matrix ViewportMatrix() {
6 Viewport viewport = Display.Viewport;
7 float num = 1f / viewport.Width;
8 float num2 = 1f / viewport.Height;
9 return new Matrix(
10 2f * num,
11 0f,
12 0f,
13 0f,
14 0f,
15 -2f * num2,
16 0f,
17 0f,
18 0f,
19 0f,
20 1f,
21 0f,
22 -1f,
23 1f,
24 0f,
25 1f
26 );
27 }
28
29 public FlatBatch2D FlatBatch(int layer = 0,
30 DepthStencilState depthStencilState = null,
31 RasterizerState rasterizerState = null,
32 BlendState blendState = null) {
33 depthStencilState = depthStencilState ?? DepthStencilState.None;
34 rasterizerState = rasterizerState ?? RasterizerState.CullNoneScissor;
35 blendState = blendState ?? BlendState.AlphaBlend;
36 return FindFlatBatch(layer, depthStencilState, rasterizerState, blendState);
37 }
38
40 bool useAlphaTest = false,
41 int layer = 0,
42 DepthStencilState depthStencilState = null,
43 RasterizerState rasterizerState = null,
44 BlendState blendState = null,
45 SamplerState samplerState = null) {
46 depthStencilState = depthStencilState ?? DepthStencilState.None;
47 rasterizerState = rasterizerState ?? RasterizerState.CullNoneScissor;
48 blendState = blendState ?? BlendState.AlphaBlend;
49 samplerState = samplerState ?? SamplerState.LinearClamp;
50 return FindTexturedBatch(
51 texture,
52 useAlphaTest,
53 layer,
54 depthStencilState,
55 rasterizerState,
56 blendState,
57 samplerState
58 );
59 }
60
61 public FontBatch2D FontBatch(BitmapFont font = null,
62 int layer = 0,
63 DepthStencilState depthStencilState = null,
64 RasterizerState rasterizerState = null,
65 BlendState blendState = null,
66 SamplerState samplerState = null) {
67 font = font ?? BitmapFont.DebugFont;
68 depthStencilState = depthStencilState ?? DepthStencilState.None;
69 rasterizerState = rasterizerState ?? RasterizerState.CullNoneScissor;
70 blendState = blendState ?? BlendState.AlphaBlend;
71 samplerState = samplerState ?? SamplerState.LinearClamp;
72 return FindFontBatch(font, layer, depthStencilState, rasterizerState, blendState, samplerState);
73 }
74
75 public void Flush(bool clearAfterFlush = true, int maxLayer = int.MaxValue) {
76 Flush(ViewportMatrix(), clearAfterFlush, maxLayer);
77 }
78 }
79}
T1 FindFlatBatch(int layer, DepthStencilState depthStencilState, RasterizerState rasterizerState, BlendState blendState)
T3 FindFontBatch(BitmapFont font, int layer, DepthStencilState depthStencilState, RasterizerState rasterizerState, BlendState blendState, SamplerState samplerState)
T2 FindTexturedBatch(Texture2D texture, bool useAlphaTest, int layer, DepthStencilState depthStencilState, RasterizerState rasterizerState, BlendState blendState, SamplerState samplerState)
static readonly BlendState AlphaBlend
static readonly DepthStencilState None
static Viewport Viewport
TexturedBatch2D TexturedBatch(Texture2D texture, bool useAlphaTest=false, int layer=0, DepthStencilState depthStencilState=null, RasterizerState rasterizerState=null, BlendState blendState=null, SamplerState samplerState=null)
FlatBatch2D FlatBatch(int layer=0, DepthStencilState depthStencilState=null, RasterizerState rasterizerState=null, BlendState blendState=null)
void Flush(bool clearAfterFlush=true, int maxLayer=int.MaxValue)
FontBatch2D FontBatch(BitmapFont font=null, int layer=0, DepthStencilState depthStencilState=null, RasterizerState rasterizerState=null, BlendState blendState=null, SamplerState samplerState=null)
static readonly RasterizerState CullNoneScissor
static BitmapFont DebugFont