3DS: Fix crash when pushing too many verts

This commit is contained in:
Jeffrey Pfau 2016-08-07 10:09:18 -07:00
parent f5ee8330f7
commit 0c748d3bfc
2 changed files with 9 additions and 2 deletions

View File

@ -27,7 +27,7 @@ struct ctrUIVertex {
u32 abgr;
};
#define MAX_NUM_QUADS 1024
#define MAX_NUM_QUADS 256
#define VERTEX_BUFFER_SIZE MAX_NUM_QUADS * sizeof(struct ctrUIVertex)
static struct ctrUIVertex* ctrVertexBuffer = NULL;
@ -146,6 +146,13 @@ void ctrActivateTexture(C3D_Tex* texture) {
}
void ctrAddRectScaled(u32 color, s16 x, s16 y, s16 w, s16 h, s16 u, s16 v, s16 uw, s16 vh) {
if (x >= 400 && w >= 0) {
return;
}
if (y >= 240 && h >= 0) {
return;
}
if (ctrNumVerts + ctrVertStart == MAX_NUM_QUADS) {
ctrFlushBatch();
C3D_Flush();

View File

@ -95,7 +95,7 @@ void GUIFontIconMetrics(const struct GUIFont* font, enum GUIIcon icon, unsigned*
void GUIFontDrawGlyph(const struct GUIFont* font, int glyph_x, int glyph_y, uint32_t color, uint32_t glyph) {
int index = fontGlyphIndexFromCodePoint(glyph);
fontGlyphPos_s data;
fontCalcGlyphPos(&data, index, GLYPH_POS_CALC_VTXCOORD, 1.0, 1.0);
fontCalcGlyphPos(&data, index, 0, 1.0, 1.0);
C3D_Tex* tex = &font->sheets[data.sheetIndex];
ctrActivateTexture(tex);