Even more shared pointers.

This commit is contained in:
2023-11-10 22:33:21 -06:00
parent 732a90931c
commit 085facd079
19 changed files with 89 additions and 80 deletions

View File

@ -65,9 +65,9 @@ int32_t DawnHost::init(std::shared_ptr<DawnGame> game) {
assertTrue(fbWidth > 0, "Detected framebuffer height is too small?");
assertTrue(windowWidth > 0, "Detected window width is too small?");
assertTrue(windowHeight > 0, "Detected window height is too small?");
game->renderManager.backBuffer->setSize(fbWidth, fbHeight);
game->renderManager.backBuffer->scale = ((float_t)fbWidth) / ((float_t)windowWidth);
assertTrue(game->renderManager.backBuffer->scale > 0, "Back buffer scale is invalid");
game->renderManager->backBuffer->setSize(fbWidth, fbHeight);
game->renderManager->backBuffer->scale = ((float_t)fbWidth) / ((float_t)windowWidth);
assertTrue(game->renderManager->backBuffer->scale > 0, "Back buffer scale is invalid");
assertNoGLError();
// Default keybinds
@ -184,16 +184,16 @@ void glfwOnResize(GLFWwindow *window, int32_t w, int32_t h) {
if(!host) return;
assertTrue(window == host->data->window, "glfwOnResize: Window mismatch");
auto backBuffer = ((BackBufferRenderTarget*)&host->game->renderManager.backBuffer);
assertNotNull(backBuffer, "glfwOnResize: Back buffer is not valid");
auto bb = host->game->renderManager->backBuffer;
assertNotNull(bb, "glfwOnResize: Back buffer is not valid");
int32_t windowWidth, windowHeight;
glfwGetWindowSize(window, &windowWidth, &windowHeight);
// TODO: I may throttle this, it calls for every frame the window's resized.
backBuffer->setSize((float_t)w, (float_t)h);
backBuffer->scale = ((float_t)w) / ((float_t)windowWidth);
assertTrue(backBuffer->scale > 0, "glfwOnResize: Back buffer scale is invalid");
bb->setSize((float_t)w, (float_t)h);
bb->scale = ((float_t)w) / ((float_t)windowWidth);
assertTrue(bb->scale > 0, "glfwOnResize: Back buffer scale is invalid");
}
void glfwOnKey(
@ -225,11 +225,11 @@ void glfwOnCursor(GLFWwindow* window, double xpos, double ypos) {
if(host == nullptr) return;
host->game->inputManager.rawInputValues[INPUT_MANAGER_AXIS_MOUSE_X] = mathClamp<float_t>(
(float_t)(xpos / host->game->renderManager.backBuffer->getWidth()),
(float_t)(xpos / host->game->renderManager->backBuffer->getWidth()),
0, 1
);
host->game->inputManager.rawInputValues[INPUT_MANAGER_AXIS_MOUSE_Y] = mathClamp<float_t>(
(float_t)(ypos / host->game->renderManager.backBuffer->getHeight()),
(float_t)(ypos / host->game->renderManager->backBuffer->getHeight()),
0, 1
);
}