Implement DrawGraph.DrawTextToPMap & others

DrawGraph.GetPixelColor
DrawGraph.GetAlphaColor
SACT2.SP_GetAMapValue
SACT2.SP_GetPixelValue
This commit is contained in:
Nunuhara Cabbage
2019-12-21 07:06:52 -08:00
parent 6bef461a5d
commit dd77689199
6 changed files with 46 additions and 5 deletions
+1
View File
@@ -171,5 +171,6 @@ SDL_Color gfx_get_font_color(void);
int gfx_render_text(Texture *dst, Point pos, char *msg, struct text_metrics *tm);
void gfx_draw_text_to_amap(Texture *dst, int x, int y, char *text);
void gfx_draw_text_to_pmap(Texture *dst, int x, int y, char *text);
#endif /* SYSTEM4_SDL_CORE_H */
+3 -3
View File
@@ -117,7 +117,7 @@ hll_defun_inline(CopyReduce, (gfx_copy_stretch(TEX(a[0].i), a[1].i, a[2].i, a[3]
//void CopyReduceAMap(int nDest, int nDx, int nDy, int nDWidth, int nDHeight, int nSrc, int nSx, int nSy, int nSWidth, int nSHeight)
hll_defun_inline(CopyReduceAMap, (gfx_copy_stretch_amap(TEX(a[0].i), a[1].i, a[2].i, a[3].i, a[4].i, TEX(a[5].i), a[6].i, a[7].i, a[8].i, a[9].i), 0));
//void DrawTextToPMap(int nDest, int nX, int nY, string szText)
hll_unimplemented(DrawGraph, DrawTextToPMap);
hll_defun_inline(DrawTextToPMap, (gfx_draw_text_to_pmap(TEX(a[0].i), a[1].i, a[2].i, hll_string_ref(a[3].i)->text), 0));
//void DrawTextToAMap(int nDest, int nX, int nY, string szText)
hll_defun_inline(DrawTextToAMap, (gfx_draw_text_to_amap(TEX(a[0].i), a[1].i, a[2].i, hll_string_ref(a[3].i)->text), 0));
//void SetFontSize(int nSize)
@@ -210,9 +210,9 @@ hll_unimplemented(DrawGraph, DrawLine);
//void DrawLineToAMap(int nDest, int nX0, int nY0, int nX1, int nY1, int nAlpha)
hll_unimplemented(DrawGraph, DrawLineToAMap);
//bool GetPixelColor(int nSurface, int nX, int nY, ref int nR, ref int nG, ref int nB)
hll_unimplemented(DrawGraph, GetPixelColor);
hll_defun_inline(GetPixelColor, sact_SP_GetPixelValue(a[0].i, a[1].i, a[2].i, a[3].iref, a[4].iref, a[5].iref));
//bool GetAlphaColor(int nSurface, int nX, int nY, ref int nA)
hll_unimplemented(DrawGraph, GetAlphaColor);
hll_defun_inline(GetAlphaColor, (*a[3].iref = sact_SP_GetAMapValue(a[0].i, a[1].i, a[2].i), 1));
//void DrawPolygon(int nDest, int nTex, float fX0, float fY0, float fZ0, float fU0, float fV0, float fX1, float fY1, float fZ1, float fU1, float fV1, float fX2, float fY2, float fZ2, float fU2, float fV2)
hll_unimplemented(DrawGraph, DrawPolygon);
//void DrawColorPolygon(int nDest, float fX0, float fY0, float fZ0, int nR0, int nG0, int nB0, int nA0, float fX1, float fY1, float fZ1, int nR1, int nG1, int nB1, int nA1, float fX2, float fY2, float fZ2, int nR2, int nG2, int nB2, int nA2)
+2 -2
View File
@@ -520,9 +520,9 @@ hll_unimplemented(SACT2, Debug_Pause);
// void Debug_GetFuncStack(ref string sz, int nNest)
hll_unimplemented(SACT2, Debug_GetFuncStack);
// int SP_GetAMapValue(int nSP, int nX, int nY)
hll_unimplemented(SACT2, SP_GetAMapValue);
hll_defun_inline(SP_GetAMapValue, sact_SP_GetAMapValue(a[0].i, a[1].i, a[2].i));
// bool SP_GetPixelValue(int nSP, int nX, int nY, ref int pnR, ref int pnG, ref int pnB)
hll_unimplemented(SACT2, SP_GetPixelValue);
hll_defun_inline(SP_GetPixelValue, sact_SP_GetPixelValue(a[0].i, a[1].i, a[2].i, a[3].iref, a[4].iref, a[5].iref));
// int SP_SetBrightness(int nSP, int nBrightness)
hll_unimplemented(SACT2, SP_SetBrightness);
// int SP_GetBrightness(int nSP)
+2
View File
@@ -70,5 +70,7 @@ int sact_SP_TextClear(int sp_no);
int sact_SP_TextCopy(int dno, int sno);
int sact_SP_IsPtIn(int sp_no, int x, int y);
int sact_CG_GetMetrics(int cg_no, union vm_value *cgm);
int sact_SP_GetAMapValue(int sp_no, int x, int y);
int sact_SP_GetPixelValue(int sp_no, int x, int y, int *r, int *g, int *b);
#endif /* SYSTEM4_SACT_H */
+17
View File
@@ -517,3 +517,20 @@ int sact_CG_GetMetrics(int cg_no, union vm_value *cgm)
cgm[6].i = metrics.alpha_pitch;
return 1;
}
int sact_SP_GetAMapValue(int sp_no, int x, int y)
{
Texture *t = sact_get_texture(sp_no);
SDL_Color c = gfx_get_pixel(t, x, y);
return c.a;
}
int sact_SP_GetPixelValue(int sp_no, int x, int y, int *r, int *g, int *b)
{
Texture *t = sact_get_texture(sp_no);
SDL_Color c = gfx_get_pixel(t, x, y);
*r = c.r;
*g = c.g;
*b = c.b;
return 1;
}
+21
View File
@@ -337,6 +337,27 @@ void gfx_draw_text_to_amap(Texture *dst, int x, int y, char *text)
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
}
void gfx_draw_text_to_pmap(Texture *dst, int x, int y, char *text)
{
if (!font)
return;
set_font_style(get_font_style());
char *conv = sjis2utf(text, strlen(text));
Point pos = { x, y };
//glBlendFuncSeparate(GL_ZERO, GL_ONE, GL_ONE, GL_ZERO);
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE);
Texture glyph;
get_glyph(font->font, &glyph, conv, font_metrics.color);
render_glyph(dst, &glyph, pos);
gfx_delete_texture(&glyph);
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
}
void gfx_font_init(void)
{
if (TTF_Init() == -1)