SDL2 Tutorial

时间:2024-11-06 13:35:32

Hello World for SDL2

SDL2 setting for visual studio.

http://lazyfoo.net/tutorials/SDL/01_hello_SDL/windows/msvsnet2010u/index.php

1. SDL_Init( SDL_INIT_VIDEO );

2. window = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );

3. screenSurface = SDL_GetWindowSurface( window );

4. SDL_FillRect( screenSurface, NULL, SDL_MapRGB( screenSurface->format, 0xFF, 0xFF, 0xFF ) );

5. SDL_UpdateWindowSurface( window );

6. SDL_DestroyWindow( window );

The above five line code will create a SDL window and create a surface from this window, than we fill this surface with color(0xff, 0xff, 0xff) and update this window use the surface we create before, finally we just destroy the window and return this program