当前位置: 首页 > 工具软件 > SDL > 使用案例 >

编译运行sdl

太叔小云
2023-12-01
#include <SDL2/SDL.h>

int main(int argc, char *argv[]) {
    SDL_Init(SDL_INIT_EVERYTHING);
    SDL_Quit();
    return 0;
}

检测运行成功

gcc sdl_image.c -o sdl_demo -lSDL2


    #include <stdio.h>  
    #include <SDL/SDL.h>  
    int main()  
    {  
        //The images  
        SDL_Surface* hello = NULL;  
        SDL_Surface* screen = NULL;  
        SDL_Init( SDL_INIT_EVERYTHING );  
        //Set up screen  
        screen = SDL_SetVideoMode( 640, 480, 32, SDL_SWSURFACE );  
        //Load image  
        hello = SDL_LoadBMP( "logo.bmp" );  
        //Apply image to screen  
        SDL_BlitSurface( hello, NULL, screen, NULL );  
        //Update Screen  
        SDL_Flip( screen );  
        //Pause  
        SDL_Delay( 5000 );      
        //Quit SDL  
        SDL_Quit();  
        //Free memory  
        SDL_FreeSurface( hello );  
        //Quit SDL  
        SDL_Quit();  
        return 0;  
    }  

加载一副bmp图片。

gcc -I/usr/include/SDL/ sdl_image.c -o sdl_image -L/usr/lib -lSDL

 类似资料: