# SDL-Study **Repository Path**: chen227/sdl-study ## Basic Information - **Project Name**: SDL-Study - **Description**: SDL库的设计目的是使用各种本机高性能媒体接口(用于视频、音频等)编写在Linux、*BSD、MacOS、Win32和BeOS上运行的游戏,并向应用程序提供单一源代码级API。SDL是一个相当低级的API,但是使用它,完全可移植的应用程序可以非常灵活地编写。 - **Primary Language**: C/C++ - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 1 - **Created**: 2021-09-16 - **Last Updated**: 2024-09-06 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # SDL-Study #### 介绍 SDL库的设计目的是使用各种本机高性能媒体接口(用于视频、音频等)编写在Linux、*BSD、MacOS、Win32和BeOS上运行的游戏,并向应用程序提供单一源代码级API。SDL是一个相当低级的API,但是使用它,完全可移植的应用程序可以非常灵活地编写。 中文学习网站 http://tjumyk.github.io/sdl-tutorial-cn/index.html 英文学习网站 http://www.sdltutorials.com/ sdl下载网站 https://www.libsdl.org/release/ #### 软件架构 软件架构说明 #### 安装教程 1. 安装 SDL2 在 Linux 上,您可以使用终端轻松安装 SDL2: 找到SDL2的当前版本:apt-cache search libsdl2 (e.g. libsdl2-2.0-0) 安装SDL2:sudo apt-get install libsdl2-2.0-0(替换为找到的版本) 安装SDL2开发包:sudo apt-get install libsdl2-dev 如果尚未安装 build Essentials:sudo apt-get install build-essential 扩展库 apt-get install libsdl2* 2. 安装 SDL1.2 apt-get install libsdl1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev 3. 自己编译的方案 #编译安装SDL git clone https://github.com/libsdl-org/SDL.git -b SDL2 cd SDL mkdir build cd build ../configure make sudo make install #安装automake sudo apt-get install automake yum -y install automake #安装libssl-dev sudo apt-get install aptitude sudo aptitude install libssl-dev #编译安装cmake https://cmake.org/files/v3.22/cmake-3.22.1.tar.gz ./configure make sudo make install #编译安装SDL_image #git clone https://github.com/libsdl-org/SDL_image.git -b SDL2 git clone https://gitee.com/rock1782002/SDL_image.git -b SDL2 cd SDL_image mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Release cmake --build . --config Release --parallel #CMake >= 3.15 sudo cmake --install . --config Release #编译安装freetype wget http://download.savannah.gnu.org/releases/freetype/freetype-2.9.tar.gz tar zxvf freetype-2.9.tar.gz cd freetype-2.9/ ./configure --prefix=/usr/local/freetype make sudo make install #编译安装SDL_ttf git clone https://gitee.com/tjourney/SDL_ttf.git -b SDL2 cd SDL_ttf mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Release -DFREETYPE_INCLUDE_DIRS=/usr/local/freetype/include/freetype2 -DFREETYPE_LIBRARY=/usr/local/freetype/lib/libfreetype.so cmake --build . --config Release --parallel #CMake >= 3.15 sudo cmake --install . --config Release #安装opus https://ftp.osuosl.org/pub/xiph/releases/opus/opus-1.5.2.tar.gz 解压 cd opus-1.5.2 mkdir build cd build #sudo apt-get install libopus-dev ../configure make sudo make install #编译安装libxmp git clone https://gitee.com/libsdl-org/libxmp.git cd libxmp mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Release cmake --build . --config Release --parallel sudo cmake --install . --config Release #安装glib2 sudo apt-get install libglib2.0-dev #编译安装fluidsynth git clone https://gitee.com/openkylin/fluidsynth.git cd fluidsynth mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Release cmake --build . --config Release --parallel sudo cmake --install . --config Release #编译安装wavpack git clone https://gitee.com/openkylin/wavpack.git cd wavpack mkdir build cd build #cmake .. -DCMAKE_BUILD_TYPE=Release #cmake --build . --config Release --parallel #sudo cmake --install . --config Release ../configure make sudo make install #编译安装SDL_mixer git clone https://gitee.com/tjourney/SDL_mixer.git -b SDL2 cd SDL_mixer mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Release -DOpusFile_INCLUDE_PATH=/usr/local/include -DOpusFile_LIBRARY=/usr/local/lib/libopus.so -Dlibxmp_LIBRARY=/usr/local/lib/libxmp.so -Dlibxmp_INCLUDE_PATH=/usr/local/include -DFluidSynth_LIBRARY=/usr/local/lib/libfluidsynth.so -DFluidSynth_INCLUDE_PATH=/usr/local/include/ -Dwavpack_LIBRARY=/usr/local/lib/libwavpack.so -Dwavpack_INCLUDE_PATH=/usr/local/include/wavpack -DSDL2MIXER_WAVPACK=OFF -DSDL2MIXER_OPUS=OFF cmake --build . --config Release --parallel #CMake >= 3.15 sudo cmake --install . --config Release 问题:程序不显示窗口 #安装opengl sudo aptitude install build-essential sudo aptitude install build-essential libgl1-mesa-dev sudo aptitude install libglew-dev libsdl2-dev libsdl2-image-dev libglm-dev libfreetype6-dev sudo aptitude install libglfw3-dev libglfw3 #### 使用说明 1. sdl-tutorial-cn是基于windows的版本,使用SDL-devel-1.2.15; https://www.libsdl.org/release/SDL-devel-1.2.15-mingw32.tar.gz https://www.libsdl.org/projects/SDL_image/release-1.2.html 2. http://wiki.libsdl.org/Tutorials https://www.parallelrealities.co.uk/tutorials/ 使用 SDL 2.0 构建 3 个完整游戏的教程 https://github.com/libsdl-org/SDL/tree/release-2.0.22 http://www.libsdl.org/index.php 3. xxxx #### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request #### 特技 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md 2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) 6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)