Added some basic font rendering and texas holdem

This commit is contained in:
2021-05-03 21:32:40 -07:00
parent f559ff2092
commit 8546a2bcf8
35 changed files with 827 additions and 72 deletions

47
src/display/gui/font.c Normal file
View File

@ -0,0 +1,47 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "font.h"
tilesetdiv_t * fontGetCharacterDivision(tileset_t *tileset, char character) {
int32_t i = ((int32_t)character) - FONT_CHAR_START;
return tileset->divisions + i;
}
void fontSpriteBatchBuffer(spritebatch_t *batch, tileset_t *tileset,
char *string, float x, float y, float z, float charWidth, float charHeight
) {
int32_t i;
char c;
tilesetdiv_t *div;
float cx, cy;
i = 0;
cx = x, cy = y;
while(true) {
c = string[i];
if(c == '\0') break;
i++;
if(c == '\n') {
cx = x;
cy += charWidth;
continue;
} else if(c == ' ') {
cx += charHeight;
continue;
}
div = fontGetCharacterDivision(tileset, c);
spriteBatchQuad(batch, -1,
cx, cy, z, charWidth, charHeight,
div->x0, div->y0, div->x1, div->y1
);
cx += charWidth;
}
}

17
src/display/gui/font.h Normal file
View File

@ -0,0 +1,17 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include <dawn/dawn.h>
#include "../spritebatch.h"
#define FONT_CHAR_START 33
tilesetdiv_t * fontGetCharacterDivision(tileset_t *tileset, char character);
void fontSpriteBatchBuffer(spritebatch_t *batch, tileset_t *tileset,
char *string, float x, float y, float z, float charWidth, float charHeight
);