Skip to content

Commit a3c5a40

Browse files
committed
use glm
1 parent c60c1b4 commit a3c5a40

File tree

260 files changed

+5883
-8253
lines changed

Some content is hidden

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

260 files changed

+5883
-8253
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
@@ -1112,8 +1112,6 @@
11121112
0305D5F0166C9DAE00557FC4 /* TextUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextUtils.h; sourceTree = "<group>"; };
11131113
0305D5F2166C9DAE00557FC4 /* TimeKeeper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TimeKeeper.h; sourceTree = "<group>"; };
11141114
0305D5F4166C9DAE00557FC4 /* TriWallSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TriWallSceneNode.h; sourceTree = "<group>"; };
1115-
0305D5F5166C9DAE00557FC4 /* vectors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vectors.h; sourceTree = "<group>"; };
1116-
0305D5F6166C9DAE00557FC4 /* vectors_old.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vectors_old.h; sourceTree = "<group>"; };
11171115
0305D5F7166C9DAE00557FC4 /* version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = version.h; sourceTree = "<group>"; };
11181116
0305D5F8166C9DAE00557FC4 /* ViewFrustum.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewFrustum.h; sourceTree = "<group>"; };
11191117
0305D5FA166C9DAE00557FC4 /* VotingBooth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VotingBooth.h; sourceTree = "<group>"; };
@@ -2372,8 +2370,6 @@
23722370
0305D5F0166C9DAE00557FC4 /* TextUtils.h */,
23732371
0305D5F2166C9DAE00557FC4 /* TimeKeeper.h */,
23742372
0305D5F4166C9DAE00557FC4 /* TriWallSceneNode.h */,
2375-
0305D5F5166C9DAE00557FC4 /* vectors.h */,
2376-
0305D5F6166C9DAE00557FC4 /* vectors_old.h */,
23772373
0305D5F7166C9DAE00557FC4 /* version.h */,
23782374
0305D5F8166C9DAE00557FC4 /* ViewFrustum.h */,
23792375
0305D5FA166C9DAE00557FC4 /* VotingBooth.h */,

configure.ac

+4
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,10 @@ AC_CHECK_HEADERS( \
418418
cstdio \
419419
cstring
420420
)
421+
AC_CHECK_HEADERS(
422+
[glm/glm.hpp],
423+
,
424+
[AC_MSG_ERROR([glm (from https://glm.g-truc.net) is needed])])
421425
AC_LANG(C)
422426
AC_CHECK_HEADERS( \
423427
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

+17-30
Original file line numberDiff line numberDiff line change
@@ -46,46 +46,33 @@ 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],
5353
int physics, bool bounce, bool drive, bool shoot, bool ricochet);
5454
~ArcObstacle();
5555

56-
Obstacle* copyWithTransform(const MeshTransform&) const;
56+
Obstacle* copyWithTransform(const MeshTransform&) const override;
5757

5858
MeshObstacle* makeMesh();
5959

60-
const char* getType() const;
60+
const char* getType() const override;
6161
static const char* getClassName(); // const
62-
bool isValid() const;
63-
bool isFlatTop() const;
64-
65-
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;
83-
84-
int packSize() const;
85-
void *pack(void*) const;
86-
const void *unpack(const void*);
87-
88-
void print(std::ostream& out, const std::string& indent) const;
62+
bool isValid() const override;
63+
bool isFlatTop() const override;
64+
65+
float intersect(const Ray&) const override;
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;
70+
71+
int packSize() const override;
72+
void *pack(void*) const override;
73+
const void *unpack(const void*) override;
74+
75+
void print(std::ostream& out, const std::string& indent) const override;
8976

9077
private:
9178
void finalize();

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

+16-15
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,31 +27,31 @@ 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

33-
Obstacle* copyWithTransform(const MeshTransform&) const;
34+
Obstacle* copyWithTransform(const MeshTransform&) const override;
3435

35-
const char* getType() const;
36+
const char* getType() const override;
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

48-
int packSize() const;
49-
void *pack(void*) const;
50-
const void *unpack(const void*);
49+
int packSize() const override;
50+
void *pack(void*) const override;
51+
const void *unpack(const void*) override;
5152

52-
void print(std::ostream& out, const std::string& indent) const;
53-
void printOBJ(std::ostream& out, const std::string& indent) const;
53+
void print(std::ostream& out, const std::string& indent) const override;
54+
void printOBJ(std::ostream& out, const std::string& indent) const override;
5455

5556
std::string userTextures[2];
5657

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&) override;
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;

0 commit comments

Comments
 (0)