mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 11:35:08 -04:00
WIP on redesigning static VB code
This commit is contained in:
parent
78e7887c7b
commit
55cd5bc3a0
@ -420,7 +420,8 @@ void Builder_MakeChunk(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 = (struct VertexTextured*)Gfx_RecreateAndLockVb(&info->vb,
|
info->vb = Gfx_CreateVb(VERTEX_FORMAT_TEXTURED, totalVerts + 1);
|
||||||
|
Builder_Vertices = (struct VertexTextured*)Gfx_LockVb(info->vb,
|
||||||
VERTEX_FORMAT_TEXTURED, totalVerts + 1);
|
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 */
|
||||||
|
@ -173,8 +173,10 @@ static CC_NOINLINE void BuildClouds(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 = (struct VertexTextured*)Gfx_RecreateAndLockVb(&clouds_vb,
|
clouds_vb = Gfx_CreateVb(VERTEX_FORMAT_TEXTURED, clouds_vertices);
|
||||||
|
data = (struct VertexTextured*)Gfx_LockVb(clouds_vb,
|
||||||
VERTEX_FORMAT_TEXTURED, clouds_vertices);
|
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);
|
||||||
}
|
}
|
||||||
@ -239,8 +241,10 @@ static CC_NOINLINE void BuildSky(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 = (struct VertexColoured*)Gfx_RecreateAndLockVb(&sky_vb,
|
sky_vb = Gfx_CreateVb(VERTEX_FORMAT_COLOURED, sky_vertices);
|
||||||
|
data = (struct VertexColoured*)Gfx_LockVb(sky_vb,
|
||||||
VERTEX_FORMAT_COLOURED, sky_vertices);
|
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);
|
||||||
@ -307,8 +311,10 @@ static CC_NOINLINE void BuildSkybox(void) {
|
|||||||
struct VertexTextured* data;
|
struct VertexTextured* data;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
data = (struct VertexTextured*)Gfx_RecreateAndLockVb(&skybox_vb,
|
skybox_vb = Gfx_CreateVb(VERTEX_FORMAT_TEXTURED, SKYBOX_COUNT);
|
||||||
|
data = (struct VertexTextured*)Gfx_LockVb(skybox_vb,
|
||||||
VERTEX_FORMAT_TEXTURED, SKYBOX_COUNT);
|
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);
|
||||||
@ -703,7 +709,9 @@ static CC_NOINLINE void BuildMapSides(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 = (struct VertexTextured*)Gfx_RecreateAndLockVb(&sides_vb,
|
|
||||||
|
sides_vb = Gfx_CreateVb(VERTEX_FORMAT_TEXTURED, sides_vertices);
|
||||||
|
data = (struct VertexTextured*)Gfx_LockVb(sides_vb,
|
||||||
VERTEX_FORMAT_TEXTURED, sides_vertices);
|
VERTEX_FORMAT_TEXTURED, sides_vertices);
|
||||||
|
|
||||||
sides_fullBright = Blocks.Brightness[block];
|
sides_fullBright = Blocks.Brightness[block];
|
||||||
@ -748,7 +756,9 @@ static CC_NOINLINE void BuildMapEdges(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 = (struct VertexTextured*)Gfx_RecreateAndLockVb(&edges_vb,
|
|
||||||
|
edges_vb = Gfx_CreateVb(VERTEX_FORMAT_TEXTURED, edges_vertices);
|
||||||
|
data = (struct VertexTextured*)Gfx_LockVb(edges_vb,
|
||||||
VERTEX_FORMAT_TEXTURED, edges_vertices);
|
VERTEX_FORMAT_TEXTURED, edges_vertices);
|
||||||
|
|
||||||
edges_fullBright = Blocks.Brightness[block];
|
edges_fullBright = Blocks.Brightness[block];
|
||||||
|
@ -98,8 +98,7 @@ extern const cc_string Gfx_LowPerfMessage;
|
|||||||
#define GFX_MAX_INDICES (65536 / 4 * 6)
|
#define GFX_MAX_INDICES (65536 / 4 * 6)
|
||||||
#define GFX_MAX_VERTICES 65536
|
#define GFX_MAX_VERTICES 65536
|
||||||
|
|
||||||
void Gfx_RecreateTexture(GfxResourceID* tex, struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps);
|
void Gfx_RecreateTexture(GfxResourceID* tex, struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps);
|
||||||
void* Gfx_RecreateAndLockVb(GfxResourceID* vb, VertexFormat fmt, int count);
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
|
@ -341,8 +341,10 @@ static void Init2DResources(void) {
|
|||||||
Gfx_Create();
|
Gfx_Create();
|
||||||
if (framebuffer_vb) return;
|
if (framebuffer_vb) return;
|
||||||
|
|
||||||
struct VertexTextured* data = (struct VertexTextured*)Gfx_RecreateAndLockVb(&framebuffer_vb,
|
framebuffer_vb = Gfx_CreateVb(VERTEX_FORMAT_TEXTURED, 4);
|
||||||
VERTEX_FORMAT_TEXTURED, 4);
|
struct VertexTextured* data = (struct VertexTextured*)Gfx_LockVb(framebuffer_vb,
|
||||||
|
VERTEX_FORMAT_TEXTURED, 4);
|
||||||
|
|
||||||
data[0].x = -1.0f; data[0].y = -1.0f; data[0].z = 0.0f; data[0].Col = PACKEDCOL_WHITE; data[0].U = 0.0f; data[0].V = 1.0f;
|
data[0].x = -1.0f; data[0].y = -1.0f; data[0].z = 0.0f; data[0].Col = PACKEDCOL_WHITE; data[0].U = 0.0f; data[0].V = 1.0f;
|
||||||
data[1].x = 1.0f; data[1].y = -1.0f; data[1].z = 0.0f; data[1].Col = PACKEDCOL_WHITE; data[1].U = 1.0f; data[1].V = 1.0f;
|
data[1].x = 1.0f; data[1].y = -1.0f; data[1].z = 0.0f; data[1].Col = PACKEDCOL_WHITE; data[1].U = 1.0f; data[1].V = 1.0f;
|
||||||
data[2].x = 1.0f; data[2].y = 1.0f; data[2].z = 0.0f; data[2].Col = PACKEDCOL_WHITE; data[2].U = 1.0f; data[2].V = 0.0f;
|
data[2].x = 1.0f; data[2].y = 1.0f; data[2].z = 0.0f; data[2].Col = PACKEDCOL_WHITE; data[2].U = 1.0f; data[2].V = 0.0f;
|
||||||
|
@ -455,12 +455,6 @@ void Texture_RenderShaded(const struct Texture* tex, PackedCol shadeColor) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*------------------------------------------------------Vertex buffers-----------------------------------------------------*
|
*------------------------------------------------------Vertex buffers-----------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
void* Gfx_RecreateAndLockVb(GfxResourceID* vb, VertexFormat fmt, int count) {
|
|
||||||
Gfx_DeleteVb(vb);
|
|
||||||
*vb = Gfx_CreateVb(fmt, count);
|
|
||||||
return Gfx_LockVb(*vb, fmt, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GfxResourceID Gfx_AllocStaticVb( VertexFormat fmt, int count);
|
static GfxResourceID Gfx_AllocStaticVb( VertexFormat fmt, int count);
|
||||||
static GfxResourceID Gfx_AllocDynamicVb(VertexFormat fmt, int maxVertices);
|
static GfxResourceID Gfx_AllocDynamicVb(VertexFormat fmt, int maxVertices);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user