一.SDL的下载
下载链接
二.SDL的环境配置
解压以后放在中文路径下
不会添加环境变量自行搜索(比较简单网上教程很多)
下面进行编译器的配置
复制这段内容
x64\SDL2main.lib
x64\SDL2.lib
将这段代码放进去运行一下
#include <SDL.h>int main(int argc, char* argv[]) {SDL_Window* window = NULL;SDL_Renderer* renderer = NULL;SDL_Init(SDL_INIT_VIDEO);window = SDL_CreateWindow("SDL Example", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, 0);renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255); // 设置绘制颜色为红色SDL_RenderClear(renderer); // 清空渲染器SDL_RenderPresent(renderer); // 将绘制的内容显示到窗口上SDL_Delay(3000); // 等待3秒SDL_DestroyRenderer(renderer);SDL_DestroyWindow(window);SDL_Quit();return 0;
}
这样就是成功了!!!