Aurora Engine 游戏引擎入门 14(添加OpenGL的数学库)


简介

本序列由澳大利亚的一个游戏引擎爱好者整理制作,使用了前瞻的语言技术,
经常多次的修改制作,一个个小的知识点贯通,非常具有引导学习意义!

Bilibili站转载学习,非个人研究,鸣谢!

原作者Github
Bilibili直达链接
YouTube直达链接


游戏引擎离不开数学的运算,无论是图形化界面还是空间计算,都需要数学的参与;数学改变我们的生活,比如一碗米饭,一双筷子等,这都是数学在生活中的表现;

#1 OpenGL 数学库介绍
#2 使用Git以子模块的形式集成glm
#3 修改premake5.lua添加引用到项目
#4 C++中的*.hpp和 *.inl文件简介
#5 简单测试使用


#1 OpenGL 数学库介绍

glm官方网站:https://www.opengl.org/sdk/libs/GLM/

OpenGL Mathematics (GLM)
GLM is a C++ mathematics library for graphics software based on the OpenGL Shading Language (GLSL) specification.
GLM provides classes and functions designed and implemented with the same naming conventions and functionalities than GLSL so that when a programmer knows GLSL, he knows GLM as well which makes it really easy to use.
This project isn’t limited by GLSL features. An extension system, based on the GLSL extension conventions, provides extended capabilities: matrix transformations, quaternions, half-based types, random numbers, etc…
This library works perfectly with OpenGL but it also ensures interoperability with other third party libraries and SDK. It is a good candidate for software rendering (Raytracing / Rasterisation), image processing, physic simulations and any context that requires a simple and convenient mathematics library.
GLM is written as a platform independent library with no dependence and officially supports the following compilers:

Requirements

  • GCC 3.4 and higher
  • LLVM 2.3 and higher
  • Visual Studio 2005 and higher

The source code is under the MIT licence.

git源码项目地址:https://github.com/g-truc/glm


#2 使用Git以子模块的形式集成glm

  1. Tutorials GUI中的功能添加子模块
    在这里插入图片描述

或者使用git的命令行命令 git submodule add xxx.git [dir]

  1. 设置模块添加的必要参数
    在这里插入图片描述

  2. 确定添加到本地目录


#3 修改premake5.lua添加引用到项目
因为glm是纯的定义实现库,而不是一个具体的项目,所以需要全部include到项目
在这里插入图片描述在这里插入图片描述
在这里插入图片描述


#4 C++中的*.hpp和 *.inl文件简介

  1. *.hpp是*.cpp和*.h文件的合并,包实现和定义放在了一定叫做*.hpp文件
    hpp,其实质就是将.cpp的实现代码混入.h头文件当中,定义与实现都包含在同一文件,则该类的调用者只需要include该hpp文件即可,无需再将cpp加入到project中进行编译。而实现代码将直接编译到调用者的obj文件中,不再生成单独的obj,采用hpp将大幅度减少调用 project中的cpp文件数与编译次数,也不用再发布烦人的lib与dll,因此非常适合用来编写公用的开源库。
    hpp的优点不少,但是编写中有以下几点要注意:
    1、 是Header Plus Plus 的简写。
    2、与*.h类似,hpp是C++程序头文件 。
    3、是VCL专用的头文件,已预编译。
    4、是一般模板类的头文件。
    5、一般来说,.h里面只有声明,没有实现,而.hpp里声明实现都有,后者可以减少.cpp的数量。
    6、*.h里面可以有using namespace std,而*.hpp里则无。
    7、不可包含全局对象和全局函数。
    8、类之间不可循环调用。
    9、不可使用静态成员。

HPP files are C++ Header Files or header files that are written in the C++ programming language. These files are mainly categorized as developer files wherein there is a possibility to insert these files to a . CPP source code file, provided the “#include directive” is used.

  1. *.inl文件是inline函数文件
    inl 文件是内联函数的源文件。
    内联函数通常在c++头文件中实现,但有的时候内联函数较多或者出于一些别的考虑(使头文件看起来更简洁等)

Source code file used by Microsoft C++ compilers; contains inline functions that can be included into C++ programs; used for storing reusable program components. INL files can be used as an alternative to placing implementations of inline functions in hea

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值