19 this->vertexIndex = vtxFmtIndex;
21 GX_SetVtxAttrFmt(this->vertexIndex, GX_VA_POS, GX_POS_XY, GX_S16, 0);
22 GX_SetVtxAttrFmt(this->vertexIndex, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
23 GX_SetVtxAttrFmt(this->vertexIndex, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
27 width = ALIGN8(width);
28 if (width == 0) width = 8;
30 height = ALIGN8(height);
31 if (height == 0) height = 8;
33 uint32_t glyphSize = (width * height) >> 1;
35 void* texture = memalign(32, glyphSize);
37 memset(texture, 0x00, glyphSize);
38 textureCacheStale =
true;
45 if (!texture || !bitmap)
return;
47 uint16_t texWidth = ALIGN8(bitmap->width);
48 if (texWidth == 0) texWidth = 8;
50 uint16_t texHeight = ALIGN8(bitmap->rows);
51 if (texHeight == 0) texHeight = 8;
53 uint32_t glyphSize = (texWidth * texHeight) >> 1;
55 uint8_t* dst =
static_cast<uint8_t*
>(texture);
56 uint8_t* src =
static_cast<uint8_t*
>(bitmap->buffer);
58 uint32_t srcPitch = bitmap->pitch < 0 ? -bitmap->pitch : bitmap->pitch;
59 if (srcPitch == 0) srcPitch = bitmap->width;
60 uint32_t pos, x1, y1, x, y;
63 for (y1 = 0; y1 < bitmap->rows; y1 += 8) {
64 for (x1 = 0; x1 < bitmap->width; x1 += 8) {
65 for (y = y1; y < (y1 + 8); y++) {
66 for (x = x1; x < (x1 + 8); x += 2, dst++) {
67 if (x >= bitmap->width || y >= bitmap->rows) {
71 pos = y * srcPitch + x;
74 *dst = (src[pos] & 0xF0);
75 if (x + 1 < bitmap->width) {
76 *dst |= (src[pos + 1] >> 4);
84 DCFlushRange(texture, glyphSize);
85 textureCacheStale =
true;
109 if (!texture)
return;
111 GXTexObj glyphTexture;
114 GX_InitTexObj(&glyphTexture, texture, width, height, GX_TF_I4, GX_CLAMP, GX_CLAMP, GX_FALSE);
115 GX_LoadTexObj(&glyphTexture, GX_TEXMAP0);
119 if (textureCacheStale) {
120 GX_InvalidateTexAll();
121 textureCacheStale =
false;
125 GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
126 GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
129 GX_Begin(GX_QUADS, this->vertexIndex, 4);
132 GX_Position2s16(screenX, screenY);
133 GX_Color4u8(color.r, color.g, color.b, color.a);
134 GX_TexCoord2f32(0.0f, 0.0f);
137 GX_Position2s16(width + screenX, screenY);
138 GX_Color4u8(color.r, color.g, color.b, color.a);
139 GX_TexCoord2f32(1.0f, 0.0f);
142 GX_Position2s16(width + screenX, height + screenY);
143 GX_Color4u8(color.r, color.g, color.b, color.a);
144 GX_TexCoord2f32(1.0f, 1.0f);
147 GX_Position2s16(screenX, height + screenY);
148 GX_Color4u8(color.r, color.g, color.b, color.a);
149 GX_TexCoord2f32(0.0f, 1.0f);
154 GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
155 GX_SetVtxDesc(GX_VA_TEX0, GX_NONE);
161 GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
162 GX_SetVtxDesc(GX_VA_TEX0, GX_NONE);
164 GX_Begin(GX_QUADS, this->vertexIndex, 4);
166 GX_Position2s16(screenX, screenY);
167 GX_Color4u8(color.r, color.g, color.b, color.a);
169 GX_Position2s16(width + screenX, screenY);
170 GX_Color4u8(color.r, color.g, color.b, color.a);
172 GX_Position2s16(width + screenX, height + screenY);
173 GX_Color4u8(color.r, color.g, color.b, color.a);
175 GX_Position2s16(screenX, height + screenY);
176 GX_Color4u8(color.r, color.g, color.b, color.a);
180 GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
181 GX_SetVtxDesc(GX_VA_TEX0, GX_NONE);
void drawFeature(int16_t screenX, int16_t screenY, uint16_t width, uint16_t height, const PixelColor &color) override
Draws a solid-color rectangle used for text decoration (underline/strike-through).
void drawQuad(void *texture, int16_t screenX, int16_t screenY, uint16_t width, uint16_t height, const PixelColor &color) override
Draws a glyph texture as a quad tinted with color.