diff --git a/include/gfx/gfx.h b/include/gfx/gfx.h index 893efd2..0ca3260 100644 --- a/include/gfx/gfx.h +++ b/include/gfx/gfx.h @@ -114,6 +114,7 @@ void gfx_blend(Texture *dst, int dx, int dy, Texture *src, int sx, int sy, int w 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_color(struct texture *dst, int dx, int dy, struct texture *src, int sx, int sy, int w, int h, int r, int g, int b); 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_blend_src_bright(Texture *dst, int dx, int dy, Texture *src, int sx, int sy, int w, int h, int a, int rate); void gfx_blend_amap_color_alpha(Texture *dst, int dx, int dy, Texture *src, int sx, int sy, int w, int h, int r, int g, int b, int a); void gfx_fill(struct texture *dst, int x, int y, int w, int h, int r, int g, int b); void gfx_fill_alpha_color(struct texture *dst, int x, int y, int w, int h, int r, int g, int b, int a); diff --git a/src/draw.c b/src/draw.c index e2760e5..805158c 100644 --- a/src/draw.c +++ b/src/draw.c @@ -347,6 +347,19 @@ void gfx_blend_amap_alpha(Texture *dst, int dx, int dy, Texture *src, int sx, in restore_blend_mode(); } +void gfx_blend_src_bright(Texture *dst, int dx, int dy, Texture *src, int sx, int sy, int w, int h, int a, int rate) +{ + GLfloat f_rate = rate / 255.0; + f_rate *= (a / 255.0); + glBlendFuncSeparate(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_ALPHA, GL_ZERO, GL_ONE); + glBlendColor(f_rate, f_rate, f_rate, a / 255.0); + + struct copy_data data = COPY_DATA(dx, dy, sx, sy, w, h); + run_copy_shader(©_shader.s, dst, src, &data); + + restore_blend_mode(); +} + void gfx_blend_amap_color_alpha(Texture *dst, int dx, int dy, Texture *src, int sx, int sy, int w, int h, int r, int g, int b, int a) { glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/src/hll/DrawGraph.c b/src/hll/DrawGraph.c index 8047333..bea93ac 100644 --- a/src/hll/DrawGraph.c +++ b/src/hll/DrawGraph.c @@ -206,7 +206,11 @@ static void DrawGraph_SetFontName(struct string *text) gfx_set_font_name(text->text); } -//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_BlendSrcBright(int dst, int dx, int dy, int src, int sx, int sy, int w, int h, int alpha, int rate) +{ + gfx_blend_src_bright(DTEX(dst), dx, dy, STEX(src), sx, sy, w, h, alpha, 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); @@ -346,7 +350,7 @@ HLL_LIBRARY(DrawGraph, HLL_EXPORT(CopyAMapMax, DrawGraph_CopyAMapMax), HLL_EXPORT(CopyAMapMin, DrawGraph_CopyAMapMin), HLL_EXPORT(Blend, DrawGraph_Blend), - //HLL_EXPORT(BlendSrcBright, DrawGraph_BlendSrcBright), + HLL_EXPORT(BlendSrcBright, DrawGraph_BlendSrcBright), //HLL_EXPORT(BlendAddSatur, DrawGraph_BlendAddSatur), HLL_EXPORT(BlendAMap, DrawGraph_BlendAMap), //HLL_EXPORT(BlendAMapSrcOnly, DrawGraph_BlendAMapSrcOnly),