Call renderer on tiles only-if tile on screen
OpenGL automatically clips objects outside of the view space but we were still using up a lot of useless glDraw calls which impacts performance. This change is temporary and will change when we get to scrolling the world.
This commit is contained in:
parent
e638724c75
commit
fd3a353fdd
@ -313,12 +313,16 @@ void worldTraveller_gameUpdateAndRender(GameState *state, const f32 dt)
|
|||||||
v2 tileSize = V2(CAST(f32)state->tileSize, CAST(f32)state->tileSize);
|
v2 tileSize = V2(CAST(f32)state->tileSize, CAST(f32)state->tileSize);
|
||||||
v2 tilePosInPixel = v2_scale(tile.pos, tileSize.x);
|
v2 tilePosInPixel = v2_scale(tile.pos, tileSize.x);
|
||||||
|
|
||||||
|
if ((tilePosInPixel.x < state->width && tilePosInPixel.x >= 0) &&
|
||||||
|
(tilePosInPixel.y < state->height && tilePosInPixel.y >= 0))
|
||||||
|
{
|
||||||
v4 texNDC =
|
v4 texNDC =
|
||||||
v4_scale(worldAtlas->texRect[terraincoords_ground], ndcFactor);
|
v4_scale(worldAtlas->texRect[terraincoords_ground], ndcFactor);
|
||||||
updateBufferObject(state->renderer.vbo, texNDC);
|
updateBufferObject(state->renderer.vbo, texNDC);
|
||||||
renderer_object(&state->renderer, tilePosInPixel, tileSize, 0.0f,
|
renderer_object(&state->renderer, tilePosInPixel, tileSize, 0.0f,
|
||||||
V3(0, 0, 0), worldTex);
|
V3(0, 0, 0), worldTex);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE(doyle): Factor to normalise sprite sheet rect coords to -1, 1
|
// NOTE(doyle): Factor to normalise sprite sheet rect coords to -1, 1
|
||||||
Entity *hero = &state->entityList[state->heroIndex];
|
Entity *hero = &state->entityList[state->heroIndex];
|
||||||
|
Loading…
Reference in New Issue
Block a user