11#include <stdio.h>
22
3- #include <SDL2/SDL.h>
4- #include <SDL2/SDL_ttf.h>
3+ #include <SDL3/SDL.h>
4+ #include <SDL3/SDL_main.h>
5+ #include <SDL3_ttf/SDL_ttf.h>
56
67// Define screen dimensions
78#define SCREEN_WIDTH 480
@@ -32,8 +33,6 @@ int main(int argc, char **argv)
3233
3334 SDL_Window * win = SDL_CreateWindow (
3435 "window" ,
35- SDL_WINDOWPOS_UNDEFINED ,
36- SDL_WINDOWPOS_UNDEFINED ,
3736 SCREEN_WIDTH ,
3837 SCREEN_HEIGHT ,
3938 0 );
@@ -45,22 +44,22 @@ int main(int argc, char **argv)
4544 SDL_GetError ());
4645 }
4746
48- SDL_Renderer * renderer = SDL_CreateRenderer (win , -1 , 0 );
47+ SDL_Renderer * renderer = SDL_CreateRenderer (win , NULL );
4948 TTF_Font * font = TTF_OpenFont ("Pacifico.ttf" , 40 );
5049
5150 // Set the text and background color
5251 SDL_Color text_color = {0xff , 0xff , 0xff , 0xff };
5352 SDL_Color bg_color = {0x00 , 0x00 , 0x00 , 0xff };
5453
55- SDL_Rect text_rect ;
56- SDL_Surface * surface = TTF_RenderText (font , "Hello World!" , text_color , bg_color );
54+ SDL_FRect text_rect ;
55+ SDL_Surface * surface = TTF_RenderText_Shaded (font , "Hello World!" , 0 , text_color , bg_color );
5756 SDL_Texture * texture = SDL_CreateTextureFromSurface (renderer , surface );
5857
5958 // Get text dimensions
6059 text_rect .w = surface -> w ;
6160 text_rect .h = surface -> h ;
6261
63- SDL_FreeSurface (surface );
62+ SDL_DestroySurface (surface );
6463
6564 text_rect .x = (SCREEN_WIDTH - text_rect .w ) / 2 ;
6665 text_rect .y = text_rect .h + 30 ;
@@ -73,14 +72,14 @@ int main(int argc, char **argv)
7372 {
7473 switch (e .type )
7574 {
76- case SDL_QUIT :
75+ case SDL_EVENT_QUIT :
7776 running = 0 ;
7877 break ;
79- case SDL_CONTROLLERDEVICEADDED :
80- SDL_GameControllerOpen (e .cdevice .which );
78+ case SDL_EVENT_GAMEPAD_ADDED :
79+ SDL_OpenGamepad (e .cdevice .which );
8180 break ;
82- case SDL_CONTROLLERBUTTONDOWN :
83- if (e .cbutton .button == SDL_CONTROLLER_BUTTON_START )
81+ case SDL_EVENT_GAMEPAD_BUTTON_DOWN :
82+ if (e .button .button == SDL_GAMEPAD_BUTTON_START )
8483 {
8584 running = 0 ;
8685 }
@@ -91,7 +90,7 @@ int main(int argc, char **argv)
9190 SDL_SetRenderDrawColor (renderer , 0xff , 0xff , 0xff , 0xff );
9291 SDL_RenderClear (renderer );
9392 SDL_SetRenderDrawColor (renderer , 0xff , 0x00 , 0x00 , 0xff );
94- SDL_RenderCopy (renderer , texture , NULL , & text_rect );
93+ SDL_RenderTexture (renderer , texture , NULL , & text_rect );
9594 SDL_RenderPresent (renderer );
9695 }
9796
@@ -101,4 +100,4 @@ int main(int argc, char **argv)
101100 SDL_Quit ();
102101
103102 return 0 ;
104- }
103+ }
0 commit comments