Implement DrawGraph.CopyRotZoom2Bilinear

Used in Daiteikoku.

It's similar to DrawGraph.CopyRotZoom, but specifies source and
destination center points.
This commit is contained in:
kichikuou
2023-06-18 20:57:00 +09:00
parent c99e9842ad
commit e1d5eba1f2
3 changed files with 29 additions and 2 deletions
+1
View File
@@ -146,6 +146,7 @@ void gfx_copy_stretch_blend_amap_alpha(struct texture *dst, int dx, int dy, int
void gfx_copy_rot_zoom(Texture *dst, Texture *src, int sx, int sy, int w, int h, float rotate, float mag);
void gfx_copy_rot_zoom_amap(Texture *dst, Texture *src, int sx, int sy, int w, int h, float rotate, float mag);
void gfx_copy_rot_zoom_use_amap(Texture *dst, Texture *src, int sx, int sy, int w, int h, float rotate, float mag);
void gfx_copy_root_zoom2(Texture *dst, float cx, float cy, Texture *src, float scx, float scy, float rot, float mag);
void gfx_copy_reverse_LR(Texture *dst, int dx, int dy, Texture *src, int sx, int sy, int w, int h);
void gfx_copy_reverse_amap_LR(Texture *dst, int dx, int dy, Texture *src, int sx, int sy, int w, int h);
void gfx_copy_rotate_y(Texture *dst, Texture *front, Texture *back, int sx, int sy, int w, int h, float rot, float mag);
+23
View File
@@ -770,6 +770,29 @@ void gfx_copy_rot_zoom_use_amap(Texture *dst, Texture *src, int sx, int sy, int
copy_rot_zoom(dst, src, sx, sy, w, h, rotate, mag, &hitbox_shader.s);
}
void gfx_copy_root_zoom2(Texture *dst, float cx, float cy, Texture *src, float scx, float scy, float rot, float mag)
{
gfx_fill_amap(dst, 0, 0, dst->w, dst->h, 0);
// 1. scale src vertices to texture size
// 2. translate so that center point of copy region is at origin
// 3. rotate
// 4. scale
// 4. tranlate to center point of dst texture
// (applied in reverse order)
mat4 mw_transform = GLM_MAT4_IDENTITY_INIT;
glm_translate(mw_transform, (vec3){ cx, cy, 0 });
glm_scale(mw_transform, (vec3){ mag, mag, 0 });
glm_rotate_z(mw_transform, -rot * (M_PI/180.0), mw_transform);
glm_translate(mw_transform, (vec3){ -scx, -scy, 0 });
glm_scale(mw_transform, (vec3){ src->w, src->h, 1 });
mat4 wv_transform = WV_TRANSFORM(dst->w, dst->h);
struct copy_data data = ROTATE_DATA(dst, 0, 0, src->w, src->h);
run_draw_shader(&hitbox_noblend_shader.s, dst, src, mw_transform, wv_transform, &data);
}
static void copy_rotate_y(Texture *dst, Texture *front, Texture *back, int sx, int sy, int w, int h, float rot, float mag, Shader *shader)
{
Texture *src = front;
+5 -2
View File
@@ -298,7 +298,10 @@ static void DrawGraph_CopyRotZoomUseAMap(int dst, int src, int sx, int sy, int w
gfx_copy_rot_zoom_use_amap(DTEX(dst), STEX(src), sx, sy, w, h, rotate, mag);
}
//void DrawGraph_CopyRotZoom2Bilinear(int dst, float cx, float cy, int src, float scx, float scy, float rot, float mag);
static void DrawGraph_CopyRotZoom2Bilinear(int dst, float cx, float cy, int src, float scx, float scy, float rot, float mag)
{
gfx_copy_root_zoom2(DTEX(dst), cx, cy, STEX(src), scx, scy, rot, mag);
}
static void DrawGraph_CopyRotateY(int write, int dst, int src, int sx, int sy, int w, int h, float rot, float mag)
{
@@ -469,7 +472,7 @@ HLL_LIBRARY(DrawGraph,
HLL_EXPORT(CopyRotZoom, DrawGraph_CopyRotZoom),
HLL_EXPORT(CopyRotZoomAMap, DrawGraph_CopyRotZoomAMap),
HLL_EXPORT(CopyRotZoomUseAMap, DrawGraph_CopyRotZoomUseAMap),
//HLL_EXPORT(CopyRotZoom2Bilinear, DrawGraph_CopyRotZoom2Bilinear),
HLL_EXPORT(CopyRotZoom2Bilinear, DrawGraph_CopyRotZoom2Bilinear),
HLL_EXPORT(CopyRotateY, DrawGraph_CopyRotateY),
HLL_EXPORT(CopyRotateYUseAMap, DrawGraph_CopyRotateYUseAMap),
//HLL_EXPORT(CopyRotateYFixL, DrawGraph_CopyRotateYFixL),