git repos / saland

commit 425db249

Poul Sander · 2025-11-23 12:31
425db24905f886d6aa64b1dc32756d771ec0ebc8 patch · browse files
parent 2e368f0844c45eeb090495ab537f6e0c82772fb6

Add black bars around the rendred area to prevent popping near the borders in wierd resolutions.

Changed files

M src/saland/Game.cpp before
diff --git a/src/saland/Game.cpp b/src/saland/Game.cpp index 3809ec8..70e75ef 100644 --- a/src/saland/Game.cpp +++ b/src/saland/Game.cpp
@@ -442,6 +442,32 @@ void Game::Draw(SDL_Renderer* target) {
if (data->debugMenuActive) {
DrawDebugMenu(target);
}
+ // Draw black bars where globalData.logicalResize suggests that the physical area ends.
+ // This covers the letterboxing/pillarboxing margins to ensure only the game area is visible.
+ int topMargin = globalData.logicalResize.GetTopMargin();
+ int leftMargin = globalData.logicalResize.GetLeftMargin();
+
+ // Top bar
+ if (topMargin > 0) {
+ SDL_Rect topBar = {0, 0, globalData.xsize, topMargin};
+ SDL_SetRenderDrawColor(target, 0, 0, 0, 255);
+ SDL_RenderFillRect(target, &topBar);
+ // Bottom bar
+ SDL_Rect bottomBar = {0, globalData.ysize - topMargin, globalData.xsize, topMargin};
+ SDL_SetRenderDrawColor(target, 0, 0, 0, 255);
+ SDL_RenderFillRect(target, &bottomBar);
+ }
+
+ // Left bar
+ if (leftMargin > 0) {
+ SDL_Rect leftBar = {0, 0, leftMargin, globalData.ysize};
+ SDL_SetRenderDrawColor(target, 0, 0, 0, 255);
+ SDL_RenderFillRect(target, &leftBar);
+ // Right bar
+ SDL_Rect rightBar = {globalData.xsize - leftMargin, 0, leftMargin, globalData.ysize};
+ SDL_SetRenderDrawColor(target, 0, 0, 0, 255);
+ SDL_RenderFillRect(target, &rightBar);
+ }
//#if DEBUG
static unsigned long int Frames;
static unsigned long int Ticks;