Implement DrawGraph.blend

This commit is contained in:
Nunuhara Cabbage
2020-08-27 17:22:03 -07:00
parent d69bc33449
commit d9e50ab809
3 changed files with 18 additions and 2 deletions
+1
View File
@@ -103,6 +103,7 @@ void gfx_copy_use_amap_under(struct texture *dst, int dx, int dy, struct texture
void gfx_copy_use_amap_border(struct texture *dst, int dx, int dy, struct texture *src, int sx, int sy, int w, int h, int threshold);
void gfx_copy_amap_max(struct texture *dst, int dx, int dy, struct texture *src, int sx, int sy, int w, int h);
void gfx_copy_amap_min(struct texture *dst, int dx, int dy, struct texture *src, int sx, int sy, int w, int h);
void gfx_blend(Texture *dst, int dx, int dy, Texture *src, int sx, int sy, int w, int h, int a);
void gfx_blend_amap(struct texture *dst, int dx, int dy, struct texture *src, int sx, int sy, int w, int h);
void gfx_blend_amap_alpha(struct texture *dst, int dx, int dy, struct texture *src, int sx, int sy, int w, int h, int a);
void gfx_fill(struct texture *dst, int x, int y, int w, int h, int r, int g, int b);
+11
View File
@@ -250,6 +250,17 @@ void gfx_copy_amap_min(Texture *dst, int dx, int dy, Texture *src, int sx, int s
restore_blend_mode();
}
void gfx_blend(Texture *dst, int dx, int dy, Texture *src, int sx, int sy, int w, int h, int a)
{
glBlendFuncSeparate(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_ZERO, GL_ONE);
glBlendColor(0, 0, 0, a / 255.0);
struct copy_data data = COPY_DATA(dx, dy, sx, sy, w, h);
run_copy_shader(&copy_shader.s, dst, src, &data);
restore_blend_mode();
}
void gfx_blend_amap(Texture *dst, int dx, int dy, Texture *src, int sx, int sy, int w, int h)
{
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+6 -2
View File
@@ -61,6 +61,11 @@ static void DrawGraph_CopyAMapMin(int dst, int dx, int dy, int src, int sx, int
gfx_copy_amap_min(TEX(dst), dx, dy, TEX(src), sx, sy, w, h);
}
static void DrawGraph_Blend(int dst, int dx, int dy, int src, int sx, int sy, int w, int h, int alpha)
{
gfx_blend(TEX(dst), dx, dy, TEX(src), sx, sy, w, h, alpha);
}
static void DrawGraph_BlendAMap(int dst, int dx, int dy, int src, int sx, int sy, int w, int h)
{
gfx_blend_amap(TEX(dst), dx, dy, TEX(src), sx, sy, w, h);
@@ -161,7 +166,6 @@ static void DrawGraph_SetFontName(struct string *text)
}
//void DrawGraph_CopyColorReverse(int dst, int dx, int dy, int src, int sx, int sy, int w, int h);
//void DrawGraph_Blend(int dst, int dx, int dy, int src, int sx, int sy, int w, int h, int alpha);
//void DrawGraph_BlendSrcBright(int dst, int dx, int dy, int src, int sx, int sy, int w, int h, int alpha, int rate);
//void DrawGraph_BlendAddSatur(int dst, int dx, int dy, int src, int sx, int sy, int w, int h);
//void DrawGraph_BlendAMapSrcOnly(int dst, int dx, int dy, int src, int sx, int sy, int w, int h);
@@ -225,7 +229,7 @@ HLL_LIBRARY(DrawGraph,
HLL_EXPORT(CopyUseAMapBorder, DrawGraph_CopyUseAMapBorder),
HLL_EXPORT(CopyAMapMax, DrawGraph_CopyAMapMax),
HLL_EXPORT(CopyAMapMin, DrawGraph_CopyAMapMin),
//HLL_EXPORT(Blend, DrawGraph_Blend),
HLL_EXPORT(Blend, DrawGraph_Blend),
//HLL_EXPORT(BlendSrcBright, DrawGraph_BlendSrcBright),
//HLL_EXPORT(BlendAddSatur, DrawGraph_BlendAddSatur),
HLL_EXPORT(BlendAMap, DrawGraph_BlendAMap),