From 252bd10fa4c9b07a2af10db954dc6389eb365939 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 27 Mar 2026 20:31:39 -0700
Subject: [PATCH] Removed zooming in on the ship in zoom mode
It turns out this was too complicated to manage visually, and with the controls out of the way it's pretty easy to see the action.
---
game/game.cpp | 138 ++------------------------------------------------
game/game.h | 2 -
2 files changed, 3 insertions(+), 137 deletions(-)
diff --git a/game/game.cpp b/game/game.cpp
index b7e6d4c9..71b7dfda 100644
--- a/game/game.cpp
+++ b/game/game.cpp
@@ -595,28 +595,8 @@ GamePanelDelegate::UpdateZoom()
SDL_GetRenderSafeArea(renderer, &rect);
SDL_SetRenderLogicalPresentation(renderer, saved_w, saved_h, saved_mode);
- // We can zoom if we're on a phone in landscape mode and not local multiplayer
- bool zoom = false;
-
+ // We can zoom if we're on a phone in landscape mode
if ((SDL_IsPhone() || SteamStreamingToPhone()) && rect.w > rect.h) {
- int i;
-
- int local_players = 0;
- OBJ_LOOP(i, MAX_PLAYERS) {
- if (!gPlayers[i]->IsValid()) {
- continue;
- }
-
- if (IS_LOCAL_CONTROL(gPlayers[i]->GetControlType())) {
- ++local_players;
- }
- }
- if (local_players == 1) {
- zoom = true;
- }
- }
-
- if (zoom) {
StartZoom(rect);
} else {
StopZoom();
@@ -626,7 +606,6 @@ GamePanelDelegate::UpdateZoom()
void
GamePanelDelegate::StartZoom(const SDL_Rect &rect)
{
- SDL_Renderer *renderer = screen->GetRenderer();
float scale = (float)GAME_WIDTH / rect.w;
int x = (int)SDL_round(rect.x * scale);
int y = (int)SDL_round(rect.y * scale);
@@ -634,10 +613,6 @@ GamePanelDelegate::StartZoom(const SDL_Rect &rect)
ui->SetPosition(x, y);
ui->SetSize(GAME_WIDTH, height);
- if (!m_texture) {
- m_texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_UNKNOWN, SDL_TEXTUREACCESS_TARGET, GAME_WIDTH, GAME_HEIGHT);
- }
-
m_zoom = true;
}
@@ -647,117 +622,19 @@ GamePanelDelegate::StopZoom()
ui->SetPosition(0, 0);
ui->SetSize(GAME_WIDTH, GAME_HEIGHT);
- if (m_texture) {
- SDL_DestroyTexture(m_texture);
- m_texture = nullptr;
- }
-
m_zoom = false;
}
void
GamePanelDelegate::StartZoomedDrawing()
{
- SDL_Renderer *renderer = screen->GetRenderer();
-
- // Don't clip the top and bottom
- screen->GetClip(&m_savedClip);
- SDL_Rect clip = m_savedClip;
- clip.y = 0;
- clip.h = GAME_HEIGHT;
- screen->ClipBlit(&clip);
-
- SDL_SetRenderTarget(renderer, m_texture);
- screen->Clear();
+ screen->SetLogicalSize(GAME_WIDTH, GAME_HEIGHT);
}
void
GamePanelDelegate::StopZoomedDrawing()
{
- SDL_Renderer *renderer = screen->GetRenderer();
-
- SDL_SetRenderTarget(renderer, nullptr);
- SDL_SetRenderLogicalPresentation(renderer, 0, 0, SDL_LOGICAL_PRESENTATION_DISABLED);
-
- int w = 0, h = 0;
- SDL_GetRenderOutputSize(renderer, &w, &h);
-
- int playerX, playerY;
- gPlayers[0]->GetPos(&playerX, &playerY);
- GetRenderCoordinates(playerX, playerY);
- playerX += (32 / 2);
- playerY += (32 / 2);
-
- float scale = (float)GAME_WIDTH / w;
- SDL_Rect src;
- src.w = GAME_WIDTH;
- src.h = (int)SDL_roundf(h * scale);
- src.x = 0;
- src.y = playerY - src.h / 2;
- float minu = (float)src.x / m_texture->w;
- float minv = (float)src.y / m_texture->h;
- float maxu = (float)(src.x + src.w) / m_texture->w;
- float maxv = (float)(src.y + src.h) / m_texture->h;
-
- SDL_FRect dst;
- dst.x = 0.0f;
- dst.y = 0.0f;
- dst.w = (float)w;
- dst.h = (float)h;
-
- SDL_FColor color = { 1.0f, 1.0f, 1.0f, 1.0f };
- SDL_Vertex verts[6];
- SDL_Vertex *vert = verts;
- /* 0 */
- vert->position.x = dst.x;
- vert->position.y = dst.y;
- vert->color = color;
- vert->tex_coord.x = minu;
- vert->tex_coord.y = minv;
- vert++;
- /* 1 */
- vert->position.x = dst.x + dst.w;
- vert->position.y = dst.y;
- vert->color = color;
- vert->tex_coord.x = maxu;
- vert->tex_coord.y = minv;
- vert++;
- /* 2 */
- vert->position.x = dst.x + dst.w;
- vert->position.y = dst.y + dst.h;
- vert->color = color;
- vert->tex_coord.x = maxu;
- vert->tex_coord.y = maxv;
- vert++;
- /* 0 */
- vert->position.x = dst.x;
- vert->position.y = dst.y;
- vert->color = color;
- vert->tex_coord.x = minu;
- vert->tex_coord.y = minv;
- vert++;
- /* 2 */
- vert->position.x = dst.x + dst.w;
- vert->position.y = dst.y + dst.h;
- vert->color = color;
- vert->tex_coord.x = maxu;
- vert->tex_coord.y = maxv;
- vert++;
- /* 3 */
- vert->position.x = dst.x;
- vert->position.y = dst.y + dst.h;
- vert->color = color;
- vert->tex_coord.x = minu;
- vert->tex_coord.y = maxv;
- vert++;
-
- SDL_SetRenderTextureAddressMode(renderer, SDL_TEXTURE_ADDRESS_WRAP, SDL_TEXTURE_ADDRESS_WRAP);
- SDL_RenderGeometry(renderer, m_texture, verts, 6, NULL, 0);
- SDL_SetRenderTextureAddressMode(renderer, SDL_TEXTURE_ADDRESS_AUTO, SDL_TEXTURE_ADDRESS_AUTO);
-
- SDL_SetRenderLogicalPresentation(renderer, ui->X() + ui->Width() + ui->X(), ui->Y() + ui->Height() + ui->Y(), SDL_LOGICAL_PRESENTATION_LETTERBOX);
-
- screen->ClipBlit(&m_savedClip);
+ screen->SetLogicalSize(ui->X() + ui->Width() + ui->X(), ui->Y() + ui->Height() + ui->Y());
}
/* ----------------------------------------------------------------- */
@@ -1459,13 +1336,4 @@ void RenderSprite(UITexture *sprite, int x, int y, int w, int h)
w = (int)(((float)w * gScrnRect.w) / GAME_WIDTH);
h = (int)(((float)h * gScrnRect.h) / GAME_HEIGHT);
screen->QueueBlit(sprite->Texture(), x, y, w, h, DOCLIP);
-
- // Render the other side of the sprite
- if (y < 0) {
- y += GAME_HEIGHT;
- screen->QueueBlit(sprite->Texture(), x, y, w, h, DOCLIP);
- } else if ((y + h) > GAME_HEIGHT) {
- y -= GAME_HEIGHT;
- screen->QueueBlit(sprite->Texture(), x, y, w, h, DOCLIP);
- }
}
diff --git a/game/game.h b/game/game.h
index 6c2aea98..a7d447fa 100644
--- a/game/game.h
+++ b/game/game.h
@@ -103,8 +103,6 @@ class GamePanelDelegate : public UIPanelDelegate
} m_state;
bool m_zoom;
- SDL_Texture *m_texture = nullptr;
- SDL_Rect m_savedClip;
};
/* ----------------------------------------------------------------- */