Dawn/src/poker/render/frame.c

51 lines
1.5 KiB
C

/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "frame.h"
primitive_t bruh;
void pokerFrameInit(poker_t *poker, render_t *render) {
frameBufferInit(&poker->frameWorld, render->width, render->height);
frameBufferInit(&poker->frameGui, render->width, render->height);
fonttextinfo_t *info;
char *text = "Hello world how are you today? I'm doing fine myself.";
info = fontTextClamp(&poker->font, text, 16, 500);
fontTextInit(&poker->font, &bruh, info);
}
void pokerFrameWorld(poker_t *poker, render_t *render) {
// Update the frame buffer
frameBufferResize(&poker->frameWorld, render->width, render->height);
// Correct the aspect on the perspective camera for the world
cameraPerspective(&poker->cameraWorld, 20,
render->width / render->height,
0.001, 1000
);
shaderUseCamera(&poker->shader, &poker->cameraWorld);
}
void pokerFrameGui(poker_t *poker, render_t *render) {
// Update FB
frameBufferResize(&poker->frameGui, render->width, render->height);
// frameBufferUse(&poker->frameGui, true);
// Correct aspect on the ortho camera
cameraOrtho(&poker->cameraGui,
0, render->width,
render->height, 0,
0.01, 100
);
cameraLookAt(&poker->cameraGui, 0, 0, 5, 0, 0, 0);
shaderUseCamera(&poker->shader, &poker->cameraGui);
shaderUsePosition(&poker->shader, 0,0,0, 0,0,0);
shaderUseTexture(&poker->shader, &poker->font.texture);
primitiveDraw(&bruh, 0, -1);
}