mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 03:25:14 -04:00
Cast result of Gfx_CreateAndLockVb for better C++ compatibility
This commit is contained in:
parent
9924ba2a04
commit
71efc34d2f
@ -393,10 +393,12 @@ static cc_bool BuildChunk(int x1, int y1, int z1, struct ChunkInfo* info) {
|
|||||||
|
|
||||||
#ifndef CC_BUILD_GL11
|
#ifndef CC_BUILD_GL11
|
||||||
/* add an extra element to fix crashing on some GPUs */
|
/* add an extra element to fix crashing on some GPUs */
|
||||||
Builder_Vertices = Gfx_CreateAndLockVb(VERTEX_FORMAT_TEXTURED, totalVerts + 1, &info->Vb);
|
Builder_Vertices = (struct VertexTextured*)Gfx_CreateAndLockVb(&info->Vb,
|
||||||
|
VERTEX_FORMAT_TEXTURED, totalVerts + 1);
|
||||||
#else
|
#else
|
||||||
/* NOTE: Relies on assumption vb is ignored by GL11 Gfx_LockVb implementation */
|
/* NOTE: Relies on assumption vb is ignored by GL11 Gfx_LockVb implementation */
|
||||||
Builder_Vertices = Gfx_LockVb(0, VERTEX_FORMAT_P3FT2FC4B, totalVerts + 1);
|
Builder_Vertices = (struct VertexTextured*)Gfx_LockVb(0,
|
||||||
|
VERTEX_FORMAT_P3FT2FC4B, totalVerts + 1);
|
||||||
#endif
|
#endif
|
||||||
Builder_PostStretchTiles();
|
Builder_PostStretchTiles();
|
||||||
|
|
||||||
|
@ -195,7 +195,8 @@ static void UpdateClouds(void) {
|
|||||||
z1 = -extent; z2 = World.Length + extent;
|
z1 = -extent; z2 = World.Length + extent;
|
||||||
clouds_vertices = CalcNumVertices(x2 - x1, z2 - z1);
|
clouds_vertices = CalcNumVertices(x2 - x1, z2 - z1);
|
||||||
|
|
||||||
data = Gfx_CreateAndLockVb(VERTEX_FORMAT_TEXTURED, clouds_vertices, &clouds_vb);
|
data = (struct VertexTextured*)Gfx_CreateAndLockVb(&clouds_vb,
|
||||||
|
VERTEX_FORMAT_TEXTURED, clouds_vertices);
|
||||||
DrawCloudsY(x1, z1, x2, z2, Env.CloudsHeight, data);
|
DrawCloudsY(x1, z1, x2, z2, Env.CloudsHeight, data);
|
||||||
Gfx_UnlockVb(clouds_vb);
|
Gfx_UnlockVb(clouds_vb);
|
||||||
}
|
}
|
||||||
@ -266,7 +267,8 @@ static void UpdateSky(void) {
|
|||||||
z1 = -extent; z2 = World.Length + extent;
|
z1 = -extent; z2 = World.Length + extent;
|
||||||
sky_vertices = CalcNumVertices(x2 - x1, z2 - z1);
|
sky_vertices = CalcNumVertices(x2 - x1, z2 - z1);
|
||||||
|
|
||||||
data = Gfx_CreateAndLockVb(VERTEX_FORMAT_COLOURED, sky_vertices, &sky_vb);
|
data = (struct VertexColoured*)Gfx_CreateAndLockVb(&sky_vb,
|
||||||
|
VERTEX_FORMAT_COLOURED, sky_vertices);
|
||||||
height = max((World.Height + 2), Env.CloudsHeight) + 6;
|
height = max((World.Height + 2), Env.CloudsHeight) + 6;
|
||||||
DrawSkyY(x1, z1, x2, z2, height, data);
|
DrawSkyY(x1, z1, x2, z2, height, data);
|
||||||
Gfx_UnlockVb(sky_vb);
|
Gfx_UnlockVb(sky_vb);
|
||||||
@ -339,7 +341,8 @@ static void UpdateSkybox(void) {
|
|||||||
if (Gfx.LostContext) return;
|
if (Gfx.LostContext) return;
|
||||||
if (EnvRenderer_Minimal) return;
|
if (EnvRenderer_Minimal) return;
|
||||||
|
|
||||||
data = Gfx_CreateAndLockVb(VERTEX_FORMAT_TEXTURED, SKYBOX_COUNT, &skybox_vb);
|
data = (struct VertexTextured*)Gfx_CreateAndLockVb(&skybox_vb,
|
||||||
|
VERTEX_FORMAT_TEXTURED, SKYBOX_COUNT);
|
||||||
Mem_Copy(data, vertices, sizeof(vertices));
|
Mem_Copy(data, vertices, sizeof(vertices));
|
||||||
for (i = 0; i < SKYBOX_COUNT; i++) { data[i].Col = Env.SkyboxCol; }
|
for (i = 0; i < SKYBOX_COUNT; i++) { data[i].Col = Env.SkyboxCol; }
|
||||||
Gfx_UnlockVb(skybox_vb);
|
Gfx_UnlockVb(skybox_vb);
|
||||||
@ -689,7 +692,8 @@ static void UpdateMapSides(void) {
|
|||||||
sides_vertices += CalcNumVertices(World.Width, World.Length); /* YQuads beneath map */
|
sides_vertices += CalcNumVertices(World.Width, World.Length); /* YQuads beneath map */
|
||||||
sides_vertices += 2 * CalcNumVertices(World.Width, Math_AbsI(y)); /* ZQuads */
|
sides_vertices += 2 * CalcNumVertices(World.Width, Math_AbsI(y)); /* ZQuads */
|
||||||
sides_vertices += 2 * CalcNumVertices(World.Length, Math_AbsI(y)); /* XQuads */
|
sides_vertices += 2 * CalcNumVertices(World.Length, Math_AbsI(y)); /* XQuads */
|
||||||
data = Gfx_CreateAndLockVb(VERTEX_FORMAT_TEXTURED, sides_vertices, &sides_vb);
|
data = (struct VertexTextured*)Gfx_CreateAndLockVb(&sides_vb,
|
||||||
|
VERTEX_FORMAT_TEXTURED, sides_vertices);
|
||||||
|
|
||||||
sides_fullBright = Blocks.FullBright[block];
|
sides_fullBright = Blocks.FullBright[block];
|
||||||
col = sides_fullBright ? white : Env.ShadowCol;
|
col = sides_fullBright ? white : Env.ShadowCol;
|
||||||
@ -734,7 +738,8 @@ static void UpdateMapEdges(void) {
|
|||||||
r = rects[i];
|
r = rects[i];
|
||||||
edges_vertices += CalcNumVertices(r.Width, r.Height); /* YPlanes outside */
|
edges_vertices += CalcNumVertices(r.Width, r.Height); /* YPlanes outside */
|
||||||
}
|
}
|
||||||
data = Gfx_CreateAndLockVb(VERTEX_FORMAT_TEXTURED, edges_vertices, &edges_vb);
|
data = (struct VertexTextured*)Gfx_CreateAndLockVb(&edges_vb,
|
||||||
|
VERTEX_FORMAT_TEXTURED, edges_vertices);
|
||||||
|
|
||||||
edges_fullBright = Blocks.FullBright[block];
|
edges_fullBright = Blocks.FullBright[block];
|
||||||
col = edges_fullBright ? white : Env.SunCol;
|
col = edges_fullBright ? white : Env.SunCol;
|
||||||
|
@ -115,7 +115,7 @@ void Gfx_UpdateDynamicVb_IndexedTris(GfxResourceID vb, void* vertices, int vCoun
|
|||||||
Gfx_DrawVb_IndexedTris(vCount);
|
Gfx_DrawVb_IndexedTris(vCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Gfx_CreateAndLockVb(VertexFormat fmt, int count, GfxResourceID* vb) {
|
void* Gfx_CreateAndLockVb(GfxResourceID* vb, VertexFormat fmt, int count) {
|
||||||
*vb = Gfx_CreateVb(fmt, count);
|
*vb = Gfx_CreateVb(fmt, count);
|
||||||
return Gfx_LockVb(*vb, fmt, count);
|
return Gfx_LockVb(*vb, fmt, count);
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ cc_bool Gfx_TryRestoreContext(void);
|
|||||||
/* NOTE: This replaces the dynamic vertex buffer's data first with the given vertices before drawing. */
|
/* NOTE: This replaces the dynamic vertex buffer's data first with the given vertices before drawing. */
|
||||||
void Gfx_UpdateDynamicVb_IndexedTris(GfxResourceID vb, void* vertices, int vCount);
|
void Gfx_UpdateDynamicVb_IndexedTris(GfxResourceID vb, void* vertices, int vCount);
|
||||||
/* Shorthand for Gfx_CreateVb followed by Gfx_LockVb */
|
/* Shorthand for Gfx_CreateVb followed by Gfx_LockVb */
|
||||||
void* Gfx_CreateAndLockVb(VertexFormat fmt, int count, GfxResourceID* vb);
|
void* Gfx_CreateAndLockVb(GfxResourceID* vb, VertexFormat fmt, int count);
|
||||||
|
|
||||||
/* Renders a 2D flat coloured rectangle. */
|
/* Renders a 2D flat coloured rectangle. */
|
||||||
void Gfx_Draw2DFlat(int x, int y, int width, int height, PackedCol col);
|
void Gfx_Draw2DFlat(int x, int y, int width, int height, PackedCol col);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user