+void GUI::DrawCharacter(SDL_Renderer * renderer, int x, int y, uint8_t c, bool invert/*= false*/)
+{
+ uint32_t inv = (invert ? 0x000000FF : 0x00000000);
+ uint32_t pixel = 0xFFFFC000; // RRGGBBAA
+ uint8_t * ptr = (uint8_t *)&font10pt[(c - 0x20) * FONT_WIDTH * FONT_HEIGHT];
+ SDL_Rect dst;
+ dst.x = x * FONT_WIDTH, dst.y = y * FONT_HEIGHT, dst.w = FONT_WIDTH, dst.h = FONT_HEIGHT;
+
+ for(int i=0; i<FONT_WIDTH*FONT_HEIGHT; i++)
+ stamp[i] = (pixel | ptr[i]) ^ inv;
+
+ SDL_UpdateTexture(charStamp, NULL, stamp, FONT_WIDTH * sizeof(Uint32));
+ SDL_RenderCopy(renderer, charStamp, NULL, &dst);
+}
+
+
+//
+// N.B.: This draws a char at an abosulte X/Y position, not on a grid
+//
+void GUI::DrawCharacterVert(SDL_Renderer * renderer, int x, int y, uint8_t c, bool invert/*= false*/)
+{
+ uint32_t inv = (invert ? 0x000000FF : 0x00000000);
+ uint32_t pixel = 0xFFFFC000; // RRGGBBAA
+ uint8_t * ptr = (uint8_t *)&font10pt[(c - 0x20) * FONT_WIDTH * FONT_HEIGHT];
+ SDL_Rect dst;
+ dst.x = x, dst.y = y, dst.w = FONT_WIDTH, dst.h = FONT_HEIGHT;
+ SDL_Point pt = { FONT_WIDTH - 1, FONT_HEIGHT - 1 };
+
+ for(int i=0; i<FONT_WIDTH*FONT_HEIGHT; i++)
+ stamp[i] = (pixel | ptr[i]) ^ inv;
+
+ SDL_SetTextureBlendMode(charStamp, SDL_BLENDMODE_NONE);
+ SDL_UpdateTexture(charStamp, NULL, stamp, FONT_WIDTH * sizeof(Uint32));
+ SDL_RenderCopyEx(renderer, charStamp, NULL, &dst, 270.0, &pt, SDL_FLIP_NONE);
+ SDL_SetTextureBlendMode(charStamp, SDL_BLENDMODE_BLEND);
+}
+
+
+void GUI::DrawString(SDL_Renderer * renderer, int x, int y, const char * s, bool invert/*= false*/)
+{
+ int len = strlen(s);
+
+ for(int i=0; i<len; i++)
+ DrawCharacter(renderer, x + i, y, s[i], invert);
+}
+
+
+//
+// N.B.: This draws a char at an abosulte X/Y position, not on a grid
+//
+void GUI::DrawStringVert(SDL_Renderer * renderer, int x, int y, const char * s, bool invert/*= false*/)
+{
+ int len = strlen(s);
+
+ for(int i=0; i<len; i++)
+ DrawCharacterVert(renderer, x, y - (FONT_WIDTH * i), s[i], invert);
+}
+
+
+void GUI::DrawBox(SDL_Renderer * renderer, int x, int y, int w, int h, int r/*= 0x00*/, int g/*= 0xAA*/, int b/*= 0x00*/)
+{
+ SDL_SetRenderDrawColor(renderer, r, g, b, 0xFF);
+
+ for(int i=0; i<w; i++)
+ {
+ SDL_RenderDrawPoint(renderer, x + i, y);
+ SDL_RenderDrawPoint(renderer, x + i, y + h - 1);
+ }
+
+ for(int i=0; i<h; i++)
+ {
+ SDL_RenderDrawPoint(renderer, x, y + i);
+ SDL_RenderDrawPoint(renderer, x + w - 1, y + i);
+ }
+
+ SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0x00);
+}
+
+