OverEngine 开源游戏引擎使用教程
OverEngine Tiny little game engine 项目地址: https://gitcode.com/gh_mirrors/ov/OverEngine
1. 项目目录结构及介绍
OverEngine/
├── CMakeLists.txt
├── LICENSE
├── README.md
├── assets/
├── build/
├── include/
│ ├── OverEngine/
│ │ ├── Core/
│ │ ├── Renderer/
│ │ ├── ...
├── src/
│ ├── Main.cpp
│ ├── ...
├── tools/
│ ├── GenerateProjectFiles.bat
│ ├── ...
└── ...
目录结构介绍
- CMakeLists.txt: 项目的 CMake 配置文件,用于构建项目。
- LICENSE: 项目的开源许可证文件,本项目使用 MIT 许可证。
- README.md: 项目的介绍文件,包含项目的基本信息和使用说明。
- assets/: 存放游戏资源文件,如图片、音频等。
- build/: 构建生成的文件目录,包含编译后的可执行文件和中间文件。
- include/: 包含项目的头文件,按模块组织。
- src/: 包含项目的源代码文件,如
Main.cpp
等。 - tools/: 包含项目使用的工具脚本,如
GenerateProjectFiles.bat
。
2. 项目启动文件介绍
Main.cpp
Main.cpp
是项目的启动文件,负责初始化引擎并启动游戏主循环。以下是 Main.cpp
的基本结构:
#include "OverEngine/Core/Application.h"
int main(int argc, char** argv) {
// 创建应用实例
OverEngine::Application* app = new OverEngine::Application();
// 运行应用
app->Run();
// 销毁应用实例
delete app;
return 0;
}
启动流程
- 创建应用实例: 通过
new OverEngine::Application()
创建应用实例。 - 运行应用: 调用
app->Run()
启动游戏主循环。 - 销毁应用实例: 在应用结束时,通过
delete app
销毁应用实例。
3. 项目的配置文件介绍
CMakeLists.txt
CMakeLists.txt
是项目的 CMake 配置文件,用于配置项目的构建过程。以下是 CMakeLists.txt
的基本内容:
cmake_minimum_required(VERSION 3.10)
project(OverEngine)
set(CMAKE_CXX_STANDARD 17)
# 添加源文件
file(GLOB_RECURSE SOURCES src/*.cpp)
# 添加头文件目录
include_directories(include)
# 添加可执行文件
add_executable(OverEngine ${SOURCES})
# 链接库
target_link_libraries(OverEngine PRIVATE glfw glad glm stb_image)
配置文件说明
- cmake_minimum_required: 指定 CMake 的最低版本要求。
- project: 定义项目名称。
- set(CMAKE_CXX_STANDARD 17): 设置 C++ 标准为 C++17。
- file(GLOB_RECURSE SOURCES src/*.cpp): 递归获取所有源文件。
- include_directories(include): 添加头文件目录。
- add_executable(OverEngine ${SOURCES}): 添加可执行文件。
- target_link_libraries: 链接所需的库,如
glfw
,glad
,glm
,stb_image
等。
通过以上配置,可以生成适用于 Windows 和 Linux 平台的项目文件,并进行编译和运行。
OverEngine Tiny little game engine 项目地址: https://gitcode.com/gh_mirrors/ov/OverEngine
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考