SDL
SDL (Simple DirectMedia Layer)
由C语言实现的跨平台的媒体开源库
多用于开发游戏、模拟器、媒体播放器等多媒体应用领域
SDL 编译与安装
下载SDL源码
解压源码: tar -zvxf SDL2-2.0.9.tar.gz
cd SDL2-2.0.9 路径下
生成 Makefile: ./configure – prefix=/usr/local
安装: sudo make -j 8 && make install
使用SDL基本步骤
添加头文件
#include<SDL.h>
初始化 SDL
退出 SDL
SDL 渲染窗口
SDL_Init/SDL_Quit()
SDL_CreateWindow()/SDL_DestroyWindow()
SDL_CreateRender()/SDL_DestroyRender()
SDL_RenderClear
SDL_RenderPresent
运行:
clang -g -o SDL SDL.c -lsdl2
SDL.c:1:10: fatal error: 'SDL.h' file not found
#include <SDL.h>
^~~~~~~
1 error generated.
结果报错找不到SDL的库;