Account for GetVertexBufferSlot failure
This commit is contained in:
parent
9275ad4689
commit
8fbf3bbecf
1 changed files with 110 additions and 97 deletions
|
@ -329,10 +329,11 @@ static VertexBufferSlot* GetVertexBufferSlot(unsigned int slots_needed)
|
||||||
while (current_vertex_buffer_slot + slots_needed > local_vertex_buffer_size)
|
while (current_vertex_buffer_slot + slots_needed > local_vertex_buffer_size)
|
||||||
local_vertex_buffer_size <<= 1;
|
local_vertex_buffer_size <<= 1;
|
||||||
|
|
||||||
VertexBufferSlot *reallocResult = (VertexBufferSlot *)realloc(local_vertex_buffer, local_vertex_buffer_size * sizeof(VertexBufferSlot));
|
VertexBufferSlot *realloc_result = (VertexBufferSlot*)realloc(local_vertex_buffer, local_vertex_buffer_size * sizeof(VertexBufferSlot));
|
||||||
if (reallocResult != NULL)
|
|
||||||
|
if (realloc_result != NULL)
|
||||||
{
|
{
|
||||||
local_vertex_buffer = reallocResult;
|
local_vertex_buffer = realloc_result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -427,6 +428,8 @@ static void GlyphBatch_Draw(spritebatch_sprite_t *sprites, int count, int textur
|
||||||
// Add data to the vertex queue
|
// Add data to the vertex queue
|
||||||
VertexBufferSlot *vertex_buffer_slot = GetVertexBufferSlot(count);
|
VertexBufferSlot *vertex_buffer_slot = GetVertexBufferSlot(count);
|
||||||
|
|
||||||
|
if (vertex_buffer_slot != NULL)
|
||||||
|
{
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
RenderBackend_Glyph *glyph = (RenderBackend_Glyph*)sprites[i].image_id;
|
RenderBackend_Glyph *glyph = (RenderBackend_Glyph*)sprites[i].image_id;
|
||||||
|
@ -469,6 +472,7 @@ static void GlyphBatch_Draw(spritebatch_sprite_t *sprites, int count, int textur
|
||||||
vertex_buffer_slot[i].vertices[1][2].vertex_coordinate.x = vertex_left;
|
vertex_buffer_slot[i].vertices[1][2].vertex_coordinate.x = vertex_left;
|
||||||
vertex_buffer_slot[i].vertices[1][2].vertex_coordinate.y = vertex_bottom;
|
vertex_buffer_slot[i].vertices[1][2].vertex_coordinate.y = vertex_bottom;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Upload the glyph's pixels
|
// Upload the glyph's pixels
|
||||||
|
@ -761,6 +765,8 @@ void RenderBackend_DrawScreen(void)
|
||||||
|
|
||||||
VertexBufferSlot *vertex_buffer_slot = GetVertexBufferSlot(1);
|
VertexBufferSlot *vertex_buffer_slot = GetVertexBufferSlot(1);
|
||||||
|
|
||||||
|
if (vertex_buffer_slot != NULL)
|
||||||
|
{
|
||||||
vertex_buffer_slot->vertices[0][0].texture_coordinate.x = 0.0f;
|
vertex_buffer_slot->vertices[0][0].texture_coordinate.x = 0.0f;
|
||||||
vertex_buffer_slot->vertices[0][0].texture_coordinate.y = 1.0f;
|
vertex_buffer_slot->vertices[0][0].texture_coordinate.y = 1.0f;
|
||||||
vertex_buffer_slot->vertices[0][1].texture_coordinate.x = 1.0f;
|
vertex_buffer_slot->vertices[0][1].texture_coordinate.x = 1.0f;
|
||||||
|
@ -788,6 +794,7 @@ void RenderBackend_DrawScreen(void)
|
||||||
vertex_buffer_slot->vertices[1][1].vertex_coordinate.y = 1.0f;
|
vertex_buffer_slot->vertices[1][1].vertex_coordinate.y = 1.0f;
|
||||||
vertex_buffer_slot->vertices[1][2].vertex_coordinate.x = -1.0f;
|
vertex_buffer_slot->vertices[1][2].vertex_coordinate.x = -1.0f;
|
||||||
vertex_buffer_slot->vertices[1][2].vertex_coordinate.y = 1.0f;
|
vertex_buffer_slot->vertices[1][2].vertex_coordinate.y = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
FlushVertexBuffer();
|
FlushVertexBuffer();
|
||||||
|
|
||||||
|
@ -937,6 +944,8 @@ void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RECT *rect,
|
||||||
|
|
||||||
VertexBufferSlot *vertex_buffer_slot = GetVertexBufferSlot(1);
|
VertexBufferSlot *vertex_buffer_slot = GetVertexBufferSlot(1);
|
||||||
|
|
||||||
|
if (vertex_buffer_slot != NULL)
|
||||||
|
{
|
||||||
vertex_buffer_slot->vertices[0][0].texture_coordinate.x = texture_left;
|
vertex_buffer_slot->vertices[0][0].texture_coordinate.x = texture_left;
|
||||||
vertex_buffer_slot->vertices[0][0].texture_coordinate.y = texture_top;
|
vertex_buffer_slot->vertices[0][0].texture_coordinate.y = texture_top;
|
||||||
vertex_buffer_slot->vertices[0][1].texture_coordinate.x = texture_right;
|
vertex_buffer_slot->vertices[0][1].texture_coordinate.x = texture_right;
|
||||||
|
@ -964,6 +973,7 @@ void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RECT *rect,
|
||||||
vertex_buffer_slot->vertices[1][1].vertex_coordinate.y = vertex_bottom;
|
vertex_buffer_slot->vertices[1][1].vertex_coordinate.y = vertex_bottom;
|
||||||
vertex_buffer_slot->vertices[1][2].vertex_coordinate.x = vertex_left;
|
vertex_buffer_slot->vertices[1][2].vertex_coordinate.x = vertex_left;
|
||||||
vertex_buffer_slot->vertices[1][2].vertex_coordinate.y = vertex_bottom;
|
vertex_buffer_slot->vertices[1][2].vertex_coordinate.y = vertex_bottom;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue)
|
void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue)
|
||||||
|
@ -1012,6 +1022,8 @@ void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RECT *rect,
|
||||||
|
|
||||||
VertexBufferSlot *vertex_buffer_slot = GetVertexBufferSlot(1);
|
VertexBufferSlot *vertex_buffer_slot = GetVertexBufferSlot(1);
|
||||||
|
|
||||||
|
if (vertex_buffer_slot != NULL)
|
||||||
|
{
|
||||||
vertex_buffer_slot->vertices[0][0].vertex_coordinate.x = vertex_left;
|
vertex_buffer_slot->vertices[0][0].vertex_coordinate.x = vertex_left;
|
||||||
vertex_buffer_slot->vertices[0][0].vertex_coordinate.y = vertex_top;
|
vertex_buffer_slot->vertices[0][0].vertex_coordinate.y = vertex_top;
|
||||||
vertex_buffer_slot->vertices[0][1].vertex_coordinate.x = vertex_right;
|
vertex_buffer_slot->vertices[0][1].vertex_coordinate.x = vertex_right;
|
||||||
|
@ -1025,6 +1037,7 @@ void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RECT *rect,
|
||||||
vertex_buffer_slot->vertices[1][1].vertex_coordinate.y = vertex_bottom;
|
vertex_buffer_slot->vertices[1][1].vertex_coordinate.y = vertex_bottom;
|
||||||
vertex_buffer_slot->vertices[1][2].vertex_coordinate.x = vertex_left;
|
vertex_buffer_slot->vertices[1][2].vertex_coordinate.x = vertex_left;
|
||||||
vertex_buffer_slot->vertices[1][2].vertex_coordinate.y = vertex_bottom;
|
vertex_buffer_slot->vertices[1][2].vertex_coordinate.y = vertex_bottom;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ====================
|
// ====================
|
||||||
|
|
Loading…
Add table
Reference in a new issue