3DS: Fix crash when pushing too many verts
Jeffrey Pfau jeffrey@endrift.com
Sun, 07 Aug 2016 10:09:18 -0700
2 files changed,
9 insertions(+),
2 deletions(-)
M
src/platform/3ds/ctr-gpu.c
→
src/platform/3ds/ctr-gpu.c
@@ -27,7 +27,7 @@ short uw, vh;
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 @@ C3D_FVUnifMtx2x4(GPU_GEOMETRY_SHADER, GSH_FVEC_textureMtx, &textureMtx);
} 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();
M
src/platform/3ds/gui-font.c
→
src/platform/3ds/gui-font.c
@@ -95,7 +95,7 @@
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);