[nostalgia/core/userland] Replace std::array with ox::Array

This commit is contained in:
Gary Talent 2022-02-03 21:46:03 -06:00
parent 27f5523e70
commit a3643a4036
3 changed files with 7 additions and 8 deletions

View File

@ -46,7 +46,8 @@ ox::Error loadBgTileSheet(Context *ctx,
pixels[i * 2 + 1] = toColor32(palette->colors[tilesheet->pixels[i] >> 4]); pixels[i * 2 + 1] = toColor32(palette->colors[tilesheet->pixels[i] >> 4]);
} }
} }
return renderer::loadBgTexture(ctx->rendererData<void>(), section, pixels.data(), width, height); renderer::loadBgTexture(ctx->rendererData<void>(), section, pixels.data(), width, height);
return OxError(0);
} }
void puts(Context *ctx, int column, int row, const char *str) noexcept { void puts(Context *ctx, int column, int row, const char *str) noexcept {

View File

@ -14,6 +14,6 @@ ox::Error init(Context *ctx, void **rendererData) noexcept;
void shutdown(Context *ctx, void *rendererData) noexcept; void shutdown(Context *ctx, void *rendererData) noexcept;
ox::Error loadBgTexture(void *rendererData, int section, void *pixels, int w, int h) noexcept; void loadBgTexture(void *rendererData, int section, void *pixels, int w, int h) noexcept;
} }

View File

@ -2,12 +2,11 @@
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/ */
#include <array>
#include <imgui_impl_opengl3.h> #include <imgui_impl_opengl3.h>
#include <nostalgia/glutils/glutils.hpp> #include <nostalgia/glutils/glutils.hpp>
#include <ox/std/array.hpp>
#include <ox/std/fmt.hpp> #include <ox/std/fmt.hpp>
#include <nostalgia/core/config.hpp> #include <nostalgia/core/config.hpp>
@ -33,7 +32,7 @@ struct Background: public glutils::BufferSet {
bool enabled = false; bool enabled = false;
bool updated = false; bool updated = false;
inline Background() noexcept { Background() noexcept {
vertices.resize(TileCount * BgVertexVboLength); vertices.resize(TileCount * BgVertexVboLength);
elements.resize(TileCount * BgVertexEboLength); elements.resize(TileCount * BgVertexEboLength);
} }
@ -43,7 +42,7 @@ struct GlImplData {
glutils::GLProgram bgShader; glutils::GLProgram bgShader;
int64_t prevFpsCheckTime = 0; int64_t prevFpsCheckTime = 0;
uint64_t draws = 0; uint64_t draws = 0;
std::array<Background, 4> backgrounds; ox::Array<Background, 4> backgrounds;
}; };
constexpr const GLchar *bgvshad = R"( constexpr const GLchar *bgvshad = R"(
@ -200,12 +199,11 @@ void shutdown(Context*, void *rendererData) noexcept {
delete id; delete id;
} }
ox::Error loadBgTexture(void *rendererData, int section, void *pixels, int w, int h) noexcept { void loadBgTexture(void *rendererData, int section, void *pixels, int w, int h) noexcept {
oxTracef("nostalgia::core::gfx::gl", "loadBgTexture: { section: {}, w: {}, h: {} }", section, w, h); oxTracef("nostalgia::core::gfx::gl", "loadBgTexture: { section: {}, w: {}, h: {} }", section, w, h);
const auto id = static_cast<GlImplData*>(rendererData); const auto id = static_cast<GlImplData*>(rendererData);
auto &tex = id->backgrounds[static_cast<std::size_t>(section)].tex; auto &tex = id->backgrounds[static_cast<std::size_t>(section)].tex;
tex = loadTexture(w, h, pixels); tex = loadTexture(w, h, pixels);
return OxError(0);
} }
} }