Added True Type fonts

This commit is contained in:
2021-05-23 10:53:00 -07:00
parent 98814982de
commit b0dce455f0
26 changed files with 575 additions and 167 deletions

View File

@ -7,6 +7,12 @@
#include "game.h"
font_t font;
primitive_t quad;
texture_t mom;
primitive_t cube;
bool gameInit(game_t *game) {
// Init the game
game->name = GAME_NAME;
@ -17,6 +23,17 @@ bool gameInit(game_t *game) {
// Hand off to the poker logic.
pokerInit(&game->poker);
assetFontLoad(&font, "fonts/opensans/OpenSans-Bold.ttf", 64.0);
char *text = "Ayy\nNice meme";
fonttextinfo_t info = fontGetTextInfo(&font, text);
fontmeasure_t *measure = fontTextMeasure(&font, text, &info);
fontTextInitFromMeasure(&font, &quad, text, &info, measure);
fontTextMeasureDispose(measure);
quadInit(&cube, 0, 0,0,0,0, 923,576,1,1);
assetTextureLoad(&mom, "cards_normal.png");
return true;
}
@ -25,7 +42,32 @@ bool gameUpdate(game_t *game, float platformDelta) {
engineUpdateStart(&game->engine, game, platformDelta);
// Hand off to the poker logic
pokerUpdate(&game->poker, &game->engine.render);
shaderUse(&game->poker.shader);
// cameraPerspective(&game->poker.camera, 45,
// game->engine.render.width/game->engine.render.height,
// 0.01, 1000
// );
// cameraLookAt(&game->poker.camera, 300,300,300, 0,0,0);
cameraOrtho(&game->poker.camera,
0, game->engine.render.width,
game->engine.render.height, 0,
0.1, 1000
);
cameraLookAt(&game->poker.camera, 0,0,5, 0,0,-5);
shaderUseCamera(&game->poker.shader, &game->poker.camera);
shaderUseTexture(&game->poker.shader, &font.texture);
shaderUsePosition(&game->poker.shader, 0,0,0, 0,0,0);
primitiveDraw(&quad, 0, -1);
// shaderUseTexture(&game->poker.shader, &mom);
// shaderUsePosition(&game->poker.shader, 0,0,0, 0,0,0);
// primitiveDraw(&cube, 0, -1);
// pokerUpdate(&game->poker, &game->engine.render);
// Hand back to the engine.
return engineUpdateEnd(&game->engine, game);

View File

@ -8,6 +8,12 @@
#include "../engine/engine.h"
#include "../poker/poker.h"
#include "../display/camera.h"
#include "../display/shader.h"
#include "../display/gui/font.h"
#include "../display/primitives/quad.h"
#include "../display/primitives/cube.h"
/**
* Initialize the game context.
*