test
This commit is contained in:
@@ -60,8 +60,18 @@ namespace Game::Renderer {
|
||||
Object::Camera::getInstance().getPosition(camX, camY);
|
||||
int screenW, screenH;
|
||||
SDL_GetWindowSizeInPixels(Window::Window::getSDLWindowBackend(), &screenW, &screenH);
|
||||
// Pass the config to avoid wasting time recalculating it for every entity, since it's not gonna change during the frame
|
||||
RendererConfig config{ camX, camY, screenW, screenH };
|
||||
|
||||
// Logical game world is 1280x720; scale rendering if fullscreen is at different resolution
|
||||
static constexpr int LOGICAL_WIDTH = 1280;
|
||||
static constexpr int LOGICAL_HEIGHT = 720;
|
||||
const float scaleX = static_cast<float>(screenW) / LOGICAL_WIDTH;
|
||||
const float scaleY = static_cast<float>(screenH) / LOGICAL_HEIGHT;
|
||||
|
||||
// Apply SDL render scale to handle fullscreen scaling
|
||||
SDL_SetRenderScale(mRenderer, scaleX, scaleY);
|
||||
|
||||
// Pass the config WITHOUT scaling factors (SDL handles it now)
|
||||
RendererConfig config{ camX, camY, LOGICAL_WIDTH, LOGICAL_HEIGHT, 1.0f, 1.0f };
|
||||
|
||||
try {
|
||||
Game::State::GameState::getInstance().withEntitiesLocked([&](auto& entities) {
|
||||
@@ -89,6 +99,9 @@ namespace Game::Renderer {
|
||||
}
|
||||
|
||||
mPresent();
|
||||
|
||||
// Reset render scale for next frame
|
||||
SDL_SetRenderScale(mRenderer, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
void Renderer::mClear() {
|
||||
|
||||
Reference in New Issue
Block a user