[nostalgia/core] Add support for getting screen dimensions

This commit is contained in:
Gary Talent 2021-03-17 21:28:06 -05:00
parent 245424cfad
commit 4796c2e0cb
3 changed files with 42 additions and 1 deletions

View File

@ -101,6 +101,18 @@ ox::Error shutdownGfx(Context*) {
return OxError(0);
}
int getScreenWidth(Context*) {
return 240;
}
int getScreenHeight(Context*) {
return 160;
}
common::Point getScreenSize(Context*) {
return {240, 160};
}
[[nodiscard]] constexpr volatile uint32_t &bgCtl(int bg) noexcept {
switch (bg) {
case 0:

View File

@ -9,6 +9,7 @@
#pragma once
#include <ox/std/types.hpp>
#include <nostalgia/common/point.hpp>
#include "context.hpp"
@ -80,7 +81,13 @@ struct Sprite {
ox::Error initGfx(Context *ctx);
ox::Error shutdownGfx(Context*);
ox::Error shutdownGfx(Context *ctx);
int getScreenWidth(Context *ctx);
int getScreenHeight(Context *ctx);
common::Point getScreenSize(Context *ctx);
ox::Error initConsole(Context *ctx);

View File

@ -6,6 +6,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "nostalgia/common/point.hpp"
#include <array>
#ifdef NOST_FPS_PRINT
#include <iostream>
@ -57,4 +58,25 @@ ox::Error shutdownGfx(Context *ctx) {
return OxError(0);
}
int getScreenWidth(Context *ctx) {
auto id = ctx->windowerData<SdlImplData>();
int x = 0, y = 0;
SDL_GetWindowSize(id->window, &x, &y);
return x;
}
int getScreenHeight(Context *ctx) {
auto id = ctx->windowerData<SdlImplData>();
int x = 0, y = 0;
SDL_GetWindowSize(id->window, &x, &y);
return y;
}
common::Point getScreenSize(Context *ctx) {
auto id = ctx->windowerData<SdlImplData>();
int x = 0, y = 0;
SDL_GetWindowSize(id->window, &x, &y);
return {x, y};
}
}