This is my first time using SDL. Install SDL2 for my Linux system: sudo apt-get install libsdl2-dev libsdl2-image-dev Now we can test our first SDL program. This program is pretty simple, I want to show an image as the background of a main window. In Linux system, #include <SDL2/SDL.h> as well as #include <SDL2/SDL_image.h> SDL_Init(SDL_INIT_VIDEO) should be called before initializing the main window. Using SDL_Surface for loading image, SDL_Renderer and SDL_Texture for rendering operation. Free memory. Code: #include <iostream> #include <SDL2/SDL.h> #include <SDL2/SDL_image.h> using namespace std; const int SCREEN_WIDTH = 800; const int SCREEN_HEIGHT = 600; int main( int argc, char** argv) { if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) { cout << " [Error] SDL initialization fail: " << SDL_GetError() << endl; exit(1); } SDL_Window* main_win = SDL_CreateWindow( ...
Coding for Passion, Solving Problems