summaryrefslogtreecommitdiff
path: root/src/core/device.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/device.h')
-rw-r--r--src/core/device.h62
1 files changed, 52 insertions, 10 deletions
diff --git a/src/core/device.h b/src/core/device.h
index 6dc8143..0b27b70 100644
--- a/src/core/device.h
+++ b/src/core/device.h
@@ -34,9 +34,21 @@ typedef enum {
ENABLE_MULTISAMPLE = 1 << 2,
ENABLE_BLEND = 1 << 3,
ENABLE_WRITEDEPTH = 1 << 4,
+ ENABLE_STENCILTEST = 1 << 5,
} ssr_EnableMask;
typedef enum {
+ DEPTHFUNC_ALWAYS,
+ DEPTHFUNC_NEVER,
+ DEPTHFUNC_LESS,
+ DEPTHFUNC_EQUAL,
+ DEPTHFUNC_LEQUAL,
+ DEPTHFUNC_GREATER,
+ DEPTHFUNC_NOTEQUAL,
+ DEPTHFUNC_GEQUAL,
+} ssr_DepthFunc;
+
+typedef enum {
BLEND_ONE,
BLEND_ZERO,
BLEND_SRC_COLOR,
@@ -49,6 +61,28 @@ typedef enum {
BLEND_ONE_MINUS_DST_ALPHA,
} ssr_BlendFactor;
+typedef enum {
+ STENCILFUNC_ALWAYS,
+ STENCILFUNC_NEVER,
+ STENCILFUNC_LESS,
+ STENCILFUNC_EQUAL,
+ STENCILFUNC_LEQUAL,
+ STENCILFUNC_GREATER,
+ STENCILFUNC_NOTEQUAL,
+ STENCILFUNC_GEQUAL,
+} ssr_StencilFunc;
+
+typedef enum {
+ STENCILOP_KEEP,
+ STENCILOP_ZERO,
+ STENCILOP_REPLACE,
+ STENCILOP_INCR,
+ STENCILOP_INCR_WRAP,
+ STENCILOP_DECR,
+ STENCILOP_DECR_WRAP,
+ STENCILOP_INVERT,
+} ssr_StencilOp;
+
void ssr_init(ssr_Config* config);
float ssr_getaspect();
@@ -56,9 +90,6 @@ float ssr_getaspect();
int ssr_getframebufferw();
int ssr_getframebufferh();
-void ssr_setfiltermode(FilterMode filter_mode);
-void ssr_setwrapmode(WrapMode wrap_mode);
-
void ssr_matrixmode(ssr_MatrixMode mode);
void ssr_loadidentity();
void ssr_pushmatrix();
@@ -87,7 +118,7 @@ void ssr_disable(uint mask);
bool ssr_isenable(uint mask);
/* 绑定顶点数据 */
-void ssr_bindvertices(Vert* verts, int nverts, uint* indices, int nprims);
+void ssr_bindvertices(Vert* verts, int vert_count, uint* indices, int prim_count);
void ssr_unbindvertices();
void ssr_useprogram(Program* program);
@@ -103,8 +134,10 @@ void ssr_setuniformu(void* userdata);
void ssr_draw(ssr_PrimitiveType primitive);
void ssr_clearcolor(Color color);
void ssr_cleardepth();
+void ssr_clearstencil(byte val);
-void ssr_putpoint(uint screenx, uint screeny, Color color); /*直接修改某个位置的颜色*/
+/*put point onto screen*/
+void ssr_putpoint(uint screenx, uint screeny, Color color);
void ssr_putpoint32(uint screenx, uint screeny, Color32* c32);
void ssr_present();
@@ -113,20 +146,29 @@ Color ssr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char
bool ssr_testdepth(uint x, uint y, float depth);
void ssr_writedepth(uint x, uint y, float depth);
+void ssr_setdepthfunc(ssr_DepthFunc func);
void ssr_blend(Color32* src, Color32* dst, Color32* out);
void ssrU_viewport(Vec2* p, Vec2* out);
void ssrU_blend(ssr_BlendFactor sfactor, ssr_BlendFactor dfactor, Color32* src, Color32* dst, Color* out);
-Color32 ssr_getfbocolor(uint x, uint y);
-
-FilterMode ssr_getfiltermode();
-WrapMode ssr_getwrapmode();
-
void ssr_bindframebuffer(FrameBuffer* fbo);
void ssr_unbindframebuffer();
void ssr_setblendfunc(ssr_BlendFactor sfactor, ssr_BlendFactor dfactor);
+void ssrU_blendscreencolor(uint x, uint y, Color32* src);
+
+/*将颜色写入对应的屏幕位置*/
+void ssrU_putpointwithblend(uint x, uint y, Color32* color, bool blend);
+
+bool ssr_teststencil(uint x, uint y, bool pass_depth_test);
+void ssr_writestencil(uint x, uint y, bool pass_depth_test, bool pass_stencil_test);
+void ssr_setstencilfunc(ssr_StencilFunc func, byte ref, uint mask);
+void ssr_setstencilop(ssr_StencilOp fail, ssr_StencilOp dpfail, ssr_StencilOp pass);
+void ssr_setstencilmask(byte mask);
+bool ssr_iswritesencil();
+
+void ssr_blendandputpoint(int x, int y, bool blend);
#endif \ No newline at end of file