Don't render a textSurface again if nothing has changed.
This commit is contained in:
parent
39ca89d91c
commit
9e4ae7e3bd
|
@ -659,6 +659,15 @@ class Graphics {
|
||||||
|
|
||||||
void textSurface(int index, const char *inString, int x, int y, int fontColor)
|
void textSurface(int index, const char *inString, int x, int y, int fontColor)
|
||||||
{
|
{
|
||||||
|
/* Shortcut: if we already rendered the same string in the same color, don't render it again. */
|
||||||
|
if(textShape[index].text && textShape[index].image && textShape[index].fontColor == fontColor && !strcmp(textShape[index].text, inString)) {
|
||||||
|
textShape[index].x = x;
|
||||||
|
textShape[index].y = y;
|
||||||
|
if (x == -1)
|
||||||
|
textShape[index].x = (800 - textShape[index].image->w) / 2;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
strcpy(textShape[index].text, inString);
|
strcpy(textShape[index].text, inString);
|
||||||
textShape[index].x = x;
|
textShape[index].x = x;
|
||||||
textShape[index].y = y;
|
textShape[index].y = y;
|
||||||
|
|
Loading…
Reference in New Issue