Maelstrom: Fixed Visual Studio cast warnings

From 10943eeea0774ce4c75e53a2819852fc41abb595 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 27 Nov 2025 09:27:50 -0800
Subject: [PATCH] Fixed Visual Studio cast warnings

---
 game/MaelstromUI.cpp              |   4 +-
 game/Maelstrom_Globals.h          |   2 +-
 game/continue.cpp                 |   5 +-
 game/continue.h                   |   2 +-
 game/controls.h                   |   2 +-
 game/gameinfo.cpp                 |   4 +-
 game/gameover.cpp                 |   2 +-
 game/gameover.h                   |   2 +-
 game/init.cpp                     |   2 +-
 game/lobby.cpp                    |   2 +-
 game/lobby.h                      |   4 +-
 game/main.cpp                     |   2 +-
 game/netplay.cpp                  |  10 +--
 game/packet.h                     |   6 +-
 game/player.cpp                   |   2 +-
 maclib/Mac_FontServ.cpp           |   4 +-
 screenlib/SDL_FrameBuf.cpp        | 114 ++++++++++++++++--------------
 screenlib/SDL_FrameBuf.h          |  80 ++++++++++-----------
 screenlib/UIElement.cpp           |   8 +--
 screenlib/UIElementEditbox.cpp    |   2 +-
 screenlib/UIElementThumbstick.cpp |   2 +-
 21 files changed, 128 insertions(+), 133 deletions(-)

diff --git a/game/MaelstromUI.cpp b/game/MaelstromUI.cpp
index 363183ce..ddeb9203 100644
--- a/game/MaelstromUI.cpp
+++ b/game/MaelstromUI.cpp
@@ -235,7 +235,7 @@ MFont *
 MaelstromUI::GetFont(const char *fontName, int fontSize)
 {
 	char *key;
-	int keysize;
+	size_t keysize;
 	MFont *font;
 
 	keysize = strlen(fontName)+1+2+1;
@@ -262,7 +262,7 @@ MaelstromUI::CreateText(const char *text, const char *fontName, int fontSize, UI
 	MFont *font;
 	Uint8 style;
 	char *key;
-	int keysize;
+	size_t keysize;
 	SDL_Texture *texture;
 
 	/* First see if we can find it in our cache */
diff --git a/game/Maelstrom_Globals.h b/game/Maelstrom_Globals.h
index 559a481a..1dad8efb 100644
--- a/game/Maelstrom_Globals.h
+++ b/game/Maelstrom_Globals.h
@@ -141,7 +141,7 @@ extern Scores	hScores[NUM_SCORES];
 // in game.cpp : 
 extern GameInfo gGameInfo;
 // in init.cpp : 
-extern Uint32	gLastDrawn;
+extern Uint64	gLastDrawn;
 extern int	gNumSprites;
 
 // UI panel definitions...
diff --git a/game/continue.cpp b/game/continue.cpp
index 4f8a05f7..414987ad 100644
--- a/game/continue.cpp
+++ b/game/continue.cpp
@@ -33,9 +33,6 @@ void ContinuePanelDelegate::OnShow()
 {
 	m_timeoutLabel = m_panel->GetElement<UIElement>("timeout");
 	m_showTime = SDL_GetTicks();
-	if (!m_showTime) {
-		m_showTime = 1;
-	}
 	screen->ShowCursor();
 	gGameInfo.SetLocalState(STATE_DIALOG, true);
 }
@@ -57,7 +54,7 @@ void ContinuePanelDelegate::OnTick()
 		return;
 	}
 
-	int remaining = CONTINUE_TIME - (SDL_GetTicks() - m_showTime) / 1000;
+	int remaining = CONTINUE_TIME - (int)((SDL_GetTicks() - m_showTime) / 1000);
 	if (remaining <= 0) {
 		ui->HidePanel(m_panel);
 		return;
diff --git a/game/continue.h b/game/continue.h
index bae253f5..94453b37 100644
--- a/game/continue.h
+++ b/game/continue.h
@@ -37,7 +37,7 @@ class ContinuePanelDelegate : public UIDialogDelegate
 
 protected:
 	UIElement *m_timeoutLabel;
-	Uint32 m_showTime;
+	Uint64 m_showTime;
 };
 
 #endif // _continue_h
diff --git a/game/controls.h b/game/controls.h
index 7ab35e0e..8988193c 100644
--- a/game/controls.h
+++ b/game/controls.h
@@ -108,7 +108,7 @@ class ControlsDialogDelegate : public UIDialogDelegate
 	Controls m_controls;
 	UIElement *m_controlKeys[NUM_CTLS];
 	UIElementRadioGroup *m_radioGroup;
-	Uint32 m_keyinuseTimers[NUM_CTLS];
+	Uint64 m_keyinuseTimers[NUM_CTLS];
 };
 
 #endif /* _controls_h */
diff --git a/game/gameinfo.cpp b/game/gameinfo.cpp
index 47128cfa..9376be9a 100644
--- a/game/gameinfo.cpp
+++ b/game/gameinfo.cpp
@@ -558,7 +558,7 @@ GameInfo::InitializePing(int index)
 	GameInfoNode *node = &nodes[index];
 
 	if (node->nodeID != localID) {
-		node->ping.lastPing = SDL_GetTicks();
+		node->ping.lastPing = (Uint32)SDL_GetTicks();
 		node->ping.roundTripTime = 0;
 		node->ping.status = PING_GOOD;
 	}
@@ -571,7 +571,7 @@ GameInfo::UpdatePingTime(int index, Uint32 timestamp)
 	Uint32 elapsed;
 	GameInfoNode *node;
 
-	now = SDL_GetTicks();
+	now = (Uint32)SDL_GetTicks();
 	elapsed = (now - timestamp);
 
 	node = &nodes[index];
diff --git a/game/gameover.cpp b/game/gameover.cpp
index cee9e12f..9010e3c2 100644
--- a/game/gameover.cpp
+++ b/game/gameover.cpp
@@ -248,7 +248,7 @@ void GameOverPanelDelegate::BeginEnterName()
 	} else {
 		*m_handle = '\0';
 	}
-	m_handleSize = SDL_strlen(m_handle);
+	m_handleSize = (int)SDL_strlen(m_handle);
 
 	// Flush events before enabling text input
 	HandleEvents(0);
diff --git a/game/gameover.h b/game/gameover.h
index 3c262399..aae27b5d 100644
--- a/game/gameover.h
+++ b/game/gameover.h
@@ -43,7 +43,7 @@ class GameOverPanelDelegate : public UIPanelDelegate
 	UIElement *m_handleLabel;
 	int m_handleSize;
 	char m_handle[MAX_NAMELEN+1];
-	Uint32 m_showTime;
+	Uint64 m_showTime;
 };
 
 #endif // _gameover_h
diff --git a/game/init.cpp b/game/init.cpp
index 1bcb0202..baed5d72 100644
--- a/game/init.cpp
+++ b/game/init.cpp
@@ -51,7 +51,7 @@ array<Resolution> gResolutions;
 int	gResolutionIndex;
 char   *gReplayFile;
 Sint32	gLastHigh;
-Uint32	gLastDrawn;
+Uint64	gLastDrawn;
 int     gNumSprites;
 SDL_Rect gScrnRect;
 int	gStatusLine;
diff --git a/game/lobby.cpp b/game/lobby.cpp
index 3bb28f55..6ecc49fb 100644
--- a/game/lobby.cpp
+++ b/game/lobby.cpp
@@ -269,7 +269,7 @@ LobbyDialogDelegate::OnPoll()
 		return;
 	}
 
-	Uint32 now = SDL_GetTicks();
+	Uint64 now = SDL_GetTicks();
 	if (!m_lastRefresh ||
 	    (now - m_lastRefresh) > PING_INTERVAL) {
 		if (m_state == STATE_HOSTING) {
diff --git a/game/lobby.h b/game/lobby.h
index 5b29078d..434259b6 100644
--- a/game/lobby.h
+++ b/game/lobby.h
@@ -98,8 +98,8 @@ class LobbyDialogDelegate : public UIDialogDelegate
 		STATE_PLAYING
 	} m_state;
 
-	Uint32 m_lastPing;
-	Uint32 m_lastRefresh;
+	Uint64 m_lastPing;
+	Uint64 m_lastRefresh;
 	Uint32 m_requestSequence;
 
 	GameInfo &m_game;
diff --git a/game/main.cpp b/game/main.cpp
index ccd2691a..c0d45446 100644
--- a/game/main.cpp
+++ b/game/main.cpp
@@ -526,7 +526,7 @@ MainPanelDelegate::OnActionRunReplay(int index)
 
 void DelayFrame(void)
 {
-	Uint32 ticks;
+	Uint64 ticks;
 
 	while ( ((ticks=SDL_GetTicks())-gLastDrawn) < FRAME_DELAY_MS ) {
 		ui->Poll();
diff --git a/game/netplay.cpp b/game/netplay.cpp
index aec31016..ed6cfbb0 100644
--- a/game/netplay.cpp
+++ b/game/netplay.cpp
@@ -237,7 +237,7 @@ static SYNC_RESULT AwaitSync()
 	Uint32 frame;
 
 	// Send the packet to anyone waiting
-	Uint32 now = SDL_GetTicks();
+	Uint32 now = (Uint32)SDL_GetTicks();
 	for (i = 0; i < gGameInfo.GetNumNodes(); ++i) {
 		if (WaitingAcks[i]) {
 #if DEBUG_NETWORK >= 2
@@ -262,7 +262,7 @@ error("Sending packet for current frame (%ld)\r\n", NextFrame);
 
 	/* Wait for Ack's */
 	while (WaitingForAck()) {
-		now = SDL_GetTicks();
+		now = (Uint32)SDL_GetTicks();
 		for (i = 0; i < gGameInfo.GetNumNodes(); ++i) {
 			if (HasTimedOut(i, now)) {
 #if DEBUG_NETWORK >= 1
@@ -426,7 +426,7 @@ SYNC_RESULT SyncNetwork(void)
 	FrameInput.Write(QueuedInput);
 
 	// See if we need to do network synchronization
-	Uint32 now = SDL_GetTicks();
+	Uint32 now = (Uint32)SDL_GetTicks();
 	for (i = 0; i < gGameInfo.GetNumNodes(); ++i) {
 		if (gGameInfo.IsNetworkNode(i)) {
 			WaitingAcks[i] = NodeTimeout(now);
@@ -481,7 +481,7 @@ int Send_NewGame()
 	SDLNet_UDP_Send(gNetFD, 0, &newgame);
 
 	/* Get ready for responses */
-	Uint32 now = SDL_GetTicks();
+	Uint32 now = (Uint32)SDL_GetTicks();
 	for (i = 0; i < gGameInfo.GetNumNodes(); ++i) {
 		if (gGameInfo.IsNetworkNode(i)) {
 			WaitingAcks[i] = NodeTimeout(now);
@@ -505,7 +505,7 @@ int Send_NewGame()
 		}
 		//Message(message);
 
-		now = SDL_GetTicks();
+		now = (Uint32)SDL_GetTicks();
 		for (i = 0; i < gGameInfo.GetNumNodes(); ++i) {
 			if (HasTimedOut(i, now)) {
 				SDLNet_UDP_Send(gNetFD, i+1, &newgame);
diff --git a/game/packet.h b/game/packet.h
index f4aae59c..429ce661 100644
--- a/game/packet.h
+++ b/game/packet.h
@@ -105,12 +105,12 @@ class DynamicPacket : public UDPpacket
 	void Write(DynamicPacket &packet) {
 		size_t amount = packet.len - packet.pos;
 		Write(&packet.data[packet.pos], amount);
-		packet.pos += amount;
+		packet.pos += (int)amount;
 	}
 	void Write(const void *value, size_t size) {
 		Grow(size);
 		SDL_memcpy(&data[pos], value, size);
-		pos += size;
+		pos += (int)size;
 	}
 
 	bool Read(Uint8 &value) {
@@ -157,7 +157,7 @@ class DynamicPacket : public UDPpacket
 			}
 			data = (Uint8*)SDL_realloc(data, maxlen);
 		}
-		len += additionalSize;
+		len += (int)additionalSize;
 	}
 
 protected:
diff --git a/game/player.cpp b/game/player.cpp
index b28b45cb..9bd853d5 100644
--- a/game/player.cpp
+++ b/game/player.cpp
@@ -329,7 +329,7 @@ Player::Explode(void)
 		yVel += SCALE_FACTOR;
 	else
 		yVel -= SCALE_FACTOR;
-	
+
 	newsprite = gNumSprites;
 	gSprites[newsprite]=new Shrapnel(x, y, xVel, yVel, gShrapnel2[Index]);
 
diff --git a/maclib/Mac_FontServ.cpp b/maclib/Mac_FontServ.cpp
index 2ddb3b40..a78c869d 100644
--- a/maclib/Mac_FontServ.cpp
+++ b/maclib/Mac_FontServ.cpp
@@ -299,7 +299,7 @@ FontServ::TextWidth(const char *text, MFont *font, Uint8 style)
 					break;
 		default:		return(0);
 	}
-	nchars = SDL_strlen(text);
+	nchars = (int)SDL_strlen(text);
 
 	Width = 0;
 	for ( i = 0; i < nchars; ++i ) {
@@ -444,7 +444,7 @@ FontServ::TextImage(const char *text, MFont *font, Uint8 style, SDL_Color fg)
 
 	/* Print the individual characters */
 	/* Note: this could probably be optimized.. eh, who cares. :) */
-	nchars = SDL_strlen(text);
+	nchars = (int)SDL_strlen(text);
 	for ( boldness=0; boldness <= bold_offset; ++boldness ) {
 		bit_offset=0;
 		for ( i = 0; i < nchars; ++i ) {
diff --git a/screenlib/SDL_FrameBuf.cpp b/screenlib/SDL_FrameBuf.cpp
index 7d47756f..7998b116 100644
--- a/screenlib/SDL_FrameBuf.cpp
+++ b/screenlib/SDL_FrameBuf.cpp
@@ -54,8 +54,8 @@ FrameBuf::Init(int width, int height, Uint32 window_flags, SDL_Surface *icon)
 	}
 
 	/* Create the window */
-	window = SDL_CreateWindow(NULL, window_width, window_height, window_flags);
-	if (!window) {
+	m_window = SDL_CreateWindow(NULL, window_width, window_height, window_flags);
+	if (!m_window) {
 		SetError("Couldn't create %dx%d window: %s", 
 					width, height, SDL_GetError());
 		return(-1);
@@ -63,50 +63,56 @@ FrameBuf::Init(int width, int height, Uint32 window_flags, SDL_Surface *icon)
 
 	/* Set the icon, if any */
 	if ( icon ) {
-		SDL_SetWindowIcon(window, icon);
+		SDL_SetWindowIcon(m_window, icon);
 	}
 
 	/* Create the renderer */
-	renderer = SDL_CreateRenderer(window, NULL);
-	if (!renderer) {
+	m_renderer = SDL_CreateRenderer(m_window, NULL);
+	if (!m_renderer) {
 		SetError("Couldn't create renderer: %s", SDL_GetError());
 		return(-1);
 	}
 
 	/* Set the output area */
-	SDL_SetRenderLogicalPresentation(renderer, width, height, SDL_LOGICAL_PRESENTATION_LETTERBOX);
-	UpdateWindowSize(width, height);
+	SDL_SetRenderLogicalPresentation(m_renderer, width, height, SDL_LOGICAL_PRESENTATION_LETTERBOX);
+
+	m_width = width;
+	m_height = height;
+	m_clip.x = 0.0f;
+	m_clip.y = 0.0f;
+	m_clip.w = (float)width;
+	m_clip.h = (float)height;
 
 	/* Create the render target */
-	target = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_UNKNOWN, SDL_TEXTUREACCESS_TARGET, width, height);
-	if (!target) {
+	m_target = SDL_CreateTexture(m_renderer, SDL_PIXELFORMAT_UNKNOWN, SDL_TEXTUREACCESS_TARGET, width, height);
+	if (!m_target) {
 		SetError("Couldn't create target: %s", SDL_GetError());
 		return(-1);
 	}
-	//SDL_SetTextureScaleMode(target, SDL_SCALEMODE_PIXELART);
+	//SDL_SetTextureScaleMode(m_target, SDL_SCALEMODE_PIXELART);
 
-	SDL_SetRenderTarget(renderer, target);
+	SDL_SetRenderTarget(m_renderer, m_target);
 
 	return(0);
 }
 
 FrameBuf::~FrameBuf()
 {
-	if (target) {
-		SDL_DestroyTexture(target);
+	if (m_target) {
+		SDL_DestroyTexture(m_target);
 	}
-	if (renderer) {
-		SDL_DestroyRenderer(renderer);
+	if (m_renderer) {
+		SDL_DestroyRenderer(m_renderer);
 	}
-	if (window) {
-		SDL_DestroyWindow(window);
+	if (m_window) {
+		SDL_DestroyWindow(m_window);
 	}
 }
 
 void
 FrameBuf::ProcessEvent(SDL_Event *event)
 {
-	SDL_ConvertEventToRenderCoordinates(renderer, event);
+	SDL_ConvertEventToRenderCoordinates(m_renderer, event);
 }
 
 bool
@@ -114,7 +120,7 @@ FrameBuf::ConvertTouchCoordinates(const SDL_TouchFingerEvent &finger, int *x, in
 {
 	int w, h;
 
-	SDL_GetRenderOutputSize(renderer, &w, &h);
+	SDL_GetRenderOutputSize(m_renderer, &w, &h);
 	*x = (int)(finger.x * w);
 	*y = (int)(finger.y * h);
 	return true;
@@ -133,7 +139,7 @@ FrameBuf::GetCursorPosition(int *x, int *y)
 	float mouse_x, mouse_y;
 
 	SDL_GetMouseState(&mouse_x, &mouse_y);
-	SDL_RenderCoordinatesFromWindow(renderer, mouse_x, mouse_y, &mouse_x, &mouse_y);
+	SDL_RenderCoordinatesFromWindow(m_renderer, mouse_x, mouse_y, &mouse_x, &mouse_y);
 
 	*x = (int)mouse_x;
 	*y = (int)mouse_y;
@@ -142,13 +148,13 @@ FrameBuf::GetCursorPosition(int *x, int *y)
 void
 FrameBuf::EnableTextInput()
 {
-	SDL_StartTextInput(window);
+	SDL_StartTextInput(m_window);
 }
 
 void
 FrameBuf::DisableTextInput()
 {
-	SDL_StopTextInput(window);
+	SDL_StopTextInput(m_window);
 }
 
 void
@@ -160,32 +166,32 @@ FrameBuf::QueueBlit(SDL_Texture *src,
 	SDL_FRect srcrect;
 	SDL_FRect dstrect;
 
-	srcrect.x = srcx;
-	srcrect.y = srcy;
-	srcrect.w = srcw;
-	srcrect.h = srch;
-	dstrect.x = dstx;
-	dstrect.y = dsty;
-	dstrect.w = dstw;
-	dstrect.h = dsth;
+	srcrect.x = (float)srcx;
+	srcrect.y = (float)srcy;
+	srcrect.w = (float)srcw;
+	srcrect.h = (float)srch;
+	dstrect.x = (float)dstx;
+	dstrect.y = (float)dsty;
+	dstrect.w = (float)dstw;
+	dstrect.h = (float)dsth;
 	if (do_clip == DOCLIP) {
-		float scaleX = (float)srcrect.w / dstrect.w;
-		float scaleY = (float)srcrect.h / dstrect.h;
+		float scaleX = srcrect.w / dstrect.w;
+		float scaleY = srcrect.h / dstrect.h;
 
-		if (!SDL_GetRectIntersectionFloat(&clip, &dstrect, &dstrect)) {
+		if (!SDL_GetRectIntersectionFloat(&m_clip, &dstrect, &dstrect)) {
 			return;
 		}
 
 		/* Adjust the source rectangle to match */
-		srcrect.x += (int)((dstrect.x - dstx) * scaleX);
-		srcrect.y += (int)((dstrect.y - dsty) * scaleY);
-		srcrect.w = (int)(dstrect.w * scaleX);
-		srcrect.h = (int)(dstrect.h * scaleY);
+		srcrect.x += ((dstrect.x - dstx) * scaleX);
+		srcrect.y += ((dstrect.y - dsty) * scaleY);
+		srcrect.w = (dstrect.w * scaleX);
+		srcrect.h = (dstrect.h * scaleY);
 	}
 	if (angle) {
-		SDL_RenderTextureRotated(renderer, src, &srcrect, &dstrect, angle, NULL, SDL_FLIP_NONE);
+		SDL_RenderTextureRotated(m_renderer, src, &srcrect, &dstrect, angle, NULL, SDL_FLIP_NONE);
 	} else {
-		SDL_RenderTexture(renderer, src, &srcrect, &dstrect);
+		SDL_RenderTexture(m_renderer, src, &srcrect, &dstrect);
 	}
 }
 
@@ -205,27 +211,27 @@ FrameBuf::StretchBlit(const SDL_Rect *_dstrect, SDL_Texture *src, const SDL_Rect
 		dstrect = &cvtdstrect;
 	}
 
-	SDL_RenderTexture(renderer, src, srcrect, dstrect);
+	SDL_RenderTexture(m_renderer, src, srcrect, dstrect);
 }
 
 void
 FrameBuf::Update(void)
 {
-	if (target) {
+	if (m_target) {
 		/* Make sure resize events are seen before drawing to the screen */
 		SDL_PumpEvents();
 
-		SDL_SetRenderTarget(renderer, NULL);
+		SDL_SetRenderTarget(m_renderer, NULL);
 
-		SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
-		SDL_RenderClear(renderer);
+		SDL_SetRenderDrawColor(m_renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
+		SDL_RenderClear(m_renderer);
 
-		SDL_RenderTexture(renderer, target, NULL, NULL);
-		SDL_RenderPresent(renderer);
+		SDL_RenderTexture(m_renderer, m_target, NULL, NULL);
+		SDL_RenderPresent(m_renderer);
 
-		SDL_SetRenderTarget(renderer, target);
+		SDL_SetRenderTarget(m_renderer, m_target);
 	} else {
-		SDL_RenderPresent(renderer);
+		SDL_RenderPresent(m_renderer);
 	}
 }
 
@@ -236,13 +242,13 @@ FrameBuf::Fade(void)
 	Uint8 value;
 
 	for ( int i = 1; i <= max; ++i ) {
-		int v = faded ? i : max - i;
+		int v = m_faded ? i : max - i;
 		value = (Uint8)(255 * v / max);
-		SDL_SetTextureColorMod(target, value, value, value);
+		SDL_SetTextureColorMod(m_target, value, value, value);
 		Update();
 		SDL_Delay(10);
 	}
-	faded = !faded;
+	m_faded = !m_faded;
 } 
 
 int
@@ -264,7 +270,7 @@ FrameBuf::ScreenDump(const char *prefix, int x, int y, int w, int h)
 	rect.y = y;
 	rect.w = w;
 	rect.h = h;
-	dump = SDL_RenderReadPixels(renderer, &rect);
+	dump = SDL_RenderReadPixels(m_renderer, &rect);
 	if (!dump) {
 		SetError("%s", SDL_GetError());
 		return -1;
@@ -318,7 +324,7 @@ FrameBuf::LoadImage(const char *file)
 SDL_Texture *
 FrameBuf::LoadImage(SDL_Surface *surface)
 {
-	return SDL_CreateTextureFromSurface(renderer, surface);
+	return SDL_CreateTextureFromSurface(m_renderer, surface);
 }
 
 SDL_Texture *
@@ -326,7 +332,7 @@ FrameBuf::LoadImage(int w, int h, Uint32 *pixels)
 {
 	SDL_Texture *texture;
 
-	texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STATIC, w, h);
+	texture = SDL_CreateTexture(m_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STATIC, w, h);
 	if (!texture) {
 		SetError("%s", SDL_GetError());
 		return NULL;
diff --git a/screenlib/SDL_FrameBuf.h b/screenlib/SDL_FrameBuf.h
index d5ecab7a..f7b1f360 100644
--- a/screenlib/SDL_FrameBuf.h
+++ b/screenlib/SDL_FrameBuf.h
@@ -59,11 +59,11 @@ class FrameBuf : public ErrorBase {
 		*B = (Uint8)((color >>  0) & 0xFF);
 	}
 	/* Set the blit clipping rectangle */
-	void   ClipBlit(SDL_Rect *cliprect) {
-		clip.x = cliprect->x;
-		clip.y = cliprect->y;
-		clip.w = cliprect->w;
-		clip.h = cliprect->h;
+	void ClipBlit(SDL_Rect *cliprect) {
+		m_clip.x = (float)cliprect->x;
+		m_clip.y = (float)cliprect->y;
+		m_clip.w = (float)cliprect->w;
+		m_clip.h = (float)cliprect->h;
 	}
 
 	/* Event Routines */
@@ -89,22 +89,22 @@ class FrameBuf : public ErrorBase {
 	void DisableTextInput();
 
 	void ToggleFullScreen(void) {
-		if (SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN) {
-			SDL_SetWindowFullscreen(window, false);
+		if (SDL_GetWindowFlags(m_window) & SDL_WINDOW_FULLSCREEN) {
+			SDL_SetWindowFullscreen(m_window, false);
 		} else {
-			SDL_SetWindowFullscreen(window, true);
+			SDL_SetWindowFullscreen(m_window, true);
 		}
 	}
 
 	/* Information routines */
 	SDL_Window *GetWindow() const {
-		return window;
+		return m_window;
 	}
 	int Width() const {
-		return rect.w;
+		return m_width;
 	}
 	int Height() const {
-		return rect.h;
+		return m_height;
 	}
 
 	/* Blit and update routines */
@@ -121,12 +121,12 @@ class FrameBuf : public ErrorBase {
 
 	void Update(void);
 	void FadeOut(void) {
-		if (!faded) {
+		if (!m_faded) {
 			Fade();
 		}
 	}
 	void FadeIn(void) {
-		if (faded) {
+		if (m_faded) {
 			Fade();
 		}
 	}
@@ -138,35 +138,35 @@ class FrameBuf : public ErrorBase {
 	}
 	void Clear(Uint32 color = 0) {
 		UpdateDrawColor(color);
-		SDL_RenderClear(renderer);
+		SDL_RenderClear(m_renderer);
 	}
 	void DrawPoint(int x, int y, Uint32 color) {
 		UpdateDrawColor(color);
-		SDL_RenderPoint(renderer, x, y);
+		SDL_RenderPoint(m_renderer, (float)x, (float)y);
 	}
 	void DrawLine(int x1, int y1, int x2, int y2, Uint32 color) {
 		UpdateDrawColor(color);
-		SDL_RenderLine(renderer, x1, y1, x2, y2);
+		SDL_RenderLine(m_renderer, (float)x1, (float)y1, (float)x2, (float)y2);
 	}
 	void DrawRect(int x1, int y1, int w, int h, Uint32 color) {
 		UpdateDrawColor(color);
 
 		SDL_FRect rect;
-		rect.x = x1;
-		rect.y = y1;
-		rect.w = w;
-		rect.h = h;
-		SDL_RenderRect(renderer, &rect);
+		rect.x = (float)x1;
+		rect.y = (float)y1;
+		rect.w = (float)w;
+		rect.h = (float)h;
+		SDL_RenderRect(m_renderer, &rect);
 	}
 	void FillRect(int x1, int y1, int w, int h, Uint32 color) {
 		UpdateDrawColor(color);
 
 		SDL_FRect rect;
-		rect.x = x1;
-		rect.y = y1;
-		rect.w = w;
-		rect.h = h;
-		SDL_RenderFillRect(renderer, &rect);
+		rect.x = (float)x1;
+		rect.y = (float)y1;
+		rect.w = (float)w;
+		rect.h = (float)h;
+		SDL_RenderFillRect(m_renderer, &rect);
 	}
 
 	/* Load a texture image */
@@ -193,33 +193,25 @@ class FrameBuf : public ErrorBase {
 	}
 	void GetCursorPosition(int *x, int *y);
 	void SetCaption(const char *caption, const char *icon = NULL) {
-		SDL_SetWindowTitle(window, caption);
+		SDL_SetWindowTitle(m_window, caption);
 	}
 
 private:
 	/* The current display */
-	SDL_Window *window = nullptr;
-	SDL_Renderer *renderer = nullptr;
-	SDL_Texture *target = nullptr;
-	bool faded = false;
-	SDL_Rect rect;
-	SDL_FRect clip;
-	SDL_Rect output;
-
-	void UpdateWindowSize(int width, int height) {
-		clip.x = rect.x = 0;
-		clip.y = rect.y = 0;
-		clip.w = rect.w = width;
-		clip.h = rect.h = height;
-
-		SDL_GetRenderViewport(renderer, &output);
-	}
+	SDL_Window *m_window = nullptr;
+	SDL_Renderer *m_renderer = nullptr;
+	SDL_Texture *m_target = nullptr;
+	bool m_faded = false;
+	SDL_FRect m_clip;
+	int m_width;
+	int m_height;
+
 	void UpdateDrawColor(Uint32 color) {
 		Uint8 r, g, b;
 		r = (color >> 16) & 0xFF;
 		g = (color >>  8) & 0xFF;
 		b = (color >>  0) & 0xFF;
-		SDL_SetRenderDrawColor(renderer, r, g, b, 0xFF);
+		SDL_SetRenderDrawColor(m_renderer, r, g, b, 0xFF);
 	}
 };
 
diff --git a/screenlib/UIElement.cpp b/screenlib/UIElement.cpp
index d270ddf9..176119ff 100644
--- a/screenlib/UIElement.cpp
+++ b/screenlib/UIElement.cpp
@@ -563,14 +563,14 @@ UIElement::HandleEvent(const SDL_Event &event)
 		int x, y;
 
 		if (event.type == SDL_EVENT_MOUSE_MOTION) {
-			x = event.motion.x;
-			y = event.motion.y;
+			x = (int)event.motion.x;
+			y = (int)event.motion.y;
 			checkMouseLocation = true;
 		}
 		if (event.type == SDL_EVENT_MOUSE_BUTTON_DOWN ||
 		    event.type == SDL_EVENT_MOUSE_BUTTON_UP) {
-			x = event.button.x;
-			y = event.button.y;
+			x = (int)event.button.x;
+			y = (int)event.button.y;
 			checkMouseLocation = true;
 		}
 
diff --git a/screenlib/UIElementEditbox.cpp b/screenlib/UIElementEditbox.cpp
index 2ff5b57a..3bcbc11d 100644
--- a/screenlib/UIElementEditbox.cpp
+++ b/screenlib/UIElementEditbox.cpp
@@ -200,7 +200,7 @@ void
 UIElementEditbox::SetText(const char *text)
 {
 	SDL_strlcpy(m_text, text, m_textMax+1);
-	m_textLen = SDL_strlen(m_text);
+	m_textLen = (int)SDL_strlen(m_text);
 	OnTextChanged();
 }
 
diff --git a/screenlib/UIElementThumbstick.cpp b/screenlib/UIElementThumbstick.cpp
index 5d59590c..f5f36e2e 100644
--- a/screenlib/UIElementThumbstick.cpp
+++ b/screenlib/UIElementThumbstick.cpp
@@ -186,7 +186,7 @@ UIElementThumbstick::GetTouchAngleAndDistance(int x, int y, float &angle, float
 	float b = (float)(y - m_startY);
 
 	// The angle is in the 0 - 2PI range with 0 being the +Y axis
-	angle = (SDL_PI_F - SDL_atan2(a, b));
+	angle = (SDL_PI_F - SDL_atan2f(a, b));
 	distance = SDL_sqrtf((a*a) + (b*b));
 	return true;
 }