Skip to content

Commit 1068b0b

Browse files
committed
minor refactore, fix framerate limit on windows
1 parent e1e1e9b commit 1068b0b

20 files changed

Lines changed: 132 additions & 80 deletions

src/Carnage3D.vcxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
<SubSystem>Console</SubSystem>
9797
<GenerateDebugInformation>true</GenerateDebugInformation>
9898
<AdditionalLibraryDirectories>$(SDKDIR)/glew/lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
99-
<AdditionalDependencies>opengl32.lib;glew32.lib;%(AdditionalDependencies)</AdditionalDependencies>
99+
<AdditionalDependencies>opengl32.lib;glew32.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
100100
</Link>
101101
<PostBuildEvent>
102102
<Command>copy "$(SDKDIR)\glew\lib\x86\glew32.dll" "$(TargetDir)"</Command>
@@ -130,7 +130,7 @@
130130
<OptimizeReferences>true</OptimizeReferences>
131131
<GenerateDebugInformation>true</GenerateDebugInformation>
132132
<AdditionalLibraryDirectories>$(SDKDIR)/glew/lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
133-
<AdditionalDependencies>opengl32.lib;glew32.lib;%(AdditionalDependencies)</AdditionalDependencies>
133+
<AdditionalDependencies>opengl32.lib;glew32.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
134134
</Link>
135135
<PostBuildEvent>
136136
<Command>copy "$(SDKDIR)\glew\lib\x86\glew32.dll" "$(TargetDir)"</Command>

src/CarnageGame.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ void CarnageGame::SetupScreenLayout(int playersCount)
325325
// todo: what a mess
326326
const int MaxCols = 2;
327327

328-
Rectangle fullViewport = gGraphicsDevice.mViewportRect;
328+
Rect fullViewport = gGraphicsDevice.mViewportRect;
329329

330330
int numRows = (playersCount + MaxCols - 1) / MaxCols;
331331
debug_assert(numRows > 0);

src/CommonTypes.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ extern const Color32 Color32_NULL;
9797
using Point = glm::ivec2;
9898

9999
// defines rectangle in 2d space
100-
struct Rectangle
100+
struct Rect
101101
{
102102
public:
103-
Rectangle() = default;
104-
Rectangle(int posx, int posy, int sizex, int sizey)
103+
Rect() = default;
104+
Rect(int posx, int posy, int sizex, int sizey)
105105
: x(posx)
106106
, y(posy)
107107
, w(sizex)
@@ -130,9 +130,9 @@ struct Rectangle
130130
point.y < (y + h - 1);
131131
}
132132
// get union area of two rectangles
133-
inline Rectangle GetUnion(const Rectangle& rc) const
133+
inline Rect GetUnion(const Rect& rc) const
134134
{
135-
Rectangle rcOutput;
135+
Rect rcOutput;
136136

137137
int maxx = glm::max(x + w, rc.x + rc.w);
138138
int maxy = glm::max(y + h, rc.y + rc.h);
@@ -145,9 +145,9 @@ struct Rectangle
145145
return rcOutput;
146146
}
147147
// get intersection area of two rectangles
148-
inline Rectangle GetIntersection(const Rectangle& rc) const
148+
inline Rect GetIntersection(const Rect& rc) const
149149
{
150-
Rectangle rcOutput;
150+
Rect rcOutput;
151151

152152
int minx = glm::min(x + w, rc.x + rc.w);
153153
int miny = glm::min(y + h, rc.y + rc.h);
@@ -164,12 +164,12 @@ struct Rectangle
164164
int w, h;
165165
};
166166

167-
inline bool operator == (const Rectangle& lhs, const Rectangle& rhs)
167+
inline bool operator == (const Rect& lhs, const Rect& rhs)
168168
{
169169
return (lhs.x == rhs.x) && (lhs.y == rhs.y) && (lhs.w == rhs.w) && (lhs.h == rhs.h);
170170
}
171171

172-
inline bool operator != (const Rectangle& lhs, const Rectangle& rhs)
172+
inline bool operator != (const Rect& lhs, const Rect& rhs)
173173
{
174174
return (lhs.x != rhs.x) || (lhs.y != rhs.y) || (lhs.w != rhs.w) || (lhs.h != rhs.h);
175175
}

src/GameCamera.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class GameCamera final
2020

2121
eSceneCameraMode mCurrentMode;
2222

23-
Rectangle mViewportRect;
23+
Rect mViewportRect;
2424

2525
public:
2626
GameCamera();
@@ -103,7 +103,7 @@ class GameCamera2D final
103103
public:
104104
// public for convenience, should not be modified directly
105105
glm::mat4 mProjectionMatrix;
106-
Rectangle mViewportRect;
106+
Rect mViewportRect;
107107

108108
public:
109109
GameCamera2D();

src/GameDefs.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,13 @@ struct TextureRegion
297297
{
298298
SetRegion(textureSize);
299299
}
300-
TextureRegion(const Rectangle& srcRectangle, const Point& textureSize)
300+
TextureRegion(const Rect& srcRectangle, const Point& textureSize)
301301
{
302302
SetRegion(srcRectangle, textureSize);
303303
}
304304

305305
// init texture region to partial area
306-
inline void SetRegion(const Rectangle& srcRectangle, const Point& textureSize)
306+
inline void SetRegion(const Rect& srcRectangle, const Point& textureSize)
307307
{
308308
debug_assert(textureSize.x > 0);
309309
debug_assert(textureSize.y > 0);
@@ -334,7 +334,7 @@ struct TextureRegion
334334
mRectangle.SetNull();
335335
}
336336
public:
337-
Rectangle mRectangle;
337+
Rect mRectangle;
338338

339339
float mU0, mV0; // texture coords
340340
float mU1, mV1; // texture coords

src/GameMapHelpers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "SpriteManager.h"
44
#include "GameMapManager.h"
55

6-
bool GameMapHelpers::BuildMapMesh(GameMapManager& cityScape, const Rectangle& area, int layerIndex, MapMeshData& meshData)
6+
bool GameMapHelpers::BuildMapMesh(GameMapManager& cityScape, const Rect& area, int layerIndex, MapMeshData& meshData)
77
{
88
debug_assert(layerIndex > -1 && layerIndex < MAP_LAYERS_COUNT);
99

@@ -30,7 +30,7 @@ bool GameMapHelpers::BuildMapMesh(GameMapManager& cityScape, const Rectangle& ar
3030
return true;
3131
}
3232

33-
bool GameMapHelpers::BuildMapMesh(GameMapManager& cityScape, const Rectangle& area, MapMeshData& meshData)
33+
bool GameMapHelpers::BuildMapMesh(GameMapManager& cityScape, const Rect& area, MapMeshData& meshData)
3434
{
3535
// preallocate
3636
meshData.mBlocksIndices.reserve(4 * 1024 * 1024);

src/GameMapHelpers.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ class GameMapHelpers final
1111
// @param area: Target map rect
1212
// @param layerIndex: Target map layer, see MAP_LAYERS_COUNT
1313
// @param meshData: Output mesh data
14-
static bool BuildMapMesh(GameMapManager& city, const Rectangle& area, int layerIndex, MapMeshData& meshData);
15-
static bool BuildMapMesh(GameMapManager& city, const Rectangle& area, MapMeshData& meshData);
14+
static bool BuildMapMesh(GameMapManager& city, const Rect& area, int layerIndex, MapMeshData& meshData);
15+
static bool BuildMapMesh(GameMapManager& city, const Rect& area, MapMeshData& meshData);
1616

1717
// compute height for specific block slope type
1818
// @param slope: Index

src/GraphicsDefs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ const unsigned int Sizeof_Vertex3D_Debug = sizeof(Vertex3D_Debug);
145145
// @param rcSrc, rcDest: Source and destination rectangles
146146
// @param color: Quad vertices color
147147
// @param vertices: Output 4 vertices in order TOP LEFT, BOTTOM LEFT, BOTTOM RIGHT, TOP RIGHT
148-
inline void MakeQuad2D(const Point& textureSize, const Rectangle& rcSrc, const Rectangle& rcDest, Color32 color, Vertex2D* vertices)
148+
inline void MakeQuad2D(const Point& textureSize, const Rect& rcSrc, const Rect& rcDest, Color32 color, Vertex2D* vertices)
149149
{
150150
const float invx = 1.0f / textureSize.x;
151151
const float invy = 1.0f / textureSize.y;
@@ -180,7 +180,7 @@ inline void MakeQuad2D(const Point& textureSize, const Rectangle& rcSrc, const R
180180
}
181181

182182
// same as MakeQuad2D but with 3rd dimension
183-
inline void MakeQuad3D(const Point& textureSize, const Rectangle& rcSrc, const Rectangle& rcDest, Color32 color, Vertex3D* vertices)
183+
inline void MakeQuad3D(const Point& textureSize, const Rect& rcSrc, const Rect& rcDest, Color32 color, Vertex3D* vertices)
184184
{
185185
const float invx = 1.0f / textureSize.x;
186186
const float invy = 1.0f / textureSize.y;

src/GraphicsDevice.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ void GraphicsDevice::ProcessGamepadsInputs()
832832
}
833833
}
834834

835-
void GraphicsDevice::SetViewportRect(const Rectangle& sourceRectangle)
835+
void GraphicsDevice::SetViewportRect(const Rect& sourceRectangle)
836836
{
837837
if (!IsDeviceInited())
838838
{
@@ -848,7 +848,7 @@ void GraphicsDevice::SetViewportRect(const Rectangle& sourceRectangle)
848848
glCheckError();
849849
}
850850

851-
void GraphicsDevice::SetScissorRect(const Rectangle& sourceRectangle)
851+
void GraphicsDevice::SetScissorRect(const Rect& sourceRectangle)
852852
{
853853
if (!IsDeviceInited())
854854
{

src/GraphicsDevice.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ class GraphicsDevice final: public cxx::noncopyable
1010
public:
1111
// public for convenience, don't change these fields directly
1212
RenderStates mCurrentStates;
13-
Rectangle mViewportRect;
14-
Rectangle mScissorBox;
13+
Rect mViewportRect;
14+
Rect mScissorBox;
1515
GraphicsDeviceCaps mCaps;
1616

1717
// these params will automatically set during texture creation
@@ -136,11 +136,11 @@ class GraphicsDevice final: public cxx::noncopyable
136136

137137
// Setup dimensions of graphic device viewport
138138
// @param sourceRectangle: Viewport rectangle
139-
void SetViewportRect(const Rectangle& sourceRectangle);
139+
void SetViewportRect(const Rect& sourceRectangle);
140140

141141
// Setup clip rect, default is whole viewport area
142142
// @param sourceRectangle: Clipping rectangle
143-
void SetScissorRect(const Rectangle& sourceRectangle);
143+
void SetScissorRect(const Rect& sourceRectangle);
144144

145145
// Set clear color for render revice
146146
// @param clearColor: Color components

0 commit comments

Comments
 (0)