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:
Doyle Thai 2016-06-25 21:51:35 +10:00
parent e638724c75
commit fd3a353fdd

View File

@ -313,12 +313,16 @@ void worldTraveller_gameUpdateAndRender(GameState *state, const f32 dt)
v2 tileSize = V2(CAST(f32)state->tileSize, CAST(f32)state->tileSize);
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_scale(worldAtlas->texRect[terraincoords_ground], ndcFactor);
updateBufferObject(state->renderer.vbo, texNDC);
renderer_object(&state->renderer, tilePosInPixel, tileSize, 0.0f,
V3(0, 0, 0), worldTex);
}
}
// NOTE(doyle): Factor to normalise sprite sheet rect coords to -1, 1
Entity *hero = &state->entityList[state->heroIndex];