[nostalgia] Move geo types to Ox
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ox/std/types.hpp>
|
||||
#include <nostalgia/geo/point.hpp>
|
||||
#include <ox/std/point.hpp>
|
||||
|
||||
#include "context.hpp"
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
#include <ox/fs/fs.hpp>
|
||||
#include <ox/model/desctypes.hpp>
|
||||
#include <ox/std/buffer.hpp>
|
||||
#include <ox/std/size.hpp>
|
||||
|
||||
#include <keel/context.hpp>
|
||||
#include <nostalgia/geo/size.hpp>
|
||||
|
||||
#include "event.hpp"
|
||||
#include "input.hpp"
|
||||
@@ -18,7 +18,7 @@ namespace nostalgia::core::gl {
|
||||
void setMainViewEnabled(core::Context *ctx, bool enabled) noexcept;
|
||||
void drawMainView(core::Context*) noexcept;
|
||||
void setRenderSize(core::Context*, int width, int height) noexcept;
|
||||
geo::Size getRenderSize(core::Context*) noexcept;
|
||||
ox::Size getRenderSize(core::Context*) noexcept;
|
||||
void clearRenderSize(core::Context *ctx) noexcept;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace nostalgia::core::renderer {
|
||||
ox::Error init(Context *ctx) noexcept;
|
||||
}
|
||||
|
||||
namespace nostalgia::geo {
|
||||
namespace ox {
|
||||
class Size;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ class Context: public keel::Context {
|
||||
friend constexpr void setConstantRefresh(Context *ctx, bool) noexcept;
|
||||
friend bool bgStatus(Context *ctx, unsigned bg) noexcept;
|
||||
friend bool buttonDown(Context *ctx, Key) noexcept;
|
||||
friend geo::Size getScreenSize(Context *ctx) noexcept;
|
||||
friend ox::Size getScreenSize(Context *ctx) noexcept;
|
||||
friend int getScreenHeight(Context *ctx) noexcept;
|
||||
friend int getScreenWidth(Context *ctx) noexcept;
|
||||
friend ox::Error initGfx(Context *ctx) noexcept;
|
||||
@@ -109,7 +109,7 @@ class Context: public keel::Context {
|
||||
friend void gl::setMainViewEnabled(core::Context *ctx, bool enabled) noexcept;
|
||||
friend void gl::drawMainView(core::Context*) noexcept;
|
||||
friend void gl::setRenderSize(core::Context*, int width, int height) noexcept;
|
||||
friend geo::Size gl::getRenderSize(core::Context*) noexcept;
|
||||
friend ox::Size gl::getRenderSize(core::Context*) noexcept;
|
||||
friend void gl::clearRenderSize(core::Context *ctx) noexcept;
|
||||
|
||||
public:
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
#include <ox/fs/fs.hpp>
|
||||
#include <ox/model/desctypes.hpp>
|
||||
#include <ox/std/buffer.hpp>
|
||||
#include <ox/std/size.hpp>
|
||||
|
||||
#include <keel/context.hpp>
|
||||
#include <nostalgia/geo/size.hpp>
|
||||
|
||||
#include <nostalgia/core/context.hpp>
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ int getScreenHeight(Context*) noexcept {
|
||||
return 160;
|
||||
}
|
||||
|
||||
geo::Size getScreenSize(Context*) noexcept {
|
||||
ox::Size getScreenSize(Context*) noexcept {
|
||||
return {240, 160};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#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 <nostalgia/geo/point.hpp>
|
||||
#include <nostalgia/geo/size.hpp>
|
||||
|
||||
#include "color.hpp"
|
||||
#include "context.hpp"
|
||||
#include "ptidxconv.hpp"
|
||||
@@ -69,7 +68,7 @@ int getScreenWidth(Context *ctx) noexcept;
|
||||
int getScreenHeight(Context *ctx) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
geo::Size getScreenSize(Context *ctx) noexcept;
|
||||
ox::Size getScreenSize(Context *ctx) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
uint8_t bgStatus(Context *ctx) noexcept;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <glad/glad.h>
|
||||
@@ -246,7 +246,7 @@ int getScreenHeight(Context *ctx) noexcept {
|
||||
return h;
|
||||
}
|
||||
|
||||
geo::Size getScreenSize(Context *ctx) noexcept {
|
||||
ox::Size getScreenSize(Context *ctx) noexcept {
|
||||
auto id = ctx->windowerData<GlfwImplData>();
|
||||
int w = 0, h = 0;
|
||||
glfwGetFramebufferSize(id->window, &w, &h);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <imgui_impl_opengl3.h>
|
||||
|
||||
#include <ox/std/array.hpp>
|
||||
#include <ox/std/fmt.hpp>
|
||||
#include <ox/std/vec.hpp>
|
||||
|
||||
#include <nostalgia/geo/vec.hpp>
|
||||
#include <nostalgia/glutils/glutils.hpp>
|
||||
|
||||
#include <nostalgia/core/context.hpp>
|
||||
@@ -18,10 +18,6 @@ namespace nostalgia::core {
|
||||
|
||||
void ImGui_Impl_NewFrame() noexcept;
|
||||
|
||||
namespace gl {
|
||||
|
||||
}
|
||||
|
||||
namespace renderer {
|
||||
|
||||
constexpr uint64_t TileRows = 128;
|
||||
@@ -72,7 +68,7 @@ struct GlImplData {
|
||||
SpriteBlockset spriteBlocks;
|
||||
ox::Array<Sprite, 128> spriteStates;
|
||||
ox::Array<Background, 4> backgrounds;
|
||||
ox::Optional<geo::Size> renderSize;
|
||||
ox::Optional<ox::Size> renderSize;
|
||||
};
|
||||
|
||||
constexpr ox::StringView bgvshadTmpl = R"(
|
||||
@@ -482,7 +478,7 @@ void setSprite(Context *ctx,
|
||||
//oxTracef("nostalgia::core::gfx::gl", "setSprite(ctx, {}, {}, {}, {}, {}, {}, {})",
|
||||
// idx, x, y, tileIdx, spriteShape, spriteSize, flipX);
|
||||
// Tonc Table 8.4
|
||||
static constexpr ox::Array<geo::Vec<unsigned>, 12> dimensions{
|
||||
static constexpr ox::Array<ox::Vec<unsigned>, 12> dimensions{
|
||||
// col 0
|
||||
{1, 1}, // 0, 0
|
||||
{2, 2}, // 0, 1
|
||||
@@ -575,7 +571,7 @@ void clearRenderSize(core::Context *ctx) noexcept {
|
||||
id->renderSize.reset();
|
||||
}
|
||||
|
||||
geo::Size getRenderSize(core::Context *ctx) noexcept {
|
||||
ox::Size getRenderSize(core::Context *ctx) noexcept {
|
||||
const auto id = ctx->rendererData<renderer::GlImplData>();
|
||||
if (id->renderSize.has_value()) {
|
||||
return id->renderSize.value();
|
||||
|
||||
@@ -5,11 +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 <nostalgia/geo/point.hpp>
|
||||
#include <nostalgia/geo/size.hpp>
|
||||
|
||||
#include "color.hpp"
|
||||
#include "context.hpp"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nostalgia/geo/point.hpp>
|
||||
#include <ox/std/point.hpp>
|
||||
|
||||
#include "consts.hpp"
|
||||
|
||||
@@ -22,12 +22,12 @@ constexpr std::size_t ptToIdx(int x, int y, int c) noexcept {
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr std::size_t ptToIdx(const geo::Point &pt, int c) noexcept {
|
||||
constexpr std::size_t ptToIdx(const ox::Point &pt, int c) noexcept {
|
||||
return ptToIdx(pt.x, pt.y, c * TileWidth);
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr geo::Point idxToPt(int i, int c) noexcept {
|
||||
constexpr ox::Point idxToPt(int i, int c) noexcept {
|
||||
// prevent divide by zeros
|
||||
if (!c) {
|
||||
++c;
|
||||
@@ -44,13 +44,13 @@ constexpr geo::Point idxToPt(int i, int c) noexcept {
|
||||
};
|
||||
}
|
||||
|
||||
static_assert(idxToPt(4, 1) == geo::Point{4, 0});
|
||||
static_assert(idxToPt(8, 1) == geo::Point{0, 1});
|
||||
static_assert(idxToPt(8, 2) == geo::Point{0, 1});
|
||||
static_assert(idxToPt(64, 2) == geo::Point{8, 0});
|
||||
static_assert(idxToPt(128, 2) == geo::Point{0, 8});
|
||||
static_assert(idxToPt(129, 2) == geo::Point{1, 8});
|
||||
static_assert(idxToPt(192, 2) == geo::Point{8, 8});
|
||||
static_assert(idxToPt(384, 8) == geo::Point{48, 0});
|
||||
static_assert(idxToPt(4, 1) == ox::Point{4, 0});
|
||||
static_assert(idxToPt(8, 1) == ox::Point{0, 1});
|
||||
static_assert(idxToPt(8, 2) == ox::Point{0, 1});
|
||||
static_assert(idxToPt(64, 2) == ox::Point{8, 0});
|
||||
static_assert(idxToPt(128, 2) == ox::Point{0, 8});
|
||||
static_assert(idxToPt(129, 2) == ox::Point{1, 8});
|
||||
static_assert(idxToPt(192, 2) == ox::Point{8, 8});
|
||||
static_assert(idxToPt(384, 8) == ox::Point{48, 0});
|
||||
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
#include <imgui.h>
|
||||
#include <lodepng.h>
|
||||
|
||||
#include <ox/std/point.hpp>
|
||||
#include <keel/media.hpp>
|
||||
#include <nostalgia/geo/point.hpp>
|
||||
|
||||
#include "tilesheeteditor-imgui.hpp"
|
||||
|
||||
@@ -114,7 +114,7 @@ void TileSheetEditorImGui::keyStateChanged(core::Key key, bool down) {
|
||||
void TileSheetEditorImGui::draw(core::Context*) noexcept {
|
||||
const auto paneSize = ImGui::GetContentRegionAvail();
|
||||
const auto tileSheetParentSize = ImVec2(paneSize.x - m_palViewWidth, paneSize.y);
|
||||
const auto fbSize = geo::Vec2(tileSheetParentSize.x - 16, tileSheetParentSize.y - 16);
|
||||
const auto fbSize = ox::Vec2(tileSheetParentSize.x - 16, tileSheetParentSize.y - 16);
|
||||
ImGui::BeginChild("TileSheetView", tileSheetParentSize, true);
|
||||
{
|
||||
drawTileSheet(fbSize);
|
||||
@@ -240,7 +240,7 @@ studio::UndoStack *TileSheetEditorImGui::undoStack() noexcept {
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
geo::Vec2 TileSheetEditorImGui::clickPos(const ImVec2 &winPos, geo::Vec2 clickPos) noexcept {
|
||||
ox::Vec2 TileSheetEditorImGui::clickPos(const ImVec2 &winPos, ox::Vec2 clickPos) noexcept {
|
||||
clickPos.x -= winPos.x + 10;
|
||||
clickPos.y -= winPos.y + 10;
|
||||
return clickPos;
|
||||
@@ -274,9 +274,9 @@ void TileSheetEditorImGui::exportSubhseetToPng() noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
void TileSheetEditorImGui::drawTileSheet(const geo::Vec2 &fbSize) noexcept {
|
||||
void TileSheetEditorImGui::drawTileSheet(const ox::Vec2 &fbSize) noexcept {
|
||||
const auto winPos = ImGui::GetWindowPos();
|
||||
const auto fbSizei = geo::Size(static_cast<int>(fbSize.x), static_cast<int>(fbSize.y));
|
||||
const auto fbSizei = ox::Size(static_cast<int>(fbSize.x), static_cast<int>(fbSize.y));
|
||||
if (m_framebuffer.width != fbSizei.width || m_framebuffer.height != fbSizei.height) {
|
||||
glutils::resizeInitFrameBuffer(&m_framebuffer, fbSizei.width, fbSizei.height);
|
||||
m_tileSheetEditor.resizeView(fbSize);
|
||||
@@ -296,7 +296,7 @@ void TileSheetEditorImGui::drawTileSheet(const geo::Vec2 &fbSize) noexcept {
|
||||
ImVec2(1, 0));
|
||||
// handle input, this must come after drawing
|
||||
const auto &io = ImGui::GetIO();
|
||||
const auto mousePos = geo::Vec2(io.MousePos);
|
||||
const auto mousePos = ox::Vec2(io.MousePos);
|
||||
if (ImGui::IsItemHovered()) {
|
||||
const auto wheel = io.MouseWheel;
|
||||
const auto wheelh = io.MouseWheelH;
|
||||
@@ -326,7 +326,7 @@ void TileSheetEditorImGui::drawTileSheet(const geo::Vec2 &fbSize) noexcept {
|
||||
}
|
||||
}
|
||||
if (ImGui::BeginPopupContextItem("TileMenu", ImGuiPopupFlags_MouseButtonRight)) {
|
||||
const auto popupPos = geo::Vec2(ImGui::GetWindowPos());
|
||||
const auto popupPos = ox::Vec2(ImGui::GetWindowPos());
|
||||
if (ImGui::MenuItem("Insert Tile")) {
|
||||
m_tileSheetEditor.insertTile(fbSize, clickPos(winPos, popupPos));
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ox/model/def.hpp>
|
||||
#include <ox/std/vec.hpp>
|
||||
|
||||
#include <nostalgia/geo/vec.hpp>
|
||||
#include <nostalgia/glutils/glutils.hpp>
|
||||
#include <nostalgia/studio/studio.hpp>
|
||||
|
||||
@@ -51,7 +51,7 @@ class TileSheetEditorImGui: public studio::BaseEditor {
|
||||
glutils::FrameBuffer m_framebuffer;
|
||||
TileSheetEditorView m_tileSheetEditor;
|
||||
float m_palViewWidth = 300;
|
||||
geo::Vec2 m_prevMouseDownPos;
|
||||
ox::Vec2 m_prevMouseDownPos;
|
||||
Tool m_tool = Tool::Draw;
|
||||
|
||||
public:
|
||||
@@ -80,7 +80,7 @@ class TileSheetEditorImGui: public studio::BaseEditor {
|
||||
studio::UndoStack *undoStack() noexcept final;
|
||||
|
||||
[[nodiscard]]
|
||||
static geo::Vec2 clickPos(const ImVec2 &winPos, geo::Vec2 clickPos) noexcept;
|
||||
static ox::Vec2 clickPos(const ImVec2 &winPos, ox::Vec2 clickPos) noexcept;
|
||||
|
||||
protected:
|
||||
ox::Error saveItem() noexcept override;
|
||||
@@ -112,7 +112,7 @@ class TileSheetEditorImGui: public studio::BaseEditor {
|
||||
[[nodiscard]]
|
||||
ox::String palettePath(const ox::String &palettePath) const;
|
||||
|
||||
void drawTileSheet(const geo::Vec2 &fbSize) noexcept;
|
||||
void drawTileSheet(const ox::Vec2 &fbSize) noexcept;
|
||||
|
||||
void drawPaletteSelector() noexcept;
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@ class TileSheetClipboard: public ClipboardObject<TileSheetClipboard> {
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.studio.TileSheetClipboard.Pixel";
|
||||
static constexpr auto TypeVersion = 1;
|
||||
uint16_t colorIdx = 0;
|
||||
geo::Point pt;
|
||||
constexpr Pixel(uint16_t pColorIdx, geo::Point pPt) noexcept {
|
||||
ox::Point pt;
|
||||
constexpr Pixel(uint16_t pColorIdx, ox::Point pPt) noexcept {
|
||||
colorIdx = pColorIdx;
|
||||
pt = pPt;
|
||||
}
|
||||
@@ -40,7 +40,7 @@ class TileSheetClipboard: public ClipboardObject<TileSheetClipboard> {
|
||||
ox::Vector<Pixel> m_pixels;
|
||||
|
||||
public:
|
||||
constexpr void addPixel(const geo::Point &pt, uint16_t colorIdx) noexcept {
|
||||
constexpr void addPixel(const ox::Point &pt, uint16_t colorIdx) noexcept {
|
||||
m_pixels.emplace_back(colorIdx, pt);
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ class CutPasteCommand: public TileSheetCommand {
|
||||
ox::Vector<Change> m_changes;
|
||||
|
||||
public:
|
||||
constexpr CutPasteCommand(TileSheet *img, const TileSheet::SubSheetIdx &subSheetIdx, const geo::Point &dstStart, const geo::Point &dstEnd, const TileSheetClipboard &cb) noexcept {
|
||||
constexpr CutPasteCommand(TileSheet *img, const TileSheet::SubSheetIdx &subSheetIdx, const ox::Point &dstStart, const ox::Point &dstEnd, const TileSheetClipboard &cb) noexcept {
|
||||
m_img = img;
|
||||
m_subSheetIdx = subSheetIdx;
|
||||
const auto &subsheet = m_img->getSubSheet(subSheetIdx);
|
||||
@@ -553,7 +553,7 @@ void TileSheetEditorModel::cut() {
|
||||
const auto s = activeSubSheet();
|
||||
for (int y = m_selectionBounds.y; y <= m_selectionBounds.y2(); ++y) {
|
||||
for (int x = m_selectionBounds.x; x <= m_selectionBounds.x2(); ++x) {
|
||||
auto pt = geo::Point(x, y);
|
||||
auto pt = ox::Point(x, y);
|
||||
const auto idx = s->idx(pt);
|
||||
const auto c = s->getPixel(m_img.bpp, idx);
|
||||
pt.x -= m_selectionBounds.x;
|
||||
@@ -562,8 +562,8 @@ void TileSheetEditorModel::cut() {
|
||||
blankCb.addPixel(pt, 0);
|
||||
}
|
||||
}
|
||||
const auto pt1 = m_selectionOrigin == geo::Point(-1, -1) ? geo::Point(0, 0) : m_selectionOrigin;
|
||||
const auto pt2 = geo::Point(s->columns * TileWidth, s->rows * TileHeight);
|
||||
const auto pt1 = m_selectionOrigin == ox::Point(-1, -1) ? ox::Point(0, 0) : m_selectionOrigin;
|
||||
const auto pt2 = ox::Point(s->columns * TileWidth, s->rows * TileHeight);
|
||||
setClipboardObject(m_ctx, std::move(cb));
|
||||
pushCommand(ox::make<CutPasteCommand<CommandId::Cut>>(&m_img, m_activeSubsSheetIdx, pt1, pt2, blankCb));
|
||||
}
|
||||
@@ -572,7 +572,7 @@ void TileSheetEditorModel::copy() {
|
||||
auto cb = ox::make_unique<TileSheetClipboard>();
|
||||
for (int y = m_selectionBounds.y; y <= m_selectionBounds.y2(); ++y) {
|
||||
for (int x = m_selectionBounds.x; x <= m_selectionBounds.x2(); ++x) {
|
||||
auto pt = geo::Point(x, y);
|
||||
auto pt = ox::Point(x, y);
|
||||
const auto s = activeSubSheet();
|
||||
const auto idx = s->idx(pt);
|
||||
const auto c = s->getPixel(m_img.bpp, idx);
|
||||
@@ -592,8 +592,8 @@ void TileSheetEditorModel::paste() {
|
||||
return;
|
||||
}
|
||||
const auto s = activeSubSheet();
|
||||
const auto pt1 = m_selectionOrigin == geo::Point(-1, -1) ? geo::Point(0, 0) : m_selectionOrigin;
|
||||
const auto pt2 = geo::Point(s->columns * TileWidth, s->rows * TileHeight);
|
||||
const auto pt1 = m_selectionOrigin == ox::Point(-1, -1) ? ox::Point(0, 0) : m_selectionOrigin;
|
||||
const auto pt2 = ox::Point(s->columns * TileWidth, s->rows * TileHeight);
|
||||
pushCommand(ox::make<CutPasteCommand<CommandId::Paste>>(&m_img, m_activeSubsSheetIdx, pt1, pt2, *cb));
|
||||
}
|
||||
|
||||
@@ -621,7 +621,7 @@ ox::Error TileSheetEditorModel::setPalette(const ox::String &path) noexcept {
|
||||
return OxError(0);
|
||||
}
|
||||
|
||||
void TileSheetEditorModel::drawCommand(const geo::Point &pt, std::size_t palIdx) noexcept {
|
||||
void TileSheetEditorModel::drawCommand(const ox::Point &pt, std::size_t palIdx) noexcept {
|
||||
const auto &activeSubSheet = m_img.getSubSheet(m_activeSubsSheetIdx);
|
||||
if (pt.x >= activeSubSheet.columns * TileWidth || pt.y >= activeSubSheet.rows * TileHeight) {
|
||||
return;
|
||||
@@ -664,7 +664,7 @@ void TileSheetEditorModel::setActiveSubsheet(const TileSheet::SubSheetIdx &idx)
|
||||
this->activeSubsheetChanged.emit(m_activeSubsSheetIdx);
|
||||
}
|
||||
|
||||
void TileSheetEditorModel::fill(const geo::Point &pt, int palIdx) noexcept {
|
||||
void TileSheetEditorModel::fill(const ox::Point &pt, int palIdx) noexcept {
|
||||
const auto &s = m_img.getSubSheet(m_activeSubsSheetIdx);
|
||||
// build idx list
|
||||
ox::Array<bool, PixelsPerTile> updateMap = {};
|
||||
@@ -689,7 +689,7 @@ void TileSheetEditorModel::fill(const geo::Point &pt, int palIdx) noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
void TileSheetEditorModel::select(const geo::Point &pt) noexcept {
|
||||
void TileSheetEditorModel::select(const ox::Point &pt) noexcept {
|
||||
if (!m_selectionOngoing) {
|
||||
m_selectionOrigin = pt;
|
||||
m_selectionOngoing = true;
|
||||
@@ -755,16 +755,16 @@ bool TileSheetEditorModel::pixelSelected(std::size_t idx) const noexcept {
|
||||
return m_selectionBounds.contains(pt);
|
||||
}
|
||||
|
||||
void TileSheetEditorModel::getFillPixels(bool *pixels, const geo::Point &pt, int oldColor) const noexcept {
|
||||
void TileSheetEditorModel::getFillPixels(bool *pixels, const ox::Point &pt, int oldColor) const noexcept {
|
||||
const auto &activeSubSheet = *this->activeSubSheet();
|
||||
const auto tileIdx = [activeSubSheet](const geo::Point &pt) noexcept {
|
||||
const auto tileIdx = [activeSubSheet](const ox::Point &pt) noexcept {
|
||||
return ptToIdx(pt, activeSubSheet.columns) / PixelsPerTile;
|
||||
};
|
||||
// get points
|
||||
const auto leftPt = pt + geo::Point(-1, 0);
|
||||
const auto rightPt = pt + geo::Point(1, 0);
|
||||
const auto topPt = pt + geo::Point(0, -1);
|
||||
const auto bottomPt = pt + geo::Point(0, 1);
|
||||
const auto leftPt = pt + ox::Point(-1, 0);
|
||||
const auto rightPt = pt + ox::Point(1, 0);
|
||||
const auto topPt = pt + ox::Point(0, -1);
|
||||
const auto bottomPt = pt + ox::Point(0, 1);
|
||||
// calculate indices
|
||||
const auto idx = ptToIdx(pt, activeSubSheet.columns);
|
||||
const auto leftIdx = ptToIdx(leftPt, activeSubSheet.columns);
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ox/std/bounds.hpp>
|
||||
#include <ox/std/point.hpp>
|
||||
#include <ox/std/trace.hpp>
|
||||
#include <ox/std/string.hpp>
|
||||
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
#include <nostalgia/geo/bounds.hpp>
|
||||
#include <nostalgia/geo/point.hpp>
|
||||
#include <nostalgia/studio/studio.hpp>
|
||||
|
||||
namespace nostalgia::core {
|
||||
@@ -30,8 +30,8 @@ class TileSheetEditorModel: public ox::SignalHandler {
|
||||
Context *m_ctx = nullptr;
|
||||
ox::String m_path;
|
||||
bool m_selectionOngoing = false;
|
||||
geo::Point m_selectionOrigin = {-1, -1};
|
||||
geo::Bounds m_selectionBounds = {{-1, -1}, {-1, -1}};
|
||||
ox::Point m_selectionOrigin = {-1, -1};
|
||||
ox::Bounds m_selectionBounds = {{-1, -1}, {-1, -1}};
|
||||
|
||||
public:
|
||||
TileSheetEditorModel(Context *ctx, ox::String path);
|
||||
@@ -58,7 +58,7 @@ class TileSheetEditorModel: public ox::SignalHandler {
|
||||
|
||||
ox::Error setPalette(const ox::String &path) noexcept;
|
||||
|
||||
void drawCommand(const geo::Point &pt, std::size_t palIdx) noexcept;
|
||||
void drawCommand(const ox::Point &pt, std::size_t palIdx) noexcept;
|
||||
|
||||
void endDrawCommand() noexcept;
|
||||
|
||||
@@ -91,9 +91,9 @@ class TileSheetEditorModel: public ox::SignalHandler {
|
||||
return m_activeSubsSheetIdx;
|
||||
}
|
||||
|
||||
void fill(const geo::Point &pt, int palIdx) noexcept;
|
||||
void fill(const ox::Point &pt, int palIdx) noexcept;
|
||||
|
||||
void select(const geo::Point &pt) noexcept;
|
||||
void select(const ox::Point &pt) noexcept;
|
||||
|
||||
void completeSelection() noexcept;
|
||||
|
||||
@@ -116,7 +116,7 @@ class TileSheetEditorModel: public ox::SignalHandler {
|
||||
bool pixelSelected(std::size_t idx) const noexcept;
|
||||
|
||||
protected:
|
||||
void getFillPixels(bool *pixels, const geo::Point &pt, int oldColor) const noexcept;
|
||||
void getFillPixels(bool *pixels, const ox::Point &pt, int oldColor) const noexcept;
|
||||
|
||||
private:
|
||||
void pushCommand(studio::UndoCommand *cmd) noexcept;
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nostalgia/core/consts.hpp>
|
||||
#include <ox/std/point.hpp>
|
||||
#include <keel/media.hpp>
|
||||
#include <nostalgia/geo/point.hpp>
|
||||
|
||||
#include <nostalgia/core/consts.hpp>
|
||||
|
||||
#include "tilesheeteditorview.hpp"
|
||||
|
||||
@@ -25,7 +26,7 @@ void TileSheetEditorView::draw() noexcept {
|
||||
m_pixelGridDrawer.draw(updated(), m_scrollOffset);
|
||||
}
|
||||
|
||||
void TileSheetEditorView::scrollV(const geo::Vec2 &paneSz, float wheel, bool zoomMod) noexcept {
|
||||
void TileSheetEditorView::scrollV(const ox::Vec2 &paneSz, float wheel, bool zoomMod) noexcept {
|
||||
const auto pixelSize = m_pixelsDrawer.pixelSize(paneSz);
|
||||
const ImVec2 sheetSize(pixelSize.x * static_cast<float>(m_model.activeSubSheet()->columns) * TileWidth,
|
||||
pixelSize.y * static_cast<float>(m_model.activeSubSheet()->rows) * TileHeight);
|
||||
@@ -42,7 +43,7 @@ void TileSheetEditorView::scrollV(const geo::Vec2 &paneSz, float wheel, bool zoo
|
||||
m_scrollOffset.y = ox::clamp(m_scrollOffset.y, 0.f, sheetSize.y / 2);
|
||||
}
|
||||
|
||||
void TileSheetEditorView::scrollH(const geo::Vec2 &paneSz, float wheelh) noexcept {
|
||||
void TileSheetEditorView::scrollH(const ox::Vec2 &paneSz, float wheelh) noexcept {
|
||||
const auto pixelSize = m_pixelsDrawer.pixelSize(paneSz);
|
||||
const ImVec2 sheetSize(pixelSize.x * static_cast<float>(m_model.activeSubSheet()->columns) * TileWidth,
|
||||
pixelSize.y * static_cast<float>(m_model.activeSubSheet()->rows) * TileHeight);
|
||||
@@ -50,31 +51,31 @@ void TileSheetEditorView::scrollH(const geo::Vec2 &paneSz, float wheelh) noexcep
|
||||
m_scrollOffset.x = ox::clamp(m_scrollOffset.x, -(sheetSize.x / 2), 0.f);
|
||||
}
|
||||
|
||||
void TileSheetEditorView::insertTile(const geo::Vec2 &paneSize, const geo::Vec2 &clickPos) noexcept {
|
||||
void TileSheetEditorView::insertTile(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept {
|
||||
const auto pt = clickPoint(paneSize, clickPos);
|
||||
const auto s = m_model.activeSubSheet();
|
||||
const auto tileIdx = ptToIdx(pt, s->columns) / PixelsPerTile;
|
||||
m_model.insertTiles(m_model.activeSubSheetIdx(), tileIdx, 1);
|
||||
}
|
||||
|
||||
void TileSheetEditorView::deleteTile(const geo::Vec2 &paneSize, const geo::Vec2 &clickPos) noexcept {
|
||||
void TileSheetEditorView::deleteTile(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept {
|
||||
const auto pt = clickPoint(paneSize, clickPos);
|
||||
const auto s = m_model.activeSubSheet();
|
||||
const auto tileIdx = ptToIdx(pt, s->columns) / PixelsPerTile;
|
||||
m_model.deleteTiles(m_model.activeSubSheetIdx(), tileIdx, 1);
|
||||
}
|
||||
|
||||
void TileSheetEditorView::clickDraw(const geo::Vec2 &paneSize, const geo::Vec2 &clickPos) noexcept {
|
||||
void TileSheetEditorView::clickDraw(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept {
|
||||
const auto pt = clickPoint(paneSize, clickPos);
|
||||
m_model.drawCommand(pt, m_palIdx);
|
||||
}
|
||||
|
||||
void TileSheetEditorView::clickSelect(const geo::Vec2 &paneSize, const geo::Vec2 &clickPos) noexcept {
|
||||
void TileSheetEditorView::clickSelect(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept {
|
||||
const auto pt = clickPoint(paneSize, clickPos);
|
||||
m_model.select(pt);
|
||||
}
|
||||
|
||||
void TileSheetEditorView::clickFill(const geo::Vec2 &paneSize, const geo::Vec2 &clickPos) noexcept {
|
||||
void TileSheetEditorView::clickFill(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept {
|
||||
const auto pt = clickPoint(paneSize, clickPos);
|
||||
m_model.fill(pt, static_cast<int>(m_palIdx));
|
||||
}
|
||||
@@ -84,7 +85,7 @@ void TileSheetEditorView::releaseMouseButton() noexcept {
|
||||
m_model.completeSelection();
|
||||
}
|
||||
|
||||
void TileSheetEditorView::resizeView(const geo::Vec2 &sz) noexcept {
|
||||
void TileSheetEditorView::resizeView(const ox::Vec2 &sz) noexcept {
|
||||
m_viewSize = sz;
|
||||
initView();
|
||||
}
|
||||
@@ -109,7 +110,7 @@ void TileSheetEditorView::initView() noexcept {
|
||||
m_pixelGridDrawer.initBufferSet(m_viewSize, *m_model.activeSubSheet());
|
||||
}
|
||||
|
||||
geo::Point TileSheetEditorView::clickPoint(const geo::Vec2 &paneSize, const geo::Vec2 &clickPos) const noexcept {
|
||||
ox::Point TileSheetEditorView::clickPoint(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) const noexcept {
|
||||
auto [x, y] = clickPos;
|
||||
const auto pixDrawSz = m_pixelsDrawer.pixelSize(paneSize);
|
||||
x /= paneSize.x;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ox/std/vec.hpp>
|
||||
#include <ox/model/def.hpp>
|
||||
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
#include <nostalgia/geo/vec.hpp>
|
||||
#include <nostalgia/glutils/glutils.hpp>
|
||||
#include <nostalgia/studio/studio.hpp>
|
||||
|
||||
@@ -42,10 +42,10 @@ class TileSheetEditorView: public ox::SignalHandler {
|
||||
TileSheetEditorModel m_model;
|
||||
TileSheetGrid m_pixelGridDrawer;
|
||||
TileSheetPixels m_pixelsDrawer;
|
||||
geo::Vec2 m_viewSize;
|
||||
ox::Vec2 m_viewSize;
|
||||
float m_pixelSizeMod = 1;
|
||||
bool m_updated = false;
|
||||
geo::Vec2 m_scrollOffset;
|
||||
ox::Vec2 m_scrollOffset;
|
||||
std::size_t m_palIdx = 0;
|
||||
|
||||
public:
|
||||
@@ -55,23 +55,23 @@ class TileSheetEditorView: public ox::SignalHandler {
|
||||
|
||||
void draw() noexcept;
|
||||
|
||||
void insertTile(const geo::Vec2 &paneSize, const geo::Vec2 &clickPos) noexcept;
|
||||
void insertTile(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept;
|
||||
|
||||
void deleteTile(const geo::Vec2 &paneSize, const geo::Vec2 &clickPos) noexcept;
|
||||
void deleteTile(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept;
|
||||
|
||||
void clickDraw(const geo::Vec2 &paneSize, const geo::Vec2 &clickPos) noexcept;
|
||||
void clickDraw(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept;
|
||||
|
||||
void clickSelect(const geo::Vec2 &paneSize, const geo::Vec2 &clickPos) noexcept;
|
||||
void clickSelect(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept;
|
||||
|
||||
void clickFill(const geo::Vec2 &paneSize, const geo::Vec2 &clickPos) noexcept;
|
||||
void clickFill(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept;
|
||||
|
||||
void releaseMouseButton() noexcept;
|
||||
|
||||
void scrollV(const geo::Vec2 &paneSz, float wheel, bool zoomMod) noexcept;
|
||||
void scrollV(const ox::Vec2 &paneSz, float wheel, bool zoomMod) noexcept;
|
||||
|
||||
void scrollH(const geo::Vec2 &paneSz, float wheel) noexcept;
|
||||
void scrollH(const ox::Vec2 &paneSz, float wheel) noexcept;
|
||||
|
||||
void resizeView(const geo::Vec2 &sz) noexcept;
|
||||
void resizeView(const ox::Vec2 &sz) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr const TileSheet &img() const noexcept;
|
||||
@@ -111,7 +111,7 @@ class TileSheetEditorView: public ox::SignalHandler {
|
||||
private:
|
||||
void initView() noexcept;
|
||||
|
||||
geo::Point clickPoint(const geo::Vec2 &paneSize, const geo::Vec2 &clickPos) const noexcept;
|
||||
ox::Point clickPoint(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) const noexcept;
|
||||
|
||||
ox::Error setActiveSubsheet(const TileSheet::SubSheetIdx &idx) noexcept;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nostalgia/core/consts.hpp>
|
||||
@@ -18,7 +18,7 @@ ox::Error TileSheetGrid::buildShader() noexcept {
|
||||
return glutils::buildShaderProgram(pixelLineVshad, pixelLineFshad, pixelLineGshad).moveTo(&m_shader);
|
||||
}
|
||||
|
||||
void TileSheetGrid::draw(bool update, const geo::Vec2 &scroll) noexcept {
|
||||
void TileSheetGrid::draw(bool update, const ox::Vec2 &scroll) noexcept {
|
||||
glLineWidth(3 * m_pixelSizeMod * 0.5f);
|
||||
glUseProgram(m_shader);
|
||||
glBindVertexArray(m_bufferSet.vao);
|
||||
@@ -32,7 +32,7 @@ void TileSheetGrid::draw(bool update, const geo::Vec2 &scroll) noexcept {
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
void TileSheetGrid::initBufferSet(const geo::Vec2 &paneSize, const TileSheet::SubSheet &subsheet) noexcept {
|
||||
void TileSheetGrid::initBufferSet(const ox::Vec2 &paneSize, const TileSheet::SubSheet &subsheet) noexcept {
|
||||
// vao
|
||||
m_bufferSet.vao = glutils::generateVertexArrayObject();
|
||||
glBindVertexArray(m_bufferSet.vao);
|
||||
@@ -54,7 +54,7 @@ void TileSheetGrid::initBufferSet(const geo::Vec2 &paneSize, const TileSheet::Su
|
||||
reinterpret_cast<void*>(4 * sizeof(float)));
|
||||
}
|
||||
|
||||
void TileSheetGrid::setBufferObject(geo::Point pt1, geo::Point pt2, Color32 c, float *vbo, const geo::Vec2 &pixSize) noexcept {
|
||||
void TileSheetGrid::setBufferObject(ox::Point pt1, ox::Point pt2, Color32 c, float *vbo, const ox::Vec2 &pixSize) noexcept {
|
||||
const auto x1 = static_cast<float>(pt1.x) * pixSize.x - 1.f;
|
||||
const auto y1 = 1.f - static_cast<float>(pt1.y) * pixSize.y;
|
||||
const auto x2 = static_cast<float>(pt2.x) * pixSize.x - 1.f;
|
||||
@@ -64,9 +64,9 @@ void TileSheetGrid::setBufferObject(geo::Point pt1, geo::Point pt2, Color32 c, f
|
||||
memcpy(vbo, vertices, sizeof(vertices));
|
||||
}
|
||||
|
||||
void TileSheetGrid::setBufferObjects(const geo::Vec2 &paneSize, const TileSheet::SubSheet &subsheet) noexcept {
|
||||
void TileSheetGrid::setBufferObjects(const ox::Vec2 &paneSize, const TileSheet::SubSheet &subsheet) noexcept {
|
||||
const auto pixSize = pixelSize(paneSize);
|
||||
const auto set = [&](unsigned i, geo::Point pt1, geo::Point pt2, Color32 c) {
|
||||
const auto set = [&](unsigned i, ox::Point pt1, ox::Point pt2, Color32 c) {
|
||||
const auto vbo = &m_bufferSet.vertices[i * VertexVboLength];
|
||||
setBufferObject(pt1, pt2, c, vbo, pixSize);
|
||||
};
|
||||
@@ -100,7 +100,7 @@ void TileSheetGrid::setBufferObjects(const geo::Vec2 &paneSize, const TileSheet:
|
||||
}
|
||||
}
|
||||
|
||||
geo::Vec2 TileSheetGrid::pixelSize(const geo::Vec2 &paneSize) const noexcept {
|
||||
ox::Vec2 TileSheetGrid::pixelSize(const ox::Vec2 &paneSize) const noexcept {
|
||||
const auto [sw, sh] = paneSize;
|
||||
constexpr float ymod = 0.35f / 10.0f;
|
||||
const auto xmod = ymod * sh / sw;
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
#include <nostalgia/geo/point.hpp>
|
||||
#include <nostalgia/geo/vec.hpp>
|
||||
#include <nostalgia/glutils/glutils.hpp>
|
||||
#include <nostalgia/studio/studio.hpp>
|
||||
|
||||
@@ -67,17 +65,17 @@ class TileSheetGrid {
|
||||
|
||||
ox::Error buildShader() noexcept;
|
||||
|
||||
void draw(bool update, const geo::Vec2 &scroll) noexcept;
|
||||
void draw(bool update, const ox::Vec2 &scroll) noexcept;
|
||||
|
||||
void initBufferSet(const geo::Vec2 &paneSize, const TileSheet::SubSheet &subsheet) noexcept;
|
||||
void initBufferSet(const ox::Vec2 &paneSize, const TileSheet::SubSheet &subsheet) noexcept;
|
||||
|
||||
private:
|
||||
static void setBufferObject(geo::Point pt1, geo::Point pt2, Color32 c, float *vbo, const geo::Vec2 &pixSize) noexcept;
|
||||
static void setBufferObject(ox::Point pt1, ox::Point pt2, Color32 c, float *vbo, const ox::Vec2 &pixSize) noexcept;
|
||||
|
||||
void setBufferObjects(const geo::Vec2 &paneSize, const TileSheet::SubSheet &subsheet) noexcept;
|
||||
void setBufferObjects(const ox::Vec2 &paneSize, const TileSheet::SubSheet &subsheet) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
geo::Vec2 pixelSize(const geo::Vec2 &paneSize) const noexcept;
|
||||
ox::Vec2 pixelSize(const ox::Vec2 &paneSize) const noexcept;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nostalgia/core/consts.hpp>
|
||||
@@ -22,7 +22,7 @@ ox::Error TileSheetPixels::buildShader() noexcept {
|
||||
return glutils::buildShaderProgram(Vshad, Fshad).moveTo(&m_shader);
|
||||
}
|
||||
|
||||
void TileSheetPixels::draw(bool update, const geo::Vec2 &scroll) noexcept {
|
||||
void TileSheetPixels::draw(bool update, const ox::Vec2 &scroll) noexcept {
|
||||
glUseProgram(m_shader);
|
||||
glBindVertexArray(m_bufferSet.vao);
|
||||
if (update) {
|
||||
@@ -35,7 +35,7 @@ void TileSheetPixels::draw(bool update, const geo::Vec2 &scroll) noexcept {
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
void TileSheetPixels::initBufferSet(geo::Vec2 const&paneSize) noexcept {
|
||||
void TileSheetPixels::initBufferSet(ox::Vec2 const&paneSize) noexcept {
|
||||
m_bufferSet.vao = glutils::generateVertexArrayObject();
|
||||
m_bufferSet.vbo = glutils::generateBuffer();
|
||||
m_bufferSet.ebo = glutils::generateBuffer();
|
||||
@@ -50,14 +50,14 @@ void TileSheetPixels::initBufferSet(geo::Vec2 const&paneSize) noexcept {
|
||||
reinterpret_cast<void*>(2 * sizeof(float)));
|
||||
}
|
||||
|
||||
void TileSheetPixels::update(geo::Vec2 const&paneSize) noexcept {
|
||||
void TileSheetPixels::update(ox::Vec2 const&paneSize) noexcept {
|
||||
glBindVertexArray(m_bufferSet.vao);
|
||||
setBufferObjects(paneSize);
|
||||
glutils::sendVbo(m_bufferSet);
|
||||
glutils::sendEbo(m_bufferSet);
|
||||
}
|
||||
|
||||
geo::Vec2 TileSheetPixels::pixelSize(const geo::Vec2 &paneSize) const noexcept {
|
||||
ox::Vec2 TileSheetPixels::pixelSize(const ox::Vec2 &paneSize) const noexcept {
|
||||
const auto [sw, sh] = paneSize;
|
||||
constexpr float ymod = 0.35f / 10.0f;
|
||||
const auto xmod = ymod * sh / sw;
|
||||
@@ -65,7 +65,7 @@ geo::Vec2 TileSheetPixels::pixelSize(const geo::Vec2 &paneSize) const noexcept {
|
||||
}
|
||||
|
||||
void TileSheetPixels::setPixelBufferObject(
|
||||
geo::Vec2 const&paneSize,
|
||||
ox::Vec2 const&paneSize,
|
||||
unsigned vertexRow,
|
||||
float x, float y,
|
||||
Color16 color,
|
||||
@@ -92,7 +92,7 @@ void TileSheetPixels::setPixelBufferObject(
|
||||
memcpy(ebo, elms.data(), sizeof(elms));
|
||||
}
|
||||
|
||||
void TileSheetPixels::setBufferObjects(const geo::Vec2 &paneSize) noexcept {
|
||||
void TileSheetPixels::setBufferObjects(const ox::Vec2 &paneSize) noexcept {
|
||||
// set buffer lengths
|
||||
const auto subSheet = m_model->activeSubSheet();
|
||||
const auto pal = m_model->pal();
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ox/std/vec.hpp>
|
||||
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
#include <nostalgia/geo/vec.hpp>
|
||||
#include <nostalgia/glutils/glutils.hpp>
|
||||
#include <nostalgia/studio/studio.hpp>
|
||||
|
||||
@@ -49,19 +50,19 @@ class TileSheetPixels {
|
||||
|
||||
ox::Error buildShader() noexcept;
|
||||
|
||||
void draw(bool update, const geo::Vec2 &scroll) noexcept;
|
||||
void draw(bool update, const ox::Vec2 &scroll) noexcept;
|
||||
|
||||
void initBufferSet(geo::Vec2 const&paneSize) noexcept;
|
||||
void initBufferSet(ox::Vec2 const&paneSize) noexcept;
|
||||
|
||||
void update(geo::Vec2 const&paneSize) noexcept;
|
||||
void update(ox::Vec2 const&paneSize) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
geo::Vec2 pixelSize(const geo::Vec2 &paneSize) const noexcept;
|
||||
ox::Vec2 pixelSize(const ox::Vec2 &paneSize) const noexcept;
|
||||
|
||||
private:
|
||||
void setPixelBufferObject(const geo::Vec2 &paneS, unsigned vertexRow, float x, float y, Color16 color, float *vbo, GLuint *ebo) const noexcept;
|
||||
void setPixelBufferObject(const ox::Vec2 &paneS, unsigned vertexRow, float x, float y, Color16 color, float *vbo, GLuint *ebo) const noexcept;
|
||||
|
||||
void setBufferObjects(const geo::Vec2 &paneS) noexcept;
|
||||
void setBufferObjects(const ox::Vec2 &paneS) noexcept;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -5,11 +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 <nostalgia/geo/point.hpp>
|
||||
#include <nostalgia/geo/size.hpp>
|
||||
|
||||
#include "color.hpp"
|
||||
#include "context.hpp"
|
||||
@@ -122,7 +122,7 @@ struct TileSheet {
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr auto idx(const geo::Point &pt) const noexcept {
|
||||
constexpr auto idx(const ox::Point &pt) const noexcept {
|
||||
return ptToIdx(pt, columns);
|
||||
}
|
||||
|
||||
@@ -203,19 +203,19 @@ struct TileSheet {
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr auto getPixel4Bpp(const geo::Point &pt) const noexcept {
|
||||
constexpr auto getPixel4Bpp(const ox::Point &pt) const noexcept {
|
||||
const auto idx = ptToIdx(pt, columns);
|
||||
return getPixel4Bpp(idx);
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr auto getPixel8Bpp(const geo::Point &pt) const noexcept {
|
||||
constexpr auto getPixel8Bpp(const ox::Point &pt) const noexcept {
|
||||
const auto idx = ptToIdx(pt, columns);
|
||||
return getPixel8Bpp(idx);
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr auto getPixel(int8_t pBpp, const geo::Point &pt) const noexcept {
|
||||
constexpr auto getPixel(int8_t pBpp, const ox::Point &pt) const noexcept {
|
||||
const auto idx = ptToIdx(pt, columns);
|
||||
return getPixel(pBpp, idx);
|
||||
}
|
||||
@@ -254,7 +254,7 @@ struct TileSheet {
|
||||
}
|
||||
}
|
||||
|
||||
constexpr void setPixel(int8_t pBpp, const geo::Point &pt, uint8_t palIdx) noexcept {
|
||||
constexpr void setPixel(int8_t pBpp, const ox::Point &pt, uint8_t palIdx) noexcept {
|
||||
const auto idx = ptToIdx(pt, columns);
|
||||
setPixel(pBpp, idx, palIdx);
|
||||
}
|
||||
@@ -471,7 +471,7 @@ struct TileSheet {
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr auto getPixel4Bpp(
|
||||
const geo::Point &pt,
|
||||
const ox::Point &pt,
|
||||
const SubSheetIdx &subsheetIdx) const noexcept {
|
||||
oxAssert(bpp == 4, "TileSheet::getPixel4Bpp: wrong bpp");
|
||||
auto &s = this->getSubSheet(subsheetIdx);
|
||||
@@ -481,7 +481,7 @@ struct TileSheet {
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr auto getPixel8Bpp(
|
||||
const geo::Point &pt,
|
||||
const ox::Point &pt,
|
||||
const SubSheetIdx &subsheetIdx) const noexcept {
|
||||
oxAssert(bpp == 8, "TileSheet::getPixel8Bpp: wrong bpp");
|
||||
auto &s = this->getSubSheet(subsheetIdx);
|
||||
|
||||
Reference in New Issue
Block a user