SDL库的下载与配置(Visual Studio )2024/2/4更新

一.SDL的下载

下载链接



二.SDL的环境配置

解压以后放在中文路径下

不会添加环境变量自行搜索(比较简单网上教程很多)

下面进行编译器的配置




复制这段内容

c 复制代码
x64\SDL2main.lib
x64\SDL2.lib

将这段代码放进去运行一下

c 复制代码
#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;
}

这样就是成功了!!!

相关推荐
sphw9 小时前
nixnb: Jupyter Notebook 优雅分享
ide·人工智能·jupyter
zyl8372114 小时前
MCP CodeGraph 完整介绍
visual studio
脚踏实地皮皮晨16 小时前
002002002_DepandencyObject类2
开发语言·windows·算法·c#·visual studio
仙宇觉尘21 小时前
【译】Visual Studio Copilot 中更智能的人工智能编辑
人工智能·copilot·visual studio
计算机内卷的N天1 天前
CMake与Visual Studio的使用
c++·ide·visual studio
脚踏实地皮皮晨1 天前
003002004_WPF Panel 基类 官方类定义
开发语言·windows·算法·c#·wpf·visual studio
咱入行浅1 天前
一款实用的 Visual Studio 发布部署插件,助力提高部署效率!
ide·visual studio
谢斯1 天前
[vscode] 使用unity打开vscode的取消.csproj的显示
ide·vscode·unity
2501_916007472 天前
SwiftUI 声明式语法与 Xcode 预览功能详解
ide·vscode·ios·swiftui·个人开发·xcode·敏捷流程
呐抹倾2 天前
【译】Visual Studio 停用:针对旧版本 Visual Studio 的支持提醒
ide·visual studio