diff --git a/src/Builder.c b/src/Builder.c index d803069b6..e8e2ae38d 100644 --- a/src/Builder.c +++ b/src/Builder.c @@ -420,7 +420,8 @@ void Builder_MakeChunk(struct ChunkInfo* info) { #ifndef CC_BUILD_GL11 /* 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); #else /* NOTE: Relies on assumption vb is ignored by GL11 Gfx_LockVb implementation */ diff --git a/src/EnvRenderer.c b/src/EnvRenderer.c index f4613dd7f..d275ca6bb 100644 --- a/src/EnvRenderer.c +++ b/src/EnvRenderer.c @@ -173,8 +173,10 @@ static CC_NOINLINE void BuildClouds(void) { z1 = -extent; z2 = World.Length + extent; 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); + DrawCloudsY(x1, z1, x2, z2, Env.CloudsHeight, data); Gfx_UnlockVb(clouds_vb); } @@ -239,8 +241,10 @@ static CC_NOINLINE void BuildSky(void) { z1 = -extent; z2 = World.Length + extent; 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); + height = max((World.Height + 2), Env.CloudsHeight) + 6; DrawSkyY(x1, z1, x2, z2, height, data); Gfx_UnlockVb(sky_vb); @@ -307,8 +311,10 @@ static CC_NOINLINE void BuildSkybox(void) { struct VertexTextured* data; 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); + Mem_Copy(data, vertices, sizeof(vertices)); for (i = 0; i < SKYBOX_COUNT; i++) { data[i].Col = Env.SkyboxCol; } 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 += 2 * CalcNumVertices(World.Width, Math_AbsI(y)); /* ZQuads */ 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); sides_fullBright = Blocks.Brightness[block]; @@ -748,7 +756,9 @@ static CC_NOINLINE void BuildMapEdges(void) { r = rects[i]; 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); edges_fullBright = Blocks.Brightness[block]; diff --git a/src/Graphics.h b/src/Graphics.h index 6a887ccca..43ee320fe 100644 --- a/src/Graphics.h +++ b/src/Graphics.h @@ -98,8 +98,7 @@ extern const cc_string Gfx_LowPerfMessage; #define GFX_MAX_INDICES (65536 / 4 * 6) #define GFX_MAX_VERTICES 65536 -void Gfx_RecreateTexture(GfxResourceID* tex, struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps); -void* Gfx_RecreateAndLockVb(GfxResourceID* vb, VertexFormat fmt, int count); +void Gfx_RecreateTexture(GfxResourceID* tex, struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps); /*########################################################################################################################* diff --git a/src/Window_WiiU.c b/src/Window_WiiU.c index 01bfe1c2d..203225701 100644 --- a/src/Window_WiiU.c +++ b/src/Window_WiiU.c @@ -341,8 +341,10 @@ static void Init2DResources(void) { Gfx_Create(); if (framebuffer_vb) return; - struct VertexTextured* data = (struct VertexTextured*)Gfx_RecreateAndLockVb(&framebuffer_vb, - VERTEX_FORMAT_TEXTURED, 4); + framebuffer_vb = Gfx_CreateVb(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[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; diff --git a/src/_GraphicsBase.h b/src/_GraphicsBase.h index b509411a2..e5d8e9e4e 100644 --- a/src/_GraphicsBase.h +++ b/src/_GraphicsBase.h @@ -455,12 +455,6 @@ void Texture_RenderShaded(const struct Texture* tex, PackedCol shadeColor) { /*########################################################################################################################* *------------------------------------------------------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_AllocDynamicVb(VertexFormat fmt, int maxVertices);