I started playing around with Oxygine and Ogmo last night when I stumbled upon this GitHub that read in the Ogmo level.
I ended up fixing the doRender
method as it did not work (could just be due to it being an old version of Ogmo or something):
void OgmoLevel::doRender(const RenderState& rs) {
auto tileLayers = this->tileLayers;
Sprite sprite;
for (size_t layerIndex = 0; layerIndex < tileLayers.size(); ++layerIndex) {
auto tileLayer = &tileLayers.at(layerIndex);
auto resAnim = project->resource->getResAnim(tileLayer->tileset->name);
resAnim->getFrame(0).getDiffuse().base->setLinearFilter(false);
sprite.setResAnim(resAnim);
int gridXSize = tileLayer->definition->gridWidth;
int gridYSize = tileLayer->definition->gridHeight;
size_t columns = roomWidth / gridXSize;
size_t rows = roomHeight / gridYSize;
auto tiles = &tileLayer->tiles;
size_t tilesSize = tiles->size();
size_t i = 0;
float yy = 0;
for (size_t y = 0; y < rows; ++y) {
float xx = 0;
for (size_t x = 0; x < columns; ++x) {
int tileID = tiles->at(i);
if (tileID != OGMO_BLANK_TILE)
{
int tWidth = tileLayer->tileset->tileWidth;
int actualRow = (tileID * tWidth / tWidth) / tWidth;
int actualColumn = (tileID - (actualRow * tWidth));
sprite.setColumnRow(actualColumn, actualRow);
sprite.setPosition(xx, yy);
sprite.render(rs);
}
xx += tileLayer->definition->gridWidth;
++i;
}
yy += tileLayer->definition->gridHeight;
}
}
}
The issue I see with this, is that the same exact rendering is happening every single frame. Normally for the tile maps, there are checks to determine whether or not the tile is on the screen. Now that is fine and all, but this time around, I know it is fully static 99% of the time and I want to render it to a texture and just continue to render that.
I've looked at the MemoryTexture
and ImageData
classes, but there wasn't really anything online I could find to tell me how to properly use them. Does anyone have any idea how I can achieve caching this?
(not enough rep to create proper tags)