Skip to content

Commit 5fc0b6d

Browse files
committed
use glm
1 parent baed08d commit 5fc0b6d

File tree

248 files changed

+5395
-7524
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

248 files changed

+5395
-7524
lines changed

MSVC/build/ogl.vcxproj

+3-1
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@
193193
</Lib>
194194
</ItemDefinitionGroup>
195195
<ItemGroup>
196+
<ClCompile Include="..\..\src\ogl\OpenGLAPI.cxx" />
196197
<ClCompile Include="..\..\src\ogl\OpenGLFramebuffer.cxx" />
197198
<ClCompile Include="..\..\src\ogl\OpenGLGState.cxx">
198199
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
@@ -279,6 +280,7 @@
279280
<ItemGroup>
280281
<ClInclude Include="..\..\include\bzfgl.h" />
281282
<ClInclude Include="..\..\include\glext.h" />
283+
<ClInclude Include="..\..\include\OpenGLAPI.h" />
282284
<ClInclude Include="..\..\include\OpenGLFramebuffer.h" />
283285
<ClInclude Include="..\..\include\OpenGLGState.h" />
284286
<ClInclude Include="..\..\include\OpenGLLight.h" />
@@ -290,4 +292,4 @@
290292
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
291293
<ImportGroup Label="ExtensionTargets">
292294
</ImportGroup>
293-
</Project>
295+
</Project>

MSVC/build/ogl.vcxproj.filters

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
<ClCompile Include="..\..\src\ogl\RenderNode.cxx">
2020
<Filter>Source Files</Filter>
2121
</ClCompile>
22+
<ClCompile Include="..\..\src\ogl\OpenGLAPI.cxx">
23+
<Filter>Source Files</Filter>
24+
</ClCompile>
2225
<ClCompile Include="..\..\src\ogl\OpenGLFramebuffer.cxx">
2326
<Filter>Source Files</Filter>
2427
</ClCompile>
@@ -48,6 +51,9 @@
4851
<ClInclude Include="..\..\include\glext.h">
4952
<Filter>Header Files</Filter>
5053
</ClInclude>
54+
<ClInclude Include="..\..\include\OpenGLAPI.h">
55+
<Filter>Header Files</Filter>
56+
</ClInclude>
5157
<ClInclude Include="..\..\include\OpenGLFramebuffer.h">
5258
<Filter>Header Files</Filter>
5359
</ClInclude>
@@ -60,4 +66,4 @@
6066
<UniqueIdentifier>{8b1c786a-fe0a-4a9f-8809-6572c90a8d13}</UniqueIdentifier>
6167
</Filter>
6268
</ItemGroup>
63-
</Project>
69+
</Project>

Xcode/BZFlag.xcodeproj/project.pbxproj

-4
Original file line numberDiff line numberDiff line change
@@ -1110,8 +1110,6 @@
11101110
0305D5F0166C9DAE00557FC4 /* TextUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextUtils.h; sourceTree = "<group>"; };
11111111
0305D5F2166C9DAE00557FC4 /* TimeKeeper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TimeKeeper.h; sourceTree = "<group>"; };
11121112
0305D5F4166C9DAE00557FC4 /* TriWallSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TriWallSceneNode.h; sourceTree = "<group>"; };
1113-
0305D5F5166C9DAE00557FC4 /* vectors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vectors.h; sourceTree = "<group>"; };
1114-
0305D5F6166C9DAE00557FC4 /* vectors_old.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vectors_old.h; sourceTree = "<group>"; };
11151113
0305D5F7166C9DAE00557FC4 /* version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = version.h; sourceTree = "<group>"; };
11161114
0305D5F8166C9DAE00557FC4 /* ViewFrustum.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewFrustum.h; sourceTree = "<group>"; };
11171115
0305D5FA166C9DAE00557FC4 /* VotingBooth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VotingBooth.h; sourceTree = "<group>"; };
@@ -2364,8 +2362,6 @@
23642362
0305D5F0166C9DAE00557FC4 /* TextUtils.h */,
23652363
0305D5F2166C9DAE00557FC4 /* TimeKeeper.h */,
23662364
0305D5F4166C9DAE00557FC4 /* TriWallSceneNode.h */,
2367-
0305D5F5166C9DAE00557FC4 /* vectors.h */,
2368-
0305D5F6166C9DAE00557FC4 /* vectors_old.h */,
23692365
0305D5F7166C9DAE00557FC4 /* version.h */,
23702366
0305D5F8166C9DAE00557FC4 /* ViewFrustum.h */,
23712367
0305D5FA166C9DAE00557FC4 /* VotingBooth.h */,

configure.ac

+4
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,10 @@ AC_CHECK_HEADERS( \
414414
cstdio \
415415
cstring
416416
)
417+
AC_CHECK_HEADERS(
418+
[glm/glm.hpp],
419+
,
420+
[AC_MSG_ERROR([glm (from https://glm.g-truc.net) is needed])])
417421
AC_LANG(C)
418422
AC_CHECK_HEADERS( \
419423
SDL2/SDL.h \

include/AnsiCodes.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
// System headers
2020
#include <string>
21+
#include <glm/vec3.hpp>
2122

2223
// Common headers
2324
#include "TextUtils.h"
@@ -105,7 +106,7 @@ static const std::string ColorStrings[17] =
105106
ANSI_STR_NO_UNDERLINE // 16 No Underlining
106107
};
107108

108-
inline std::string rgbToAnsi(const float* color)
109+
inline std::string rgbToAnsi(const glm::vec3 &color)
109110
{
110111
return TextUtils::format("%s;%u;%u;%um",
111112
ANSI_STR_FG_RGB,

include/ArcObstacle.h

+5-18
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ArcObstacle : public Obstacle
4646

4747
ArcObstacle();
4848
ArcObstacle(const MeshTransform& transform,
49-
const float* _pos, const float* _size,
49+
const glm::vec3 &_pos, const glm::vec3 &_size,
5050
float _rotation, float _angle, float _ratio,
5151
const float _texsize[4], bool _useNormals,
5252
int _divisions, const BzMaterial* mats[MaterialCount],
@@ -63,23 +63,10 @@ class ArcObstacle : public Obstacle
6363
bool isFlatTop() const;
6464

6565
float intersect(const Ray&) const;
66-
void getNormal(const float* p, float* n) const;
67-
void get3DNormal(const float* p, float* n) const;
68-
69-
bool inCylinder(const float* p, float radius, float height) const;
70-
bool inBox(const float* p, float angle,
71-
float halfWidth, float halfBreadth, float height) const;
72-
bool inMovingBox(const float* oldP, float oldAngle,
73-
const float *newP, float newAngle,
74-
float halfWidth, float halfBreadth, float height) const;
75-
bool isCrossing(const float* p, float angle,
76-
float halfWidth, float halfBreadth, float height,
77-
float* plane) const;
78-
79-
bool getHitNormal(const float* pos1, float azimuth1,
80-
const float* pos2, float azimuth2,
81-
float halfWidth, float halfBreadth,
82-
float height, float* normal) const;
66+
void getNormal(const glm::vec3 &p, glm::vec3 &n) const override;
67+
void get3DNormal(const glm::vec3 &p, glm::vec3 &n) const override;
68+
69+
bool inCylinder(const glm::vec3 &p, float radius, float height) const override;
8370

8471
int packSize() const;
8572
void *pack(void*) const;

include/BSPSceneDatabase.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
// system headers
2424
#include <vector>
25+
#include <glm/vec3.hpp>
2526

2627
// common implementation headers
2728
#include "bzfgl.h"
@@ -83,7 +84,7 @@ class BSPSceneDatabase : public SceneDatabase
8384
Node* root;
8485
int depth;
8586
// the following members avoid passing parameters around
86-
GLfloat eye[3];
87+
glm::vec3 eye;
8788
SceneRenderer* renderer;
8889
const ViewFrustum* frustum;
8990

include/BaseBuilding.h

+9-8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#ifndef BZF_BASE_BUILDING_H
1818
#define BZF_BASE_BUILDING_H
1919

20+
// Inherits from
2021
#include "BoxBuilding.h"
2122

2223
class BaseBuilding : public BoxBuilding
@@ -26,22 +27,22 @@ class BaseBuilding : public BoxBuilding
2627

2728
public:
2829
BaseBuilding();
29-
BaseBuilding(const float *pos, float rotation,
30-
const float *size, int _team, bool ricochet);
30+
BaseBuilding(const glm::vec3 &pos, float rotation,
31+
const glm::vec3 &size, int _team, bool ricochet);
3132
~BaseBuilding();
3233

3334
Obstacle* copyWithTransform(const MeshTransform&) const;
3435

3536
const char* getType() const;
3637
static const char* getClassName(); // const
3738

38-
bool inCylinder(const float* p, float radius, float height) const;
39-
bool inMovingBox(const float* oldP, float oldAngle,
40-
const float *newP, float newAngle,
41-
float halfWidth, float halfBreadth, float height) const;
42-
bool isCrossing(const float* p, float angle,
39+
bool inCylinder(const glm::vec3 &p, float radius, float height) const override;
40+
bool inMovingBox(const glm::vec3 &oldP, float oldAngle,
41+
const glm::vec3 &newP, float newAngle,
42+
float halfWidth, float halfBreadth, float height) const override;
43+
bool isCrossing(const glm::vec3 &p, float angle,
4344
float halfWidth, float halfBreadth, float height,
44-
float* plane) const;
45+
glm::vec4 *plane) const override;
4546

4647
int getTeam() const;
4748

include/BillboardSceneNode.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
class BillboardSceneNode : public SceneNode
2727
{
2828
public:
29-
BillboardSceneNode(const GLfloat pos[3]);
29+
BillboardSceneNode(const glm::vec3 &pos);
3030
~BillboardSceneNode();
3131

3232
virtual BillboardSceneNode* copy() const;
@@ -53,7 +53,7 @@ class BillboardSceneNode : public SceneNode
5353
void setTexture(const int);
5454
void setTextureAnimation(int cu, int cv);
5555

56-
void move(const GLfloat pos[3]);
56+
void move(const glm::vec3 &pos);
5757
void setAngle(GLfloat);
5858
void addLight(SceneRenderer&);
5959

@@ -68,7 +68,7 @@ class BillboardSceneNode : public SceneNode
6868
~BillboardRenderNode();
6969
void setColor(const GLfloat* rgba);
7070
void render() override;
71-
const GLfloat* getPosition() const override;
71+
const glm::vec3 &getPosition() const override;
7272
void setFrame(float u, float v);
7373
void setFrameSize(float du, float dv);
7474
private:
@@ -90,9 +90,9 @@ class BillboardSceneNode : public SceneNode
9090
bool lightSource;
9191
bool groundLight;
9292
float width, height;
93-
GLfloat color[4];
93+
glm::vec4 color;
9494
GLfloat angle;
95-
GLfloat lightColor[3];
95+
glm::vec3 lightColor;
9696
GLfloat lightScale;
9797
float lightCutoffTime;
9898
int cu, cv;

include/BoltSceneNode.h

+21-28
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,31 @@
2020
// Inherits from
2121
#include "SceneNode.h"
2222

23+
// System headers
24+
#include <glm/vec4.hpp>
25+
2326
// Common headers
2427
#include "OpenGLLight.h"
2528

2629
class BoltSceneNode : public SceneNode
2730
{
2831
public:
29-
BoltSceneNode(const GLfloat pos[3], const GLfloat vel[3], bool super);
32+
BoltSceneNode(const glm::vec3 &pos, const glm::vec3 &vel, bool super);
3033
~BoltSceneNode();
3134

3235
void setFlares(bool);
3336
void setSize(float radius);
3437
void setColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a = 1.0f);
3538
void setTextureColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a = 1.0f);
36-
void setColor(const GLfloat* rgb);
37-
void setTeamColor(const GLfloat* rgb);
39+
void setColor(const glm::vec3 &rgb);
40+
void setTeamColor(const glm::vec3 &rgb);
3841
void setTexture(const int);
3942
void setTextureAnimation(int cu, int cv);
4043

4144
bool getColorblind() const;
4245
void setColorblind(bool);
4346

44-
bool getInvisible() const
45-
{
46-
return invisible;
47-
}
48-
void setInvisible(bool _invisible)
49-
{
50-
invisible = _invisible;
51-
}
52-
53-
void move(const GLfloat pos[3], const GLfloat forward[3]);
47+
void move(const glm::vec3 &pos, const glm::vec3 &forward);
5448
void addLight(SceneRenderer&);
5549

5650
void notifyStyleChange() override;
@@ -64,10 +58,10 @@ class BoltSceneNode : public SceneNode
6458
public:
6559
BoltRenderNode(const BoltSceneNode*);
6660
~BoltRenderNode();
67-
void setColor(const GLfloat* rgba);
68-
void setTextureColor(const GLfloat* rgba);
61+
void setColor(const glm::vec4 &rgba);
62+
void setTextureColor(const glm::vec4 &rgba);
6963
void render() override;
70-
const GLfloat* getPosition() const override;
64+
const glm::vec3 &getPosition() const override;
7165
void setAnimation(int cu, int cv);
7266

7367
void renderGeoBolt();
@@ -78,19 +72,18 @@ class BoltSceneNode : public SceneNode
7872
const BoltSceneNode* sceneNode;
7973
int u, v, cu, cv;
8074
GLfloat du, dv;
81-
GLfloat mainColor[4];
82-
GLfloat innerColor[4];
83-
GLfloat outerColor[4];
84-
GLfloat coronaColor[4];
85-
GLfloat flareColor[4];
86-
GLfloat textureColor[4];
75+
glm::vec4 mainColor;
76+
glm::vec4 innerColor;
77+
glm::vec4 outerColor;
78+
glm::vec4 coronaColor;
79+
glm::vec4 flareColor;
80+
glm::vec4 textureColor;
8781
int numFlares;
8882
float theta[6];
8983
float phi[6];
9084

91-
static GLfloat core[9][2];
92-
static GLfloat corona[8][2];
93-
static const GLfloat ring[8][2];
85+
static glm::vec2 core[9];
86+
static const glm::vec2 corona[8];
9487
static const GLfloat CoreFraction;
9588
static const GLfloat FlareSize;
9689
static const GLfloat FlareSpread;
@@ -103,9 +96,9 @@ class BoltSceneNode : public SceneNode
10396
bool texturing;
10497
bool colorblind;
10598
float size;
106-
float velocity[3];
107-
GLfloat color[4];
108-
fvec4 teamColor;
99+
glm::vec4 color;
100+
glm::vec4 teamColor;
101+
glm::vec3 velocity;
109102
OpenGLLight light;
110103
OpenGLGState gstate;
111104
OpenGLGState colorblindGState;

include/BoxBuilding.h

+20-17
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,18 @@
1717
#ifndef BZF_BOX_BUILDING_H
1818
#define BZF_BOX_BUILDING_H
1919

20-
#include "common.h"
21-
#include <string>
20+
// Inherits from
2221
#include "Obstacle.h"
2322

23+
// System headers
24+
#include <string>
25+
#include <glm/fwd.hpp>
26+
2427
class BoxBuilding : public Obstacle
2528
{
2629
public:
2730
BoxBuilding();
28-
BoxBuilding(const float* pos, float rotation,
31+
BoxBuilding(const glm::vec3 &pos, float rotation,
2932
float width, float breadth, float height,
3033
bool drive = false, bool shoot = false,
3134
bool ricochet = false, bool invisible = false);
@@ -39,28 +42,28 @@ class BoxBuilding : public Obstacle
3942
bool isFlatTop() const;
4043

4144
float intersect(const Ray&) const;
42-
void getNormal(const float* p, float* n) const;
43-
void get3DNormal(const float* p, float* n) const;
45+
void getNormal(const glm::vec3 &p, glm::vec3 &n) const override;
46+
void get3DNormal(const glm::vec3 &p, glm::vec3 &n) const override;
4447
inline bool isInvisible() const;
4548

46-
bool inCylinder(const float* p, float radius, float height) const;
47-
bool inBox(const float* p, float angle,
48-
float halfWidth, float halfBreadth, float height) const;
49-
bool inMovingBox(const float* oldP, float oldAngle,
50-
const float *newP, float newAngle,
51-
float halfWidth, float halfBreadth, float height) const;
52-
bool isCrossing(const float* p, float angle,
49+
bool inCylinder(const glm::vec3 &p, float radius, float height) const override;
50+
bool inBox(const glm::vec3 &p, float angle,
51+
float halfWidth, float halfBreadth, float height) const override;
52+
bool inMovingBox(const glm::vec3 &oldP, float oldAngle,
53+
const glm::vec3 &newP, float newAngle,
54+
float halfWidth, float halfBreadth, float height) const override;
55+
bool isCrossing(const glm::vec3 &p, float angle,
5356
float halfWidth, float halfBreadth, float height,
54-
float* plane) const;
57+
glm::vec4 *plane) const override;
5558

5659
bool getHitNormal(
57-
const float* pos1, float azimuth1,
58-
const float* pos2, float azimuth2,
60+
const glm::vec3 &pos1, float azimuth1,
61+
const glm::vec3 &pos2, float azimuth2,
5962
float halfWidth, float halfBreadth,
6063
float height,
61-
float* normal) const;
64+
glm::vec3 &normal) const override;
6265

63-
void getCorner(int index, float* pos) const;
66+
void getCorner(int index, glm::vec3 &pos) const;
6467

6568
int packSize() const;
6669
void *pack(void*) const;

0 commit comments

Comments
 (0)