Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use glm #334

Open
wants to merge 2 commits into
base: 2.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion MSVC/build/ogl.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@
</Lib>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\src\ogl\OpenGLAPI.cxx" />
<ClCompile Include="..\..\src\ogl\OpenGLFramebuffer.cxx" />
<ClCompile Include="..\..\src\ogl\OpenGLGState.cxx">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
Expand Down Expand Up @@ -279,6 +280,7 @@
<ItemGroup>
<ClInclude Include="..\..\include\bzfgl.h" />
<ClInclude Include="..\..\include\glext.h" />
<ClInclude Include="..\..\include\OpenGLAPI.h" />
<ClInclude Include="..\..\include\OpenGLFramebuffer.h" />
<ClInclude Include="..\..\include\OpenGLGState.h" />
<ClInclude Include="..\..\include\OpenGLLight.h" />
Expand All @@ -290,4 +292,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
8 changes: 7 additions & 1 deletion MSVC/build/ogl.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
<ClCompile Include="..\..\src\ogl\RenderNode.cxx">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ogl\OpenGLAPI.cxx">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ogl\OpenGLFramebuffer.cxx">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down Expand Up @@ -48,6 +51,9 @@
<ClInclude Include="..\..\include\glext.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\include\OpenGLAPI.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\include\OpenGLFramebuffer.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand All @@ -60,4 +66,4 @@
<UniqueIdentifier>{8b1c786a-fe0a-4a9f-8809-6572c90a8d13}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>
</Project>
4 changes: 0 additions & 4 deletions Xcode/BZFlag.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1111,8 +1111,6 @@
0305D5F0166C9DAE00557FC4 /* TextUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextUtils.h; sourceTree = "<group>"; };
0305D5F2166C9DAE00557FC4 /* TimeKeeper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TimeKeeper.h; sourceTree = "<group>"; };
0305D5F4166C9DAE00557FC4 /* TriWallSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TriWallSceneNode.h; sourceTree = "<group>"; };
0305D5F5166C9DAE00557FC4 /* vectors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vectors.h; sourceTree = "<group>"; };
0305D5F6166C9DAE00557FC4 /* vectors_old.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vectors_old.h; sourceTree = "<group>"; };
0305D5F7166C9DAE00557FC4 /* version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = version.h; sourceTree = "<group>"; };
0305D5F8166C9DAE00557FC4 /* ViewFrustum.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewFrustum.h; sourceTree = "<group>"; };
0305D5FA166C9DAE00557FC4 /* VotingBooth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VotingBooth.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2368,8 +2366,6 @@
0305D5F0166C9DAE00557FC4 /* TextUtils.h */,
0305D5F2166C9DAE00557FC4 /* TimeKeeper.h */,
0305D5F4166C9DAE00557FC4 /* TriWallSceneNode.h */,
0305D5F5166C9DAE00557FC4 /* vectors.h */,
0305D5F6166C9DAE00557FC4 /* vectors_old.h */,
0305D5F7166C9DAE00557FC4 /* version.h */,
0305D5F8166C9DAE00557FC4 /* ViewFrustum.h */,
0305D5FA166C9DAE00557FC4 /* VotingBooth.h */,
Expand Down
11 changes: 11 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ if test x$enable_robots != xno; then
AC_DEFINE(ROBOT, 1, [Enabling Robots])
fi

AC_ARG_ENABLE(avx2, [ --enable-avx2 turn on simd])

# debugging and profiling
AC_ARG_ENABLE(debug, [ --enable-debug turn on debugging])
AC_ARG_ENABLE(profiling, [ --enable-profiling turn on profiling])
Expand Down Expand Up @@ -412,6 +414,10 @@ AC_CHECK_HEADERS( \
cstdio \
cstring
)
AC_CHECK_HEADERS(
[glm/glm.hpp],
,
[AC_MSG_ERROR([glm (from https://glm.g-truc.net) is needed])])
AC_LANG(C)
AC_CHECK_HEADERS( \
SDL2/SDL.h \
Expand All @@ -432,6 +438,8 @@ AC_CHECK_HEADERS( \
values.h \
)

AC_DEFINE(GLM_FORCE_AVX2, 1, [ Enable avx2 if available])

if test "x$enable_UPnP" = "xyes"; then
AC_CHECK_HEADERS(
[miniupnpc/miniupnpc.h],
Expand Down Expand Up @@ -687,6 +695,9 @@ case $host_os in
pc)
FLAGS=-mtune=native
CONF_CFLAGS="$CONF_CFLAGS $FLAGS";
if test x$enable_avx2 = xyes ; then
CONF_CXXFLAGS="$CONF_CXXFLAGS -mavx2";
fi
CONF_CXXFLAGS="$CONF_CXXFLAGS $FLAGS";
CONF_CXXFLAGS="$CONF_CXXFLAGS -fsigned-char";;
ppc)
Expand Down
3 changes: 2 additions & 1 deletion include/AnsiCodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

// System headers
#include <string>
#include <glm/vec3.hpp>

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

inline std::string rgbToAnsi(const float* color)
inline std::string rgbToAnsi(const glm::vec3 &color)
{
return TextUtils::format("%s;%u;%u;%um",
ANSI_STR_FG_RGB,
Expand Down
47 changes: 17 additions & 30 deletions include/ArcObstacle.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,46 +46,33 @@ class ArcObstacle : public Obstacle

ArcObstacle();
ArcObstacle(const MeshTransform& transform,
const float* _pos, const float* _size,
const glm::vec3 &_pos, const glm::vec3 &_size,
float _rotation, float _angle, float _ratio,
const float _texsize[4], bool _useNormals,
int _divisions, const BzMaterial* mats[MaterialCount],
int physics, bool bounce, bool drive, bool shoot, bool ricochet);
~ArcObstacle();

Obstacle* copyWithTransform(const MeshTransform&) const;
Obstacle* copyWithTransform(const MeshTransform&) const override;

MeshObstacle* makeMesh();

const char* getType() const;
const char* getType() const override;
static const char* getClassName(); // const
bool isValid() const;
bool isFlatTop() const;

float intersect(const Ray&) const;
void getNormal(const float* p, float* n) const;
void get3DNormal(const float* p, float* n) const;

bool inCylinder(const float* p, float radius, float height) const;
bool inBox(const float* p, float angle,
float halfWidth, float halfBreadth, float height) const;
bool inMovingBox(const float* oldP, float oldAngle,
const float *newP, float newAngle,
float halfWidth, float halfBreadth, float height) const;
bool isCrossing(const float* p, float angle,
float halfWidth, float halfBreadth, float height,
float* plane) const;

bool getHitNormal(const float* pos1, float azimuth1,
const float* pos2, float azimuth2,
float halfWidth, float halfBreadth,
float height, float* normal) const;

int packSize() const;
void *pack(void*) const;
const void *unpack(const void*);

void print(std::ostream& out, const std::string& indent) const;
bool isValid() const override;
bool isFlatTop() const override;

float intersect(const Ray&) const override;
void getNormal(const glm::vec3 &p, glm::vec3 &n) const override;
void get3DNormal(const glm::vec3 &p, glm::vec3 &n) const override;

bool inCylinder(const glm::vec3 &p, float radius, float height) const override;

int packSize() const override;
void *pack(void*) const override;
const void *unpack(const void*) override;

void print(std::ostream& out, const std::string& indent) const override;

private:
void finalize();
Expand Down
3 changes: 2 additions & 1 deletion include/BSPSceneDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

// system headers
#include <vector>
#include <glm/vec3.hpp>

// common implementation headers
#include "bzfgl.h"
Expand Down Expand Up @@ -83,7 +84,7 @@ class BSPSceneDatabase : public SceneDatabase
Node* root;
int depth;
// the following members avoid passing parameters around
GLfloat eye[3];
glm::vec3 eye;
SceneRenderer* renderer;
const ViewFrustum* frustum;

Expand Down
31 changes: 16 additions & 15 deletions include/BaseBuilding.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef BZF_BASE_BUILDING_H
#define BZF_BASE_BUILDING_H

// Inherits from
#include "BoxBuilding.h"

class BaseBuilding : public BoxBuilding
Expand All @@ -26,31 +27,31 @@ class BaseBuilding : public BoxBuilding

public:
BaseBuilding();
BaseBuilding(const float *pos, float rotation,
const float *size, int _team, bool ricochet);
BaseBuilding(const glm::vec3 &pos, float rotation,
const glm::vec3 &size, int _team, bool ricochet);
~BaseBuilding();

Obstacle* copyWithTransform(const MeshTransform&) const;
Obstacle* copyWithTransform(const MeshTransform&) const override;

const char* getType() const;
const char* getType() const override;
static const char* getClassName(); // const

bool inCylinder(const float* p, float radius, float height) const;
bool inMovingBox(const float* oldP, float oldAngle,
const float *newP, float newAngle,
float halfWidth, float halfBreadth, float height) const;
bool isCrossing(const float* p, float angle,
bool inCylinder(const glm::vec3 &p, float radius, float height) const override;
bool inMovingBox(const glm::vec3 &oldP, float oldAngle,
const glm::vec3 &newP, float newAngle,
float halfWidth, float halfBreadth, float height) const override;
bool isCrossing(const glm::vec3 &p, float angle,
float halfWidth, float halfBreadth, float height,
float* plane) const;
glm::vec4 *plane) const override;

int getTeam() const;

int packSize() const;
void *pack(void*) const;
const void *unpack(const void*);
int packSize() const override;
void *pack(void*) const override;
const void *unpack(const void*) override;

void print(std::ostream& out, const std::string& indent) const;
void printOBJ(std::ostream& out, const std::string& indent) const;
void print(std::ostream& out, const std::string& indent) const override;
void printOBJ(std::ostream& out, const std::string& indent) const override;

std::string userTextures[2];

Expand Down
10 changes: 5 additions & 5 deletions include/BillboardSceneNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
class BillboardSceneNode : public SceneNode
{
public:
BillboardSceneNode(const GLfloat pos[3]);
BillboardSceneNode(const glm::vec3 &pos);
~BillboardSceneNode();

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

void move(const GLfloat pos[3]);
void move(const glm::vec3 &pos);
void setAngle(GLfloat);
void addLight(SceneRenderer&);

Expand All @@ -68,7 +68,7 @@ class BillboardSceneNode : public SceneNode
~BillboardRenderNode();
void setColor(const GLfloat* rgba);
void render() override;
const GLfloat* getPosition() const override;
const glm::vec3 &getPosition() const override;
void setFrame(float u, float v);
void setFrameSize(float du, float dv);
private:
Expand All @@ -90,9 +90,9 @@ class BillboardSceneNode : public SceneNode
bool lightSource;
bool groundLight;
float width, height;
GLfloat color[4];
glm::vec4 color;
GLfloat angle;
GLfloat lightColor[3];
glm::vec3 lightColor;
GLfloat lightScale;
float lightCutoffTime;
int cu, cv;
Expand Down
49 changes: 21 additions & 28 deletions include/BoltSceneNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,31 @@
// Inherits from
#include "SceneNode.h"

// System headers
#include <glm/vec4.hpp>

// Common headers
#include "OpenGLLight.h"

class BoltSceneNode : public SceneNode
{
public:
BoltSceneNode(const GLfloat pos[3], const GLfloat vel[3], bool super);
BoltSceneNode(const glm::vec3 &pos, const glm::vec3 &vel, bool super);
~BoltSceneNode();

void setFlares(bool);
void setSize(float radius);
void setColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a = 1.0f);
void setTextureColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a = 1.0f);
void setColor(const GLfloat* rgb);
void setTeamColor(const GLfloat* rgb);
void setColor(const glm::vec3 &rgb);
void setTeamColor(const glm::vec3 &rgb);
void setTexture(const int);
void setTextureAnimation(int cu, int cv);

bool getColorblind() const;
void setColorblind(bool);

bool getInvisible() const
{
return invisible;
}
void setInvisible(bool _invisible)
{
invisible = _invisible;
}

void move(const GLfloat pos[3], const GLfloat forward[3]);
void move(const glm::vec3 &pos, const glm::vec3 &forward);
void addLight(SceneRenderer&) override;

void notifyStyleChange() override;
Expand All @@ -64,10 +58,10 @@ class BoltSceneNode : public SceneNode
public:
BoltRenderNode(const BoltSceneNode*);
~BoltRenderNode();
void setColor(const GLfloat* rgba);
void setTextureColor(const GLfloat* rgba);
void setColor(const glm::vec4 &rgba);
void setTextureColor(const glm::vec4 &rgba);
void render() override;
const GLfloat* getPosition() const override;
const glm::vec3 &getPosition() const override;
void setAnimation(int cu, int cv);

void renderGeoBolt();
Expand All @@ -78,19 +72,18 @@ class BoltSceneNode : public SceneNode
const BoltSceneNode* sceneNode;
int u, v, cu, cv;
GLfloat du, dv;
GLfloat mainColor[4];
GLfloat innerColor[4];
GLfloat outerColor[4];
GLfloat coronaColor[4];
GLfloat flareColor[4];
GLfloat textureColor[4];
glm::vec4 mainColor;
glm::vec4 innerColor;
glm::vec4 outerColor;
glm::vec4 coronaColor;
glm::vec4 flareColor;
glm::vec4 textureColor;
int numFlares;
float theta[6];
float phi[6];

static GLfloat core[9][2];
static GLfloat corona[8][2];
static const GLfloat ring[8][2];
static glm::vec2 core[9];
static const glm::vec2 corona[8];
static const GLfloat CoreFraction;
static const GLfloat FlareSize;
static const GLfloat FlareSpread;
Expand All @@ -103,9 +96,9 @@ class BoltSceneNode : public SceneNode
bool texturing;
bool colorblind;
float size;
float velocity[3];
GLfloat color[4];
fvec4 teamColor;
glm::vec4 color;
glm::vec4 teamColor;
glm::vec3 velocity;
OpenGLLight light;
OpenGLGState gstate;
OpenGLGState colorblindGState;
Expand Down
Loading
Loading