<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SDL3 | Learn C Games Programming Blog</title>
	<atom:link href="https://learncgames.com/tag/sdl3/feed/" rel="self" type="application/rss+xml" />
	<link>https://learncgames.com</link>
	<description>A blog about C, programming games and my ebook(s).</description>
	<lastBuildDate>Sat, 24 May 2025 14:21:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://learncgames.com/wp-content/uploads/2020/03/cropped-favicon-32x32.png</url>
	<title>SDL3 | Learn C Games Programming Blog</title>
	<link>https://learncgames.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">181446779</site>	<item>
		<title>Converting from SDL2 to SDL3 on Windows</title>
		<link>https://learncgames.com/converting-from-sdl2-to-sdl3-on-windows/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=converting-from-sdl2-to-sdl3-on-windows</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sat, 24 May 2025 14:21:56 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[SDL]]></category>
		<category><![CDATA[Techniques]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[SDL2]]></category>
		<category><![CDATA[SDL3]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3414</guid>

					<description><![CDATA[<p>These notes were made when converting an existing C game that used SDL2 to SDL3 on Windows. The game was originally developed for Linux Format and I had got it running on Windows with SDL2. Windows include paths have been made consistent with Linux. The include files path for SDL3 need to be SDL3\&#8230; when [&#8230;]</p>
The post <a href="https://learncgames.com/converting-from-sdl2-to-sdl3-on-windows/">Converting from SDL2 to SDL3 on Windows</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<p><img fetchpriority="high" decoding="async" class="alignleft wp-image-3418" src="https://learncgames.com/wp-content/uploads/2025/05/SDL3-300x232.png" alt="Missile Command running with SDL3" width="600" height="463" srcset="https://learncgames.com/wp-content/uploads/2025/05/SDL3-300x232.png 300w, https://learncgames.com/wp-content/uploads/2025/05/SDL3-1024x790.png 1024w, https://learncgames.com/wp-content/uploads/2025/05/SDL3-768x593.png 768w, https://learncgames.com/wp-content/uploads/2025/05/SDL3.png 1026w" sizes="(max-width: 600px) 100vw, 600px" /></p>
<p>These notes were made when converting an existing C game that used SDL2 to SDL3 on Windows. The game was originally developed for Linux Format and I had got it running on Windows with SDL2.</p>
<p>Windows include paths have been made consistent with Linux. The include files path for SDL3 need to be SDL3\&#8230; when setting them up. For SDL2, I had them in a folder c:\SDL2\include but noted that in SDL2.h include files were like this:</p>
<pre>#include "SDL_main.h"
#include "SDL_stdinc.h"</pre>
<p>While in SDL3&#8217;s SDL.h they are</p>
<pre>#include &lt;SDL3/SDL_stdinc.h&gt;
#include &lt;SDL3/SDL_assert.h&gt;</pre>
<p>So I put them c:\SDL3\SDL3</p>
<p>When you include them in your software they are like this:</p>
<pre>#include &lt;SDL3/SDL.h&gt;
#include &lt;SDL3/SDL_image.h&gt;</pre>
<p>Which is how they are in Linux.</p>
<p>The rest of these notes are taken from the differences between the SDL2 and SDL3 versions of the game. They are not complete but intended to give you an idea of some of the changes you may need to do.</p>
<h3>SDL_TTF</h3>
<p>TTF_RenderUTF8_Blended( is now TTF_RenderText_Blended with an extra text length parameter.</p>
<h3>SDL_Rects are mostly replaced by SDL_FRect</h3>
<p>This is a big change. Everywhere I was passing in an SDL_Rect became an SDL_Frect which is four floats rather than four ints.</p>
<p>SDL_RenderCopy is now SDL_RenderTexture and the last two params are now SDL_FRects.</p>
<p>To fix this I used a load of (float) casts.</p>
<p><strong>SDL_RenderDrawLine</strong> becomes <strong>SDL_RenderLine</strong> and has an SDL_FRect parameter instaed of SDL_Rect.</p>
<p>Same for <strong>SDL_RenderDrawPoint</strong> which becomes <strong>SDL_RenderPoint</strong>.</p>
<p><strong>SDL_GetMouseState</strong> keeps the same name but returns float * for both parameters now.</p>
<h3>Setup changes slightly</h3>
<p>There&#8217;s no <strong>SDL_SetMainReady()</strong> and SDL2main.lib is gone.</p>
<p>Also gone is <strong>SDL_INIT_EVERYTHING</strong> in <strong>SDL_Init()</strong>&#8211; you have to or the specific subunits. E.g. SDL_INIT_VIDEO | SDL_INIT_EVENTS</p>
<p>Also there&#8217;s no <strong>SDL_RENDERER_PRESENTVSYNC </strong>for SDL_CreateRenderer. Vsync is disabled by default as I found when my game ran about 30x faster and finished in a few seconds! Instead you need to call SDL_SetRenderVSync(renderer, 1) where 1 is syncing with each retrace, or 2 with every 2nd retrace.</p>
<p>Several of the events have been renamed, so SDL_KEYDOWN becomes SDL_EVENT_KEY_DOWN, SDL_MOUSEBUTTONDOWN becomes  SDL_EVENT_MOUSE_BUTTON_DOWN and similar for other events.  Also event.key.keysym.sym becomes event.key.key.</p>
<p>Finally SDL_FreeSurface( becomes SDL_DestroySurface.</p>
<p>I&#8217;m sure there are more but changing these was sufficent to get my game compiling and running correctly with SDL3.</p>The post <a href="https://learncgames.com/converting-from-sdl2-to-sdl3-on-windows/">Converting from SDL2 to SDL3 on Windows</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3414</post-id>	</item>
	</channel>
</rss>
