LearnOpenTK 项目教程
1. 项目的目录结构及介绍
LearnOpenTK 项目的目录结构如下:
LearnOpenTK/
├── Chapter1/
│ ├── Chapter1.csproj
│ ├── Program.cs
│ └── ...
├── Chapter2/
│ ├── Chapter2.csproj
│ ├── Program.cs
│ └── ...
├── Common/
│ ├── Common.csproj
│ ├── Shader.cs
│ └── ...
├── .gitattributes
├── .gitignore
├── LICENSE
├── LearnOpenTK.sln
└── README.md
目录介绍:
- Chapter1/ 和 Chapter2/:包含各个章节的示例代码和项目文件。
- Common/:包含项目中使用的通用代码,如着色器管理等。
- .gitattributes 和 .gitignore:Git 配置文件。
- LICENSE:项目许可证文件。
- LearnOpenTK.sln:Visual Studio 解决方案文件。
- README.md:项目说明文件。
2. 项目的启动文件介绍
每个章节目录(如 Chapter1/
)中包含一个 Program.cs
文件,这是该章节的启动文件。例如,Chapter1/Program.cs
的内容如下:
using System;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Mathematics;
using OpenTK.Windowing.Desktop;
namespace LearnOpenTK.Chapter1
{
public class Program
{
public static void Main(string[] args)
{
var nativeWindowSettings = new NativeWindowSettings()
{
Size = new Vector2i(800, 600),
Title = "LearnOpenTK - Chapter 1"
};
using (var window = new Window(GameWindowSettings.Default, nativeWindowSettings))
{
window.Run();
}
}
}
}
启动文件介绍:
- Program.cs:定义了程序的入口点
Main
方法,创建并运行一个窗口。 - NativeWindowSettings:配置窗口的大小和标题。
- Window:继承自
GameWindow
,负责窗口的生命周期管理。
3. 项目的配置文件介绍
.gitattributes
* text=auto
*.cs text eol=crlf
.gitignore
# Visual Studio Code
.vscode/
# Visual Studio
bin/
obj/
*.suo
*.user
*.sln.docstates
# Miscellaneous
*.log
*.cache
*.dll
*.pdb
LICENSE
CC-BY-4.0 license
LearnOpenTK.sln
这是 Visual Studio 解决方案文件,包含了项目的所有项目文件和配置。
README.md
# LearnOpenTK
A port of learnopengl.com's tutorials to OpenTK and C#.
For a more comprehensive written tutorial, go to the Learn section of OpenTK.net site.
These tutorials serve as a complement to the website tutorial and contains working samples of the different chapters.
## About
A port of learnopengl.com's tutorials to OpenTK and C#.
## Resources
- [LearnOpenGL](https://learnopengl.com)
- [OpenTK](https://opentk.net)
## License
CC-BY-4.0 license
配置文件介绍:
- .gitattributes:定义了 Git 对文件的处理方式。
- .gitignore:指定 Git 忽略的文件和目录。
- LICENSE:项目许可证,采用 CC-BY-4.0 许可证。
- LearnOpenTK.sln:Visual Studio 解决方案文件。
- README.md:项目说明文件,包含项目介绍、资源链接和许可证信息。