Compare commits

..

No commits in common. "d7f309750e988e189e9c22b49f3cf56b4d958a5b" and "84205879d46610dfe08098d1265c0398f2215d3d" have entirely different histories.

18 changed files with 42 additions and 182 deletions

View File

@ -57,7 +57,6 @@ misc-*,
readability-duplicate-include,
-misc-non-private-member-variables-in-classes,
-misc-no-recursion,
-misc-include-cleaner,
bugprone-*,
clang-analyzer-*,
modernize-*,

View File

@ -210,7 +210,7 @@ struct BufferSet {
};
void sendVbo(BufferSet const&bs) noexcept;
void sendEbo(BufferSet const&bs) noexcept;
void clearScreen() noexcept;

View File

@ -147,19 +147,4 @@ constexpr auto ModelTypeName_v = getModelTypeName<T, Str>();
template<typename T, typename Str = const char*>
constexpr auto ModelTypeVersion_v = requireModelTypeVersion<T>();
template<typename T, typename Str = const char*>
constexpr auto ModelTypeVersionStr_v = [] {
constexpr auto version = ModelTypeVersion_v<T>;
constexpr auto versionStr = ox::sfmt("{}", version);
return ox::BString<versionStr.len()>{versionStr};
};
template<typename T>
constexpr auto ModelTypeId_v = [] {
constexpr auto name = ModelTypeName_v<T, ox::StringView>;
constexpr auto version = ModelTypeVersion_v<T>;
constexpr auto versionStr = ox::sfmt<ox::BString<19>>("{}", version);
return ox::sfmt<ox::BString<name.len() + versionStr.len() + 1>>("{};{}", name, versionStr);
}();
}

View File

@ -103,7 +103,6 @@ install(
hardware.hpp
hashmap.hpp
heapmgr.hpp
ignore.hpp
iterator.hpp
math.hpp
maybeview.hpp

View File

@ -77,7 +77,7 @@ class FmtArg {
char dataStr[10] = {};
template<typename T>
constexpr StringView sv(const T &v, char *dataStr) noexcept {
static StringView sv(const T &v, char *dataStr) noexcept {
if constexpr(is_bool_v<T>) {
return v ? "true" : "false";
} else if constexpr(is_integer_v<T>) {

View File

@ -1,20 +0,0 @@
/*
* Copyright 2016 - 2024 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#pragma once
#if __has_include(<tuple>)
#include <tuple>
#else
namespace std {
inline constexpr struct {
constexpr void operator=(auto&&) const noexcept {}
} ignore;
}
#endif

View File

@ -11,5 +11,5 @@
#if __has_include(<cassert>)
#include <cassert>
#else
#define assert(e) while (!(e));
#define assert(e) while (1);
#endif

View File

@ -26,7 +26,6 @@
#include "hardware.hpp"
#include "hashmap.hpp"
#include "heapmgr.hpp"
#include "ignore.hpp"
#include "iterator.hpp"
#include "math.hpp"
#include "maybeview.hpp"

View File

@ -80,7 +80,6 @@ constexpr bool endsWith(CRStringView base, CRStringView ending) noexcept {
return base.len() >= endingLen && ox::strcmp(base.data() + (base.len() - endingLen), ending) == 0;
}
[[nodiscard]]
constexpr std::size_t find(CRStringView str, char search) noexcept {
std::size_t i = 0;
for (; i < str.len(); ++i) {
@ -91,7 +90,6 @@ constexpr std::size_t find(CRStringView str, char search) noexcept {
return i;
}
[[nodiscard]]
constexpr std::size_t find(CRStringView str, CRStringView search) noexcept {
std::size_t i = 0;
for (; i < str.len(); ++i) {
@ -103,7 +101,6 @@ constexpr std::size_t find(CRStringView str, CRStringView search) noexcept {
}
template<std::size_t smallSz = 0>
[[nodiscard]]
constexpr ox::Vector<ox::StringView, smallSz> split(CRStringView str, char del) noexcept {
ox::Vector<ox::StringView, smallSz> out;
constexpr auto nextSeg = [](CRStringView current, char del) {
@ -120,7 +117,6 @@ constexpr ox::Vector<ox::StringView, smallSz> split(CRStringView str, char del)
}
template<std::size_t smallSz = 0>
[[nodiscard]]
constexpr ox::Vector<ox::StringView, smallSz> split(CRStringView str, CRStringView del) noexcept {
ox::Vector<ox::StringView, smallSz> out;
constexpr auto nextSeg = [](CRStringView current, CRStringView del) {

View File

@ -143,7 +143,7 @@ template<typename T>
constexpr bool memberable(...) { return false; }
template<typename T>
struct is_class: integral_constant<bool, !is_union_v<T> && memberable<T>(nullptr)> {};
struct is_class: integral_constant<bool, !is_union<T>::value && memberable<T>(0)> {};
namespace test {
struct TestClass {int i;};
@ -159,11 +159,11 @@ constexpr bool is_class_v = is_class<T>();
template<typename T>
constexpr bool is_signed_v = integral_constant<bool, T(-1) < T(0)>::value;
template<typename T, std::size_t bits = sizeof(T) * 8>
concept Signed_c = is_signed_v<T> && sizeof(T) == bits / 8;
template<typename T, std::size_t bits>
concept Signed_c = is_signed_v<T> && sizeof(T) == 8 * bits;
template<typename T, std::size_t bits = sizeof(T) * 8>
concept Unsigned_c = !is_signed_v<T> && sizeof(T) == bits / 8;
template<typename T, std::size_t bits>
concept Unsigned_c = !is_signed_v<T> && sizeof(T) == 8 * bits;
template<typename T, typename U>
struct is_same: false_type {};

View File

@ -52,15 +52,13 @@ struct VectorAllocator {
const std::size_t cap) noexcept {
// this totally idiotic redundant check (&& count <= Size) is required to address a bug in devkitARM,
// try removing it later
if (!std::is_constant_evaluated()) {
if (cap <= m_data.size() && count <= m_data.size()) {
for (auto i = 0u; i < count; ++i) {
const auto dstItem = reinterpret_cast<T *>(&m_data[i]);
const auto srcItem = reinterpret_cast<T *>(&src->m_data[i]);
std::construct_at<T>(dstItem, std::move(*srcItem));
}
*items = reinterpret_cast<T*>(m_data.data());
if (cap <= m_data.size() && count <= m_data.size()) {
for (auto i = 0u; i < count; ++i) {
const auto dstItem = reinterpret_cast<T*>(&m_data[i]);
const auto srcItem = reinterpret_cast<T*>(&src->m_data[i]);
std::construct_at<T>(dstItem, std::move(*srcItem));
}
*items = reinterpret_cast<T*>(m_data.data());
}
}
@ -71,24 +69,20 @@ struct VectorAllocator {
const std::size_t cap) noexcept {
// this totally idiotic redundant check (&& count <= Size) is required to address a bug in devkitARM,
// try removing it later
if (!std::is_constant_evaluated()) {
if (cap <= m_data.size() && count <= m_data.size()) {
for (std::size_t i = 0; i < count; ++i) {
const auto dstItem = reinterpret_cast<T *>(&m_data[i]);
const auto srcItem = reinterpret_cast<T *>(&src->m_data[i]);
*dstItem = std::move(*srcItem);
}
*items = reinterpret_cast<T*>(m_data.data());
if (cap <= m_data.size() && count <= m_data.size()) {
for (std::size_t i = 0; i < count; ++i) {
const auto dstItem = reinterpret_cast<T*>(&m_data[i]);
const auto srcItem = reinterpret_cast<T*>(&src->m_data[i]);
*dstItem = std::move(*srcItem);
}
*items = reinterpret_cast<T*>(m_data.data());
}
}
constexpr void deallocate(T *items, std::size_t cap) noexcept {
// small vector optimization cannot be done it constexpr, but it doesn't really matter in constexpr
if (std::is_constant_evaluated()) {
if (items && static_cast<void*>(items) != static_cast<void*>(m_data.data())) {
m_allocator.deallocate(items, cap);
}
if (std::is_constant_evaluated() || (items && static_cast<void*>(items) != static_cast<void*>(m_data.data()))) {
m_allocator.deallocate(items, cap);
}
}

View File

@ -14,7 +14,7 @@
namespace nostalgia::core {
static class: public keel::Module {
class KeelModule: public keel::Module {
private:
NostalgiaPaletteToPaletteV1Converter m_nostalgiaPaletteToPaletteV1Converter;
PaletteV1ToPaletteV2Converter m_paletteV1ToPaletteV2Converter;
@ -62,11 +62,11 @@ static class: public keel::Module {
oxRequire(hdr, keel::readAssetHeader(buff));
auto const typeId = ox::buildTypeId(
hdr.clawHdr.typeName, hdr.clawHdr.typeVersion, hdr.clawHdr.typeParams);
if (typeId == ox::ModelTypeId_v<TileSheetV1> ||
typeId == ox::ModelTypeId_v<TileSheetV2> ||
typeId == ox::ModelTypeId_v<TileSheetV3> ||
typeId == ox::ModelTypeId_v<TileSheetV4>) {
oxReturnError(keel::convertBuffToBuff<CompactTileSheet>(
if (typeId == ox::buildTypeId<TileSheetV1>() ||
typeId == ox::buildTypeId<TileSheetV2>() ||
typeId == ox::buildTypeId<TileSheetV3>() ||
typeId == ox::buildTypeId<TileSheetV4>()) {
oxReturnError(keel::convertBuffToBuff<core::CompactTileSheet>(
ctx, buff, ox::ClawFormat::Metal).moveTo(buff));
}
return {};
@ -75,18 +75,19 @@ static class: public keel::Module {
oxRequire(hdr, keel::readAssetHeader(buff));
auto const typeId = ox::buildTypeId(
hdr.clawHdr.typeName, hdr.clawHdr.typeVersion, hdr.clawHdr.typeParams);
if (typeId == ox::ModelTypeId_v<NostalgiaPalette> ||
typeId == ox::ModelTypeId_v<PaletteV1>) {
oxReturnError(keel::convertBuffToBuff<Palette>(
if (typeId == ox::buildTypeId<NostalgiaPalette>() ||
typeId == ox::buildTypeId<PaletteV1>()) {
oxReturnError(keel::convertBuffToBuff<core::Palette>(
ctx, buff, ox::ClawFormat::Metal).moveTo(buff));
}
return {};
},
};
}
} mod;
};
keel::Module const*keelModule() noexcept {
static const KeelModule mod;
const keel::Module *keelModule() noexcept {
return &mod;
}

View File

@ -239,7 +239,6 @@ static void initSpritesBufferset(Context &ctx) noexcept {
glEnableVertexAttribArray(texCoordAttr);
glVertexAttribPointer(texCoordAttr, 2, GL_FLOAT, GL_FALSE, SpriteVertexVboRowLength * sizeof(float),
std::bit_cast<void*>(uintptr_t{4 * sizeof(float)}));
glBindVertexArray(0);
}
static void initBackgroundBufferset(
@ -273,7 +272,6 @@ static void initBackgroundBufferset(
glVertexAttribPointer(
palBankAttr, 1, GL_FLOAT, GL_FALSE, BgVertexVboRowLength * sizeof(float),
std::bit_cast<void*>(uintptr_t{6 * sizeof(float)}));
glBindVertexArray(0);
}
static glutils::GLTexture createTexture(
@ -303,7 +301,6 @@ static void drawBackground(CBB &cbb) noexcept {
}
glBindTexture(GL_TEXTURE_2D, cbb.tex);
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(cbb.elements.size()), GL_UNSIGNED_INT, nullptr);
glBindVertexArray(0);
}
static void drawBackgrounds(
@ -357,7 +354,6 @@ static void drawSprites(Context &ctx, ox::Size const&renderSz) noexcept {
// draw
glBindTexture(GL_TEXTURE_2D, sb.tex);
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(sb.elements.size()), GL_UNSIGNED_INT, nullptr);
glBindVertexArray(0);
}
static void loadPalette(

View File

@ -342,14 +342,13 @@ void TileSheetEditorImGui::drawTileSheet(ox::Vec2 const&fbSize) noexcept {
} else if (m_view.updated()) {
m_view.ackUpdate();
}
{
glutils::FrameBufferBind const frameBufferBind(m_framebuffer);
// clear screen and draw
glViewport(0, 0, fbSizei.width, fbSizei.height);
m_view.draw();
}
glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer);
// clear screen and draw
glViewport(0, 0, fbSizei.width, fbSizei.height);
m_view.draw();
glBindFramebuffer(GL_FRAMEBUFFER, 0);
ImGui::Image(
ig::toImTextureID(m_framebuffer.color.id),
std::bit_cast<ImTextureID>(uintptr_t{m_framebuffer.color.id}),
static_cast<ImVec2>(fbSize),
ImVec2(0, 1),
ImVec2(1, 0));

View File

@ -14,7 +14,6 @@ namespace nostalgia::core {
TileSheetEditorView::TileSheetEditorView(studio::StudioContext &sctx, ox::StringView path, studio::UndoStack &undoStack):
m_model(sctx, path, undoStack),
m_pixelsDrawer(m_model) {
glBindVertexArray(0);
// build shaders
oxThrowError(m_pixelsDrawer.buildShader());
oxThrowError(m_pixelGridDrawer.buildShader());

View File

@ -160,7 +160,7 @@ auto transformRule(keel::Context &ctx, ox::Buffer &buff) noexcept -> ox::Error {
oxRequire(hdr, readAssetHeader(buff));
const auto typeId = ox::buildTypeId(
hdr.clawHdr.typeName, hdr.clawHdr.typeVersion, hdr.clawHdr.typeParams);
if (typeId == ox::ModelTypeId_v<From>) {
if (typeId == ox::buildTypeId<From>()) {
oxReturnError(keel::convertBuffToBuff<To>(ctx, buff, fmt).moveTo(buff));
}
return {};

View File

@ -56,7 +56,7 @@ static ox::Error runApp(
return err;
}
static ox::Error run(
ox::Error run(
ox::CRStringView appName,
ox::CRStringView projectDataDir,
int,

View File

@ -8,8 +8,6 @@
#include <imgui.h>
#include <ox/std/bit.hpp>
#include <turbine/context.hpp>
#include <studio/context.hpp>
@ -17,91 +15,6 @@ namespace studio::ig {
inline constexpr auto BtnSz = ImVec2{52, 22};
constexpr ImTextureID toImTextureID(ox::Unsigned_c auto id) noexcept
requires(sizeof(id) <= sizeof(ox::Uint<sizeof(ImTextureID)*8>)) {
return std::bit_cast<ImTextureID>(ox::Uint<sizeof(ImTextureID)*8>{id});
}
template<typename T>
ox::Result<T> getDragDropPayload(ox::CStringView name) noexcept {
auto const payload = ImGui::AcceptDragDropPayload(name.c_str());
if (!payload) {
return OxError(1, "No drag/drop payload");
}
return ox::readClaw<T>(
reinterpret_cast<char const*>(payload->Data),
static_cast<size_t>(payload->DataSize));
}
ox::Error setDragDropPayload(ox::CStringView name, auto const &obj) noexcept {
oxRequire(buff, ox::writeClaw(obj, ox::ClawFormat::Metal));
ImGui::SetDragDropPayload(name.c_str(), buff.data(), buff.size());
return {};
}
class DragDropSource {
private:
bool const m_active{};
public:
inline DragDropSource() noexcept:
m_active(ImGui::BeginDragDropSource()) {
}
inline ~DragDropSource() noexcept {
if (m_active) {
ImGui::EndDragDropSource();
}
}
constexpr operator bool() const noexcept {
return m_active;
}
};
inline auto dragDropSource(auto const&cb) noexcept {
if constexpr(ox::is_same_v<decltype(cb()), ox::Error>) {
if (ig::DragDropSource const tgt; tgt) [[unlikely]] {
return cb();
}
} else {
if (ig::DragDropSource const tgt; tgt) [[unlikely]] {
cb();
}
}
}
class DragDropTarget {
private:
bool const m_active{};
public:
inline DragDropTarget() noexcept:
m_active(ImGui::BeginDragDropTarget()) {
}
inline ~DragDropTarget() noexcept {
if (m_active) {
ImGui::EndDragDropTarget();
}
}
constexpr operator bool() const noexcept {
return m_active;
}
};
inline auto dragDropTarget(auto const&cb) noexcept {
if constexpr(ox::is_same_v<decltype(cb()), ox::Error>) {
if (ig::DragDropTarget const tgt; tgt) [[unlikely]] {
return cb();
}
return ox::Error{};
} else {
if (ig::DragDropTarget const tgt; tgt) [[unlikely]] {
cb();
}
}
}
class ChildStackItem {
public:
explicit ChildStackItem(ox::CStringView id, ImVec2 const&sz = {}) noexcept;