Preface
The purpose of referencing the Sdl2_image plugin is to use images in PNG, GIF and other formats in the project. This configuration is in the "1, Build development environment" on the basis of the. Steps
Download SDL2 image (http://www.libsdl.org/projects/SDL_image/)
Change "i686-w64-mingw32" file name to "Sdl2_image" and copy to C packing directory
Configuring Sdl2image in Codeblocks
Code
#include <stdio.h> #include <stdlib.h> #include <sdl2/sdl.h>//referencing the SDL library #include <sdl2/sdl_image.h
>//references sdl_image library int main (int argc,char* argv[])//complete Mian function definition {sdl_init (sdl_init_video); sdl_window* window = Sdl_createwindow ("SDL Tutorial1",//Windows title Sdl_windo
wpos_undefined,sdl_windowpos_undefined,//window position 800,600,//window size
sdl_window_shown//display in windowed mode);
Sdl_rect Rect;
Rect.x = 100;
RECT.Y = 100; sdl_surface* Surface = sdl_getwindowsurface (window);//Get canvas sdl_surface* image = Img_load ("Arror.png");//Use image to load PNG cells Image Sdl_blitsurface (image,null,surface,&rect);//implement to paste the decal onto the canvas sdl_updatewindowsurface (window);//Update Canvas SDL_FR Eesurface (image);//Release decal sdl_freesurface (surface)//release canvas Sdl_delay (3000);//delay 3 seconds sdl_destroywindow (window);//Destroy painting
Cloth Object Sdl_quit ();//Exit SDL
return 0;
}
Note
DLL files must be copied to the project directory