[nostalgia] Cleanup

This commit is contained in:
Gary Talent 2023-11-05 10:19:27 -06:00
parent 4ae6fd7c17
commit 868adae053
10 changed files with 139 additions and 124 deletions

View File

@ -5,15 +5,11 @@
#pragma once
#include <ox/std/array.hpp>
#include <ox/std/point.hpp>
#include <ox/std/size.hpp>
#include <ox/std/types.hpp>
#include <ox/model/def.hpp>
#include "color.hpp"
#include "context.hpp"
#include "ptidxconv.hpp"
#include "tilesheet.hpp"
namespace nostalgia::core {
@ -82,6 +78,6 @@ void setSprite(Context *ctx, Sprite const&s) noexcept;
}
namespace nostalgia::core::gl {
void drawMainView(core::Context*, ox::Size const&) noexcept;
void drawMainView(core::Context&, ox::Size const&) noexcept;
}

View File

@ -13,8 +13,10 @@
#include <keel/media.hpp>
#include <turbine/turbine.hpp>
#include <nostalgia/core/color.hpp>
#include <nostalgia/core/context.hpp>
#include <nostalgia/core/gfx.hpp>
#include <nostalgia/core/tilesheet.hpp>
#include "context.hpp"

View File

@ -12,17 +12,27 @@
#include <nostalgia/core/context.hpp>
#include <nostalgia/core/gfx.hpp>
#include <nostalgia/core/tilesheet.hpp>
#include "context.hpp"
namespace nostalgia::core {
[[nodiscard]]
inline GlContext &glctx(Context &ctx) noexcept {
if constexpr(ox::defines::Debug) {
return dynamic_cast<GlContext&>(ctx);
} else {
return static_cast<GlContext&>(ctx);
}
}
namespace renderer {
Drawer::Drawer(Context &ctx) noexcept: m_ctx(ctx) {}
void Drawer::draw(turbine::Context &tctx) noexcept {
core::gl::drawMainView(&m_ctx, turbine::getScreenSize(tctx));
core::gl::drawMainView(m_ctx, turbine::getScreenSize(tctx));
}
constexpr ox::StringView bgvshadTmpl = R"(
@ -71,17 +81,17 @@ constexpr ox::StringView spritevshadTmpl = R"(
constexpr ox::StringView spritefshadTmpl = bgfshadTmpl;
[[nodiscard]]
static constexpr auto bgVertexRow(unsigned x, unsigned y) noexcept {
static constexpr auto bgVertexRow(uint_t x, uint_t y) noexcept {
return y * TileRows + x;
}
static void setSpriteBufferObject(
unsigned vi,
uint_t vi,
float enabled,
float x,
float y,
unsigned textureRow,
unsigned flipX,
uint_t textureRow,
uint_t flipX,
float *vbo,
GLuint *ebo) noexcept {
// don't worry, this memcpy gets optimized to something much more ideal
@ -109,10 +119,10 @@ static void setSpriteBufferObject(
}
void setTileBufferObject(
unsigned vi,
uint_t vi,
float x,
float y,
unsigned textureRow,
uint_t textureRow,
float *vbo,
GLuint *ebo) noexcept {
// don't worry, this memcpy gets optimized to something much more ideal
@ -137,22 +147,22 @@ void setTileBufferObject(
memcpy(ebo, elms.data(), sizeof(elms));
}
static void initSpriteBufferObjects(glutils::BufferSet *bs) noexcept {
static void initSpriteBufferObjects(glutils::BufferSet &bs) noexcept {
for (auto i = 0u; i < SpriteCount; ++i) {
auto vbo = &bs->vertices[i * static_cast<std::size_t>(SpriteVertexVboLength)];
auto ebo = &bs->elements[i * static_cast<std::size_t>(SpriteVertexEboLength)];
auto vbo = &bs.vertices[i * static_cast<std::size_t>(SpriteVertexVboLength)];
auto ebo = &bs.elements[i * static_cast<std::size_t>(SpriteVertexEboLength)];
setSpriteBufferObject(i * SpriteVertexVboRows, 0, 0, 0, 0, false, vbo, ebo);
}
}
static void initBackgroundBufferObjects(glutils::BufferSet *bg) noexcept {
static void initBackgroundBufferObjects(glutils::BufferSet &bg) noexcept {
for (auto x = 0u; x < TileColumns; ++x) {
for (auto y = 0u; y < TileRows; ++y) {
const auto i = bgVertexRow(x, y);
auto vbo = &bg->vertices[i * static_cast<std::size_t>(BgVertexVboLength)];
auto ebo = &bg->elements[i * static_cast<std::size_t>(BgVertexEboLength)];
auto vbo = &bg.vertices[i * static_cast<std::size_t>(BgVertexVboLength)];
auto ebo = &bg.elements[i * static_cast<std::size_t>(BgVertexEboLength)];
setTileBufferObject(
static_cast<unsigned>(i * BgVertexVboRows),
static_cast<uint_t>(i * BgVertexVboRows),
static_cast<float>(x),
static_cast<float>(y),
0,
@ -162,25 +172,25 @@ static void initBackgroundBufferObjects(glutils::BufferSet *bg) noexcept {
}
}
static void initSpritesBufferset(GLuint shader, glutils::BufferSet *bs) noexcept {
static void initSpritesBufferset(GLuint shader, glutils::BufferSet &bs) noexcept {
// vao
bs->vao = glutils::generateVertexArrayObject();
glBindVertexArray(bs->vao);
bs.vao = glutils::generateVertexArrayObject();
glBindVertexArray(bs.vao);
// vbo & ebo
bs->vbo = glutils::generateBuffer();
bs->ebo = glutils::generateBuffer();
bs.vbo = glutils::generateBuffer();
bs.ebo = glutils::generateBuffer();
initSpriteBufferObjects(bs);
glutils::sendVbo(*bs);
glutils::sendEbo(*bs);
glutils::sendVbo(bs);
glutils::sendEbo(bs);
// vbo layout
auto enabledAttr = static_cast<GLuint>(glGetAttribLocation(shader, "vEnabled"));
auto const enabledAttr = static_cast<GLuint>(glGetAttribLocation(shader, "vEnabled"));
glEnableVertexAttribArray(enabledAttr);
glVertexAttribPointer(enabledAttr, 1, GL_FLOAT, GL_FALSE, SpriteVertexVboRowLength * sizeof(float), nullptr);
auto posAttr = static_cast<GLuint>(glGetAttribLocation(shader, "vPosition"));
auto const posAttr = static_cast<GLuint>(glGetAttribLocation(shader, "vPosition"));
glEnableVertexAttribArray(posAttr);
glVertexAttribPointer(posAttr, 2, GL_FLOAT, GL_FALSE, SpriteVertexVboRowLength * sizeof(float),
reinterpret_cast<void*>(1 * sizeof(float)));
auto texCoordAttr = static_cast<GLuint>(glGetAttribLocation(shader, "vTexCoord"));
auto const texCoordAttr = static_cast<GLuint>(glGetAttribLocation(shader, "vTexCoord"));
glEnableVertexAttribArray(texCoordAttr);
glVertexAttribPointer(texCoordAttr, 2, GL_FLOAT, GL_FALSE, SpriteVertexVboRowLength * sizeof(float),
reinterpret_cast<void*>(3 * sizeof(float)));
@ -188,25 +198,25 @@ static void initSpritesBufferset(GLuint shader, glutils::BufferSet *bs) noexcept
static void initBackgroundBufferset(
GLuint shader,
glutils::BufferSet *bg) noexcept {
glutils::BufferSet &bg) noexcept {
// vao
bg->vao = glutils::generateVertexArrayObject();
glBindVertexArray(bg->vao);
bg.vao = glutils::generateVertexArrayObject();
glBindVertexArray(bg.vao);
// vbo & ebo
bg->vbo = glutils::generateBuffer();
bg->ebo = glutils::generateBuffer();
bg.vbo = glutils::generateBuffer();
bg.ebo = glutils::generateBuffer();
initBackgroundBufferObjects(bg);
glutils::sendVbo(*bg);
glutils::sendEbo(*bg);
glutils::sendVbo(bg);
glutils::sendEbo(bg);
// vbo layout
auto posAttr = static_cast<GLuint>(glGetAttribLocation(shader, "vPosition"));
auto const posAttr = static_cast<GLuint>(glGetAttribLocation(shader, "vPosition"));
glEnableVertexAttribArray(posAttr);
glVertexAttribPointer(posAttr, 2, GL_FLOAT, GL_FALSE, BgVertexVboRowLength * sizeof(float), nullptr);
auto texCoordAttr = static_cast<GLuint>(glGetAttribLocation(shader, "vTexCoord"));
auto const texCoordAttr = static_cast<GLuint>(glGetAttribLocation(shader, "vTexCoord"));
glEnableVertexAttribArray(texCoordAttr);
glVertexAttribPointer(
texCoordAttr, 2, GL_FLOAT, GL_FALSE, BgVertexVboRowLength * sizeof(bg->vertices[0]),
reinterpret_cast<void*>(2 * sizeof(bg->vertices[0])));
texCoordAttr, 2, GL_FLOAT, GL_FALSE, BgVertexVboRowLength * sizeof(bg.vertices[0]),
reinterpret_cast<void*>(2 * sizeof(bg.vertices[0])));
}
static glutils::GLTexture loadTexture(
@ -228,42 +238,42 @@ static glutils::GLTexture loadTexture(
return tex;
}
static void drawBackground(CBB *cbb) noexcept {
glBindVertexArray(cbb->vao);
if (cbb->updated) {
cbb->updated = false;
glutils::sendVbo(*cbb);
static void drawBackground(CBB &cbb) noexcept {
glBindVertexArray(cbb.vao);
if (cbb.updated) {
cbb.updated = false;
glutils::sendVbo(cbb);
}
glBindTexture(GL_TEXTURE_2D, cbb->tex);
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(cbb->elements.size()), GL_UNSIGNED_INT, nullptr);
glBindTexture(GL_TEXTURE_2D, cbb.tex);
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(cbb.elements.size()), GL_UNSIGNED_INT, nullptr);
}
static void drawBackgrounds(
GlContext *gctx,
GlContext &gctx,
ox::Size const&renderSz) noexcept {
// load background shader and its uniforms
glUseProgram(gctx->bgShader);
const auto uniformXScale = static_cast<GLint>(glGetUniformLocation(gctx->bgShader, "vXScale"));
const auto uniformTileHeight = static_cast<GLint>(glGetUniformLocation(gctx->bgShader, "vTileHeight"));
glUseProgram(gctx.bgShader);
const auto uniformXScale = static_cast<GLint>(glGetUniformLocation(gctx.bgShader, "vXScale"));
const auto uniformTileHeight = static_cast<GLint>(glGetUniformLocation(gctx.bgShader, "vTileHeight"));
const auto [wi, hi] = renderSz;
const auto wf = static_cast<float>(wi);
const auto hf = static_cast<float>(hi);
glUniform1f(uniformXScale, hf / wf);
for (const auto &bg : gctx->backgrounds) {
for (const auto &bg : gctx.backgrounds) {
if (bg.enabled) {
auto &cbb = gctx->cbbs[bg.cbbIdx];
auto &cbb = gctx.cbbs[bg.cbbIdx];
const auto tileRows = cbb.tex.height / TileHeight;
glUniform1f(uniformTileHeight, 1.0f / static_cast<float>(tileRows));
drawBackground(&cbb);
drawBackground(cbb);
}
}
}
static void drawSprites(GlContext *gctx, ox::Size const&renderSz) noexcept {
glUseProgram(gctx->spriteShader);
auto &sb = gctx->spriteBlocks;
const auto uniformXScale = static_cast<GLint>(glGetUniformLocation(gctx->bgShader, "vXScale"));
const auto uniformTileHeight = static_cast<GLint>(glGetUniformLocation(gctx->spriteShader, "vTileHeight"));
static void drawSprites(GlContext &gctx, ox::Size const&renderSz) noexcept {
glUseProgram(gctx.spriteShader);
auto &sb = gctx.spriteBlocks;
const auto uniformXScale = static_cast<GLint>(glGetUniformLocation(gctx.bgShader, "vXScale"));
const auto uniformTileHeight = static_cast<GLint>(glGetUniformLocation(gctx.spriteShader, "vTileHeight"));
const auto [wi, hi] = renderSz;
const auto wf = static_cast<float>(wi);
const auto hf = static_cast<float>(hi);
@ -302,31 +312,31 @@ static void loadPalette(
glUniform4fv(uniformPalette, ColorCnt, palette.data());
}
static void loadBgPalette(GlContext *gctx, Palette const&pal) noexcept {
loadPalette(gctx->bgShader, pal);
static void loadBgPalette(GlContext &gctx, Palette const&pal) noexcept {
loadPalette(gctx.bgShader, pal);
}
static void loadSpritePalette(GlContext *gctx, Palette const&pal) noexcept {
loadPalette(gctx->spriteShader, pal, true);
static void loadSpritePalette(GlContext &gctx, Palette const&pal) noexcept {
loadPalette(gctx.spriteShader, pal, true);
}
static void loadBgTexture(
GlContext *gctx,
unsigned cbbIdx,
GlContext &gctx,
uint_t cbbIdx,
const void *pixels,
int w,
int h) noexcept {
oxTracef("nostalgia::core::gfx::gl", "loadBgTexture: { cbbIdx: {}, w: {}, h: {} }", cbbIdx, w, h);
gctx->cbbs[cbbIdx].tex = loadTexture(w, h, pixels);
gctx.cbbs[cbbIdx].tex = loadTexture(w, h, pixels);
}
static void loadSpriteTexture(
GlContext *gctx,
GlContext &gctx,
const void *pixels,
int w,
int h) noexcept {
oxTracef("nostalgia::core::gfx::gl", "loadSpriteTexture: { w: {}, h: {} }", w, h);
gctx->spriteBlocks.tex = loadTexture(w, h, pixels);
gctx.spriteBlocks.tex = loadTexture(w, h, pixels);
}
}
@ -340,22 +350,22 @@ ox::Error initGfx(
const auto bgFshad = ox::sfmt(renderer::bgfshadTmpl, glutils::GlslVersion);
const auto spriteVshad = ox::sfmt(renderer::spritevshadTmpl, glutils::GlslVersion);
const auto spriteFshad = ox::sfmt(renderer::spritefshadTmpl, glutils::GlslVersion);
auto &gctx = static_cast<GlContext&>(*ctx);
auto &gctx = glctx(*ctx);
oxReturnError(glutils::buildShaderProgram(bgVshad.c_str(), bgFshad.c_str()).moveTo(&gctx.bgShader));
oxReturnError(
glutils::buildShaderProgram(spriteVshad.c_str(), spriteFshad.c_str()).moveTo(&gctx.spriteShader));
for (auto &bg : gctx.cbbs) {
initBackgroundBufferset(gctx.bgShader, &bg);
initBackgroundBufferset(gctx.bgShader, bg);
}
if (initParams.glInstallDrawer) {
turbine::gl::addDrawer(gctx.turbineCtx, &gctx.drawer);
initSpritesBufferset(gctx.spriteShader, &gctx.spriteBlocks);
initSpritesBufferset(gctx.spriteShader, gctx.spriteBlocks);
}
return {};
}
void shutdownGfx(Context &ctx) noexcept {
auto &gctx = static_cast<GlContext&>(ctx);
auto &gctx = glctx(ctx);
turbine::gl::removeDrawer(gctx.turbineCtx, &gctx.drawer);
}
@ -366,9 +376,9 @@ struct TileSheetData {
};
static ox::Result<TileSheetData> loadTileSheet(
Context *ctx, CompactTileSheet const&tilesheet) noexcept {
auto &gctx = static_cast<GlContext&>(*ctx);
const unsigned bytesPerTile = tilesheet.bpp == 8 ? PixelsPerTile : PixelsPerTile / 2;
Context &ctx, CompactTileSheet const&tilesheet) noexcept {
auto &gctx = glctx(ctx);
const uint_t bytesPerTile = tilesheet.bpp == 8 ? PixelsPerTile : PixelsPerTile / 2;
const auto tiles = tilesheet.pixels.size() / bytesPerTile;
constexpr int width = 8;
const int height = 8 * static_cast<int>(tiles);
@ -385,22 +395,22 @@ static ox::Result<TileSheetData> loadTileSheet(
pixels[i * 2 + 1] = tilesheet.pixels[i] >> 4;
}
}
renderer::loadSpriteTexture(&gctx, pixels.data(), width, height);
renderer::loadSpriteTexture(gctx, pixels.data(), width, height);
return TileSheetData{std::move(pixels), width, height};
}
ox::Error loadBgTileSheet(
Context *ctx,
unsigned cbb,
uint_t cbb,
ox::FileAddress const&tilesheetAddr,
ox::FileAddress const&paletteAddr) noexcept {
auto &gctx = static_cast<GlContext&>(*ctx);
auto &gctx = glctx(*ctx);
auto &kctx = gctx.turbineCtx.keelCtx;
oxRequire(tilesheet, readObj<CompactTileSheet>(&kctx, tilesheetAddr));
oxRequire(palette, readObj<Palette>(&kctx, paletteAddr ? paletteAddr : tilesheet->defaultPalette));
oxRequire(tsd, loadTileSheet(ctx, *tilesheet));
renderer::loadBgTexture(&gctx, cbb, tsd.pixels.data(), tsd.width, tsd.height);
renderer::loadBgPalette(&gctx, *palette);
oxRequire(tsd, loadTileSheet(*ctx, *tilesheet));
renderer::loadBgTexture(gctx, cbb, tsd.pixels.data(), tsd.width, tsd.height);
renderer::loadBgPalette(gctx, *palette);
return {};
}
@ -408,13 +418,13 @@ ox::Error loadSpriteTileSheet(
Context *ctx,
ox::FileAddress const&tilesheetAddr,
ox::FileAddress const&paletteAddr) noexcept {
auto &gctx = static_cast<GlContext&>(*ctx);
auto &gctx = glctx(*ctx);
auto &kctx = gctx.turbineCtx.keelCtx;
oxRequire(tilesheet, readObj<CompactTileSheet>(&kctx, tilesheetAddr));
oxRequire(palette, readObj<Palette>(&kctx, paletteAddr ? paletteAddr : tilesheet->defaultPalette));
oxRequire(tsd, loadTileSheet(ctx, *tilesheet));
renderer::loadSpriteTexture(&gctx, tsd.pixels.data(), tsd.width, tsd.height);
renderer::loadSpritePalette(&gctx, *palette);
oxRequire(tsd, loadTileSheet(*ctx, *tilesheet));
renderer::loadSpriteTexture(gctx, tsd.pixels.data(), tsd.width, tsd.height);
renderer::loadSpritePalette(gctx, *palette);
return {};
}
@ -427,7 +437,7 @@ ox::Error initConsole(Context *ctx) noexcept {
}
void puts(Context *ctx, int column, int row, ox::CRStringView str) noexcept {
const auto col = static_cast<unsigned>(column);
const auto col = static_cast<uint_t>(column);
for (auto i = 0u; i < str.bytes(); ++i) {
setTile(
ctx,
@ -438,48 +448,48 @@ void puts(Context *ctx, int column, int row, ox::CRStringView str) noexcept {
}
}
void setBgCbb(Context *ctx, unsigned bgIdx, unsigned cbbIdx) noexcept {
auto &gctx = static_cast<GlContext&>(*ctx);
void setBgCbb(Context *ctx, uint_t bgIdx, uint_t cbbIdx) noexcept {
auto &gctx = glctx(*ctx);
auto &bg = gctx.backgrounds[bgIdx];
bg.cbbIdx = cbbIdx;
}
uint8_t bgStatus(Context *ctx) noexcept {
const auto &gctx = static_cast<GlContext&>(*ctx);
const auto &gctx = glctx(*ctx);
uint8_t out = 0;
for (unsigned i = 0; i < gctx.cbbs.size(); ++i) {
out |= static_cast<uint8_t>(static_cast<unsigned>(gctx.backgrounds[i].enabled) << i);
for (uint_t i = 0; i < gctx.cbbs.size(); ++i) {
out |= static_cast<uint8_t>(static_cast<uint_t>(gctx.backgrounds[i].enabled) << i);
}
return out;
}
void setBgStatus(Context *ctx, uint32_t status) noexcept {
auto &gctx = static_cast<GlContext&>(*ctx);
for (unsigned i = 0; i < gctx.cbbs.size(); ++i) {
auto &gctx = glctx(*ctx);
for (uint_t i = 0; i < gctx.cbbs.size(); ++i) {
gctx.backgrounds[i].enabled = (status >> i) & 1;
}
}
bool bgStatus(Context *ctx, unsigned bg) noexcept {
const auto &gctx = static_cast<GlContext&>(*ctx);
bool bgStatus(Context *ctx, uint_t bg) noexcept {
const auto &gctx = glctx(*ctx);
return gctx.backgrounds[bg].enabled;
}
void setBgStatus(Context *ctx, unsigned bg, bool status) noexcept {
auto &gctx = static_cast<GlContext&>(*ctx);
void setBgStatus(Context *ctx, uint_t bg, bool status) noexcept {
auto &gctx = glctx(*ctx);
gctx.backgrounds[bg].enabled = status;
}
void clearTileLayer(Context *ctx, unsigned bgIdx) noexcept {
auto &gctx = static_cast<GlContext&>(*ctx);
void clearTileLayer(Context *ctx, uint_t bgIdx) noexcept {
auto &gctx = glctx(*ctx);
auto &bg = gctx.cbbs[static_cast<std::size_t>(bgIdx)];
initBackgroundBufferObjects(&bg);
initBackgroundBufferObjects(bg);
bg.updated = true;
}
void hideSprite(Context *ctx, unsigned idx) noexcept {
auto &gctx = static_cast<GlContext&>(*ctx);
void hideSprite(Context *ctx, uint_t idx) noexcept {
auto &gctx = glctx(*ctx);
auto vbo = &gctx.spriteBlocks.vertices[idx * renderer::SpriteVertexVboLength];
auto ebo = &gctx.spriteBlocks.elements[idx * renderer::SpriteVertexEboLength];
renderer::setSpriteBufferObject(idx * renderer::SpriteVertexVboRows, 0,
@ -489,17 +499,17 @@ void hideSprite(Context *ctx, unsigned idx) noexcept {
void setSprite(
Context *ctx,
unsigned idx,
uint_t idx,
int x,
int y,
unsigned tileIdx,
unsigned spriteShape,
unsigned spriteSize,
unsigned flipX) noexcept {
uint_t tileIdx,
uint_t spriteShape,
uint_t spriteSize,
uint_t flipX) noexcept {
//oxTracef("nostalgia::core::gfx::gl", "setSprite(ctx, {}, {}, {}, {}, {}, {}, {})",
// idx, x, y, tileIdx, spriteShape, spriteSize, flipX);
// Tonc Table 8.4
static constexpr ox::Array<ox::Vec<unsigned>, 12> dimensions{
static constexpr ox::Array<ox::Vec<uint_t>, 12> dimensions{
// col 0
{1, 1}, // 0, 0
{2, 2}, // 0, 1
@ -519,7 +529,7 @@ void setSprite(
const auto dim = dimensions[(spriteShape << 2) | spriteSize];
const auto uX = static_cast<int>(x) % 255;
const auto uY = static_cast<int>(y + 8) % 255 - 8;
auto &gctx = static_cast<GlContext&>(*ctx);
auto &gctx = glctx(*ctx);
auto i = 0u;
const auto set = [&](int xIt, int yIt) {
const auto fX = static_cast<float>(uX + xIt * 8) / 8;
@ -549,7 +559,7 @@ void setSprite(
void setTile(
Context *ctx,
unsigned bgIdx,
uint_t bgIdx,
int column,
int row,
uint8_t tile) noexcept {
@ -557,16 +567,16 @@ void setTile(
"nostalgia::core::gfx::setTile",
"bgIdx: {}, column: {}, row: {}, tile: {}",
bgIdx, column, row, tile);
auto &gctx = static_cast<GlContext&>(*ctx);
const auto z = static_cast<unsigned>(bgIdx);
const auto y = static_cast<unsigned>(row);
const auto x = static_cast<unsigned>(column);
auto &gctx = glctx(*ctx);
const auto z = static_cast<uint_t>(bgIdx);
const auto y = static_cast<uint_t>(row);
const auto x = static_cast<uint_t>(column);
const auto i = renderer::bgVertexRow(x, y);
auto &bg = gctx.cbbs[z];
auto vbo = &bg.vertices[i * renderer::BgVertexVboLength];
auto ebo = &bg.elements[i * renderer::BgVertexEboLength];
renderer::setTileBufferObject(
static_cast<unsigned>(i * renderer::BgVertexVboRows),
static_cast<uint_t>(i * renderer::BgVertexVboRows),
static_cast<float>(x),
static_cast<float>(y),
tile,
@ -577,13 +587,13 @@ void setTile(
namespace gl {
void drawMainView(core::Context *ctx, ox::Size const&renderSz) noexcept {
void drawMainView(core::Context &ctx, ox::Size const&renderSz) noexcept {
glViewport(0, 0, renderSz.width, renderSz.height);
glutils::clearScreen();
auto &gctx = static_cast<GlContext&>(*ctx);
renderer::drawBackgrounds(&gctx, renderSz);
auto &gctx = glctx(ctx);
renderer::drawBackgrounds(gctx, renderSz);
if (gctx.spriteBlocks.tex) {
renderer::drawSprites(&gctx, renderSz);
renderer::drawSprites(gctx, renderSz);
}
}

View File

@ -7,6 +7,7 @@
#include <studio/studio.hpp>
#include <nostalgia/core/gfx.hpp>
#include <nostalgia/core/palette.hpp>
namespace nostalgia::core {

View File

@ -6,7 +6,9 @@
#include <studio/studio.hpp>
#include <nostalgia/core/color.hpp>
#include <nostalgia/core/gfx.hpp>
#include <nostalgia/core/palette.hpp>
namespace nostalgia::core {
@ -105,4 +107,4 @@ class MoveColorCommand: public studio::UndoCommand {
void moveColor(int idx, int offset) noexcept;
};
}
}

View File

@ -12,6 +12,7 @@
#include <studio/studio.hpp>
#include <nostalgia/core/gfx.hpp>
#include <nostalgia/core/tilesheet.hpp>
namespace nostalgia::core {

View File

@ -8,6 +8,7 @@
#include <studio/studio.hpp>
#include <nostalgia/core/gfx.hpp>
#include <nostalgia/core/tilesheet.hpp>
namespace nostalgia::core {

View File

@ -9,6 +9,7 @@
#include <glutils/glutils.hpp>
#include <studio/studio.hpp>
#include <nostalgia/core/color.hpp>
#include <nostalgia/core/gfx.hpp>
namespace nostalgia::core {

View File

@ -58,9 +58,10 @@ struct TileDoc {
};
oxModelBegin(TileDoc)
oxModelFieldRename(subsheet_id, subsheetId);
oxModelFieldRename(subsheet_path, subsheetPath);
oxModelField(type);
oxModelFieldRename(subsheet_id, subsheetId)
oxModelFieldRename(subsheet_path, subsheetPath)
oxModelField(type)
oxModelFieldRename(layer_attachments, layerAttachments)
oxModelEnd()
struct SceneDoc {

View File

@ -23,7 +23,7 @@ void SceneEditorView::draw(int width, int height) noexcept {
glutils::resizeInitFrameBuffer(&m_frameBuffer, width, height);
}
const glutils::FrameBufferBind frameBufferBind(m_frameBuffer);
core::gl::drawMainView(m_cctx.get(), {width, height});
core::gl::drawMainView(*m_cctx, {width, height});
}
const glutils::FrameBuffer &SceneEditorView::framebuffer() const noexcept {