Skip to content

Commit aa83f29

Browse files
committed
refactor(ww3d2): Widen Renderer draw arguments to 32 bits
1 parent 46c0216 commit aa83f29

2 files changed

Lines changed: 31 additions & 21 deletions

File tree

‎Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.cpp‎

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@
2828
#include "WW3D2/lightenvironment.h"
2929
#include "WWDebug/wwdebug.h"
3030

31+
static unsigned short To_Unsigned_Short(unsigned int value)
32+
{
33+
const unsigned short narrowed = static_cast<unsigned short>(value);
34+
WWASSERT(narrowed == value);
35+
return narrowed;
36+
}
37+
3138
static D3DTRANSFORMSTATETYPE To_D3D_Transform(RenderBackendTransform transform)
3239
{
3340
switch (transform)
@@ -224,37 +231,40 @@ void Renderer::Set_Vertex_Buffer(const DynamicVBAccessClass & vba)
224231
DX8Wrapper::Set_Vertex_Buffer(vba);
225232
}
226233

227-
void Renderer::Set_Index_Buffer(const IndexBufferClass * ib, unsigned short index_base_offset)
234+
void Renderer::Set_Index_Buffer(const IndexBufferClass * ib, unsigned int index_base_offset)
228235
{
229-
DX8Wrapper::Set_Index_Buffer(ib, index_base_offset);
236+
DX8Wrapper::Set_Index_Buffer(ib, To_Unsigned_Short(index_base_offset));
230237
}
231238

232-
void Renderer::Set_Index_Buffer(const DynamicIBAccessClass & iba, unsigned short index_base_offset)
239+
void Renderer::Set_Index_Buffer(const DynamicIBAccessClass & iba, unsigned int index_base_offset)
233240
{
234-
DX8Wrapper::Set_Index_Buffer(iba, index_base_offset);
241+
DX8Wrapper::Set_Index_Buffer(iba, To_Unsigned_Short(index_base_offset));
235242
}
236243

237244
void Renderer::Set_Index_Buffer_Index_Offset(unsigned offset)
238245
{
239246
DX8Wrapper::Set_Index_Buffer_Index_Offset(offset);
240247
}
241248

242-
void Renderer::Draw_Triangles(unsigned buffer_type, unsigned short start_index, unsigned short polygon_count,
243-
unsigned short min_vertex_index, unsigned short vertex_count)
249+
void Renderer::Draw_Triangles(unsigned buffer_type, unsigned int start_index, unsigned int polygon_count,
250+
unsigned int min_vertex_index, unsigned int vertex_count)
244251
{
245-
DX8Wrapper::Draw_Triangles(buffer_type, start_index, polygon_count, min_vertex_index, vertex_count);
252+
DX8Wrapper::Draw_Triangles(buffer_type, To_Unsigned_Short(start_index), To_Unsigned_Short(polygon_count),
253+
To_Unsigned_Short(min_vertex_index), To_Unsigned_Short(vertex_count));
246254
}
247255

248-
void Renderer::Draw_Triangles(unsigned short start_index, unsigned short polygon_count,
249-
unsigned short min_vertex_index, unsigned short vertex_count)
256+
void Renderer::Draw_Triangles(unsigned int start_index, unsigned int polygon_count,
257+
unsigned int min_vertex_index, unsigned int vertex_count)
250258
{
251-
DX8Wrapper::Draw_Triangles(start_index, polygon_count, min_vertex_index, vertex_count);
259+
DX8Wrapper::Draw_Triangles(To_Unsigned_Short(start_index), To_Unsigned_Short(polygon_count),
260+
To_Unsigned_Short(min_vertex_index), To_Unsigned_Short(vertex_count));
252261
}
253262

254-
void Renderer::Draw_Strip(unsigned short start_index, unsigned short polygon_count,
255-
unsigned short min_vertex_index, unsigned short vertex_count)
263+
void Renderer::Draw_Strip(unsigned int start_index, unsigned int polygon_count,
264+
unsigned int min_vertex_index, unsigned int vertex_count)
256265
{
257-
DX8Wrapper::Draw_Strip(start_index, polygon_count, min_vertex_index, vertex_count);
266+
DX8Wrapper::Draw_Strip(To_Unsigned_Short(start_index), To_Unsigned_Short(polygon_count),
267+
To_Unsigned_Short(min_vertex_index), To_Unsigned_Short(vertex_count));
258268
}
259269

260270
void Renderer::Set_Transform(RenderBackendTransform transform, const Matrix4x4 & m)

‎Core/Libraries/Source/WWVegas/WW3D2/Renderer.h‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,16 @@ class Renderer
105105

106106
static void Set_Vertex_Buffer(const VertexBufferClass * vb, unsigned stream = 0);
107107
static void Set_Vertex_Buffer(const DynamicVBAccessClass & vba);
108-
static void Set_Index_Buffer(const IndexBufferClass * ib, unsigned short index_base_offset);
109-
static void Set_Index_Buffer(const DynamicIBAccessClass & iba, unsigned short index_base_offset);
108+
static void Set_Index_Buffer(const IndexBufferClass * ib, unsigned int index_base_offset);
109+
static void Set_Index_Buffer(const DynamicIBAccessClass & iba, unsigned int index_base_offset);
110110
static void Set_Index_Buffer_Index_Offset(unsigned offset);
111111

112-
static void Draw_Triangles(unsigned buffer_type, unsigned short start_index, unsigned short polygon_count,
113-
unsigned short min_vertex_index, unsigned short vertex_count);
114-
static void Draw_Triangles(unsigned short start_index, unsigned short polygon_count,
115-
unsigned short min_vertex_index, unsigned short vertex_count);
116-
static void Draw_Strip(unsigned short start_index, unsigned short polygon_count,
117-
unsigned short min_vertex_index, unsigned short vertex_count);
112+
static void Draw_Triangles(unsigned buffer_type, unsigned int start_index, unsigned int polygon_count,
113+
unsigned int min_vertex_index, unsigned int vertex_count);
114+
static void Draw_Triangles(unsigned int start_index, unsigned int polygon_count,
115+
unsigned int min_vertex_index, unsigned int vertex_count);
116+
static void Draw_Strip(unsigned int start_index, unsigned int polygon_count,
117+
unsigned int min_vertex_index, unsigned int vertex_count);
118118

119119
static void Set_Transform(RenderBackendTransform transform, const Matrix4x4 & m);
120120
static void Set_Transform(RenderBackendTransform transform, const Matrix3D & m);

0 commit comments

Comments
 (0)