Logo
InternalCommandBuffer.h
1#pragma once
2
3namespace SharpKmyGfx
4{
5 ref class Shader;
6 ref class Texture;
7
8 public enum class PrimitiveType{
9 Points,
10 Lines,
15 };
16
17 public enum class IndexType{
18 U8,
19 U16,
20 U32,
21 };
22
23 public enum class BlendFactor{
24 Zero,
25 One,
34 };
35
36 public enum class EquationType {
37 Add,
40 Min,
41 Max,
42 };
43
44 public value struct BlendInfo
45 {
46 public:
47 bool blend;
52
54 {
55 BlendInfo r;
56 r.blend = false;
63 return r;
64 }
65
67 {
68 BlendInfo r;
69 r.blend = true;
76 return r;
77 }
78 };
79
80 public enum class CullType {
81 Back,
82 None,
83 Front,
84 Double,
85 };
86
87 public enum class PolygonMode{
88 Point,
89 Line,
90 Fill,
91 };
92
93 public ref class Framebuffer
94 {
95 public:
96 kmyGfx::Framebuffer* _obj = nullptr;
97 };
98
99 public value struct StateInfo
100 {
101 public:
111 bool depthTest;//
116
118 {
119 StateInfo r;
125 r.depthTest = true;
126 r.depthWrite = true;
127 r.stencilTest = false;
128 r.stencilRef = 0;
129 r.stencilMask = 0;
130 r.colorWriteR = true;
131 r.colorWriteG = true;
132 r.colorWriteB = true;
133 r.colorWriteA = true;
134 return r;
135 };
136 };
137
138 public ref class UniformWriter
139 {
140 public:
141 kmyGfx::Shader* shd;
142 void *ptr;
144
145 void write(String^ name, float v);
146 void write(String^ name, float x, float y);
147 void write(String^ name, float x, float y, float z);
148 void write(String^ name, float x, float y, float z, float w);
149 };
150
151 public ref class InternalCommandList
152 {
153 public:
154 kmyGfx::GameViewDrawCommand* _cmd = nullptr;
155 InternalCommandList(kmyGfx::GameViewDrawCommand* cmd) {
156 _cmd = cmd;
157 }
158 };
159
160 public ref class ICBMaterial
161 {
162 public:
163 ICBMaterial();
164 ~ICBMaterial();
165
166 void writeUniform(String^ name, float v);
167 void writeUniform(String^ name, float x, float y);
168 void writeUniform(String^ name, float x, float y, float z);
169 void writeUniform(String^ name, float x, float y, float z, float w);
170
171 Shader^ _shader = nullptr;
176 float _lineWidth = 1.0f;
177
178 char* _materialUniform = nullptr;
179 };
180
181 public ref class InternalCommandBuffer
182 {
183 public:
184 kmyGfx::GameViewDrawCommandBuffer* _obj = nullptr;
185
189 void drawVertices(PrimitiveType prim, ICBMaterial^ mtl, SharpKmyMath::Matrix4 transform, array<SharpKmyMath::Vector3>^ data);
190 void drawVertices(PrimitiveType prim, ICBMaterial^ mtl, SharpKmyMath::Matrix4 transform, array<VertexPositionColor>^ data);
191 void drawVertices(PrimitiveType prim, ICBMaterial^ mtl, SharpKmyMath::Matrix4 transform, array<VertexPositionTextureColor>^ data);
192 /*
193 void bindShader(Shader^ shader, bool skinned);
194 void setTexture(int index, Texture^ t);
195 void setTransformUniform(int materialBufferIndex, SharpKmyMath::Matrix4 mtx4);
196 void drawVertices(PrimitiveType prim, int count, int instancenum);
197 void drawVertices(VertexBuffer^ vb);
198 void drawIndices(PrimitiveType prim, u32 count, u32 offset, IndexType itype, u32 instanceNum);
199 void bindBlend(BlendInfo bi);
200 void enableBlend(bool enable);
201 void bindFramebuffer(Framebuffer^ fb);
202 void viewport(u16 x, u16 y, u16 w, u16 h);
203 void clear(bool color, bool depth, bool stencil);
204 void clearColor(float r, float g, float b, float a);
205 void bindPolygonState(CullType cull, PolygonMode polygonmode);
206 void bindState(StateInfo si);
207 void getVertexAndDraw(PrimitiveType prim, int materialBufferIndex, SharpKmyMath::Matrix4 mtx4, array<SharpKmyMath::Vector3> ^data);
208 void getVertexAndDraw(PrimitiveType prim, int materialBufferIndex, SharpKmyMath::Matrix4 mtx4, array<VertexPositionTextureColor> ^data);
209 void setLineWidth(float width);
210 UniformWriter^ getUniformWriter(Shader^ shd);
211 */
214 void copyFramebuffer(Texture^ tex, int x, int y, int w, int h);
215 void clearFramebuffer(float r, float g, float b, float a, bool color, bool depth, bool stencil);
216 };
217}
Definition: InternalCommandBuffer.h:94
kmyGfx::Framebuffer * _obj
Definition: InternalCommandBuffer.h:96
Definition: InternalCommandBuffer.h:161
StateInfo _si
Definition: InternalCommandBuffer.h:173
BlendInfo _bi
Definition: InternalCommandBuffer.h:172
PolygonMode _pm
Definition: InternalCommandBuffer.h:175
~ICBMaterial()
Definition: InternalCommandBuffer.cpp:504
Shader _shader
Definition: InternalCommandBuffer.h:171
char * _materialUniform
Definition: InternalCommandBuffer.h:178
float _lineWidth
Definition: InternalCommandBuffer.h:176
ICBMaterial()
Definition: InternalCommandBuffer.cpp:499
CullType _cull
Definition: InternalCommandBuffer.h:174
void writeUniform(String^ name, float v)
Definition: InternalCommandBuffer.cpp:509
Definition: InternalCommandBuffer.h:182
InternalCommandBuffer()
Definition: InternalCommandBuffer.cpp:16
InternalCommandList getCommandList()
Definition: InternalCommandBuffer.cpp:26
void copyFramebuffer(Texture^ tex, int x, int y, int w, int h)
Definition: InternalCommandBuffer.cpp:290
void execBuffer(InternalCommandList^ icb)
Definition: InternalCommandBuffer.cpp:31
void clearFramebuffer(float r, float g, float b, float a, bool color, bool depth, bool stencil)
Definition: InternalCommandBuffer.cpp:296
~InternalCommandBuffer()
Definition: InternalCommandBuffer.cpp:21
void drawVertices(PrimitiveType prim, ICBMaterial^ mtl, SharpKmyMath::Matrix4 transform, VertexBuffer^ vb)
Definition: InternalCommandBuffer.cpp:38
kmyGfx::GameViewDrawCommandBuffer * _obj
Definition: InternalCommandBuffer.h:184
Definition: InternalCommandBuffer.h:152
InternalCommandList(kmyGfx::GameViewDrawCommand *cmd)
Definition: InternalCommandBuffer.h:155
kmyGfx::GameViewDrawCommand * _cmd
Definition: InternalCommandBuffer.h:154
Definition: Shader.h:8
Definition: Texture.h:72
Definition: InternalCommandBuffer.h:139
void write(String^ name, float v)
///////////////////
Definition: InternalCommandBuffer.cpp:543
int materialBufferIndex
Definition: InternalCommandBuffer.h:143
kmyGfx::Shader * shd
Definition: InternalCommandBuffer.h:141
void * ptr
Definition: InternalCommandBuffer.h:142
Definition: VertexBuffer.h:11
Definition: Matrix4.h:10
Definition: Billboard.cpp:4
PrimitiveType
Definition: InternalCommandBuffer.h:8
CullType
Definition: InternalCommandBuffer.h:80
BlendFactor
Definition: InternalCommandBuffer.h:23
FUNCTYPE
Definition: DrawInfo.h:39
PolygonMode
Definition: InternalCommandBuffer.h:87
STENCILOP
Definition: DrawInfo.h:32
EquationType
Definition: InternalCommandBuffer.h:36
IndexType
Definition: InternalCommandBuffer.h:17
Definition: InternalCommandBuffer.h:45
bool blend
Definition: InternalCommandBuffer.h:47
static BlendInfo noBlend()
Definition: InternalCommandBuffer.h:53
BlendFactor dstAlpha
Definition: InternalCommandBuffer.h:50
EquationType alphaEquation
Definition: InternalCommandBuffer.h:51
BlendFactor srcAlpha
Definition: InternalCommandBuffer.h:50
BlendFactor srcColor
Definition: InternalCommandBuffer.h:48
EquationType colorEquation
Definition: InternalCommandBuffer.h:49
static BlendInfo alphaBlend()
Definition: InternalCommandBuffer.h:66
BlendFactor dstColor
Definition: InternalCommandBuffer.h:48
Definition: InternalCommandBuffer.h:100
u32 stencilMask
Definition: InternalCommandBuffer.h:115
bool stencilTest
Definition: InternalCommandBuffer.h:113
bool colorWriteG
Definition: InternalCommandBuffer.h:108
bool colorWriteA
Definition: InternalCommandBuffer.h:110
STENCILOP stencilOpDepthFail
Definition: InternalCommandBuffer.h:105
static StateInfo standard()
Definition: InternalCommandBuffer.h:117
FUNCTYPE stencilFunc
Definition: InternalCommandBuffer.h:103
FUNCTYPE depthFunc
Definition: InternalCommandBuffer.h:102
u32 stencilRef
Definition: InternalCommandBuffer.h:114
bool colorWriteB
Definition: InternalCommandBuffer.h:109
bool colorWriteR
Definition: InternalCommandBuffer.h:107
bool depthTest
Definition: InternalCommandBuffer.h:111
STENCILOP stencilOpPass
Definition: InternalCommandBuffer.h:106
STENCILOP stencilOpFail
Definition: InternalCommandBuffer.h:104
bool depthWrite
Definition: InternalCommandBuffer.h:112