[nostalgia] Fix MSVC build

This commit is contained in:
Gary Talent 2022-07-09 20:20:37 -05:00
parent 2fa74069a9
commit 99bdf30c52
5 changed files with 16 additions and 26 deletions

View File

@ -51,11 +51,13 @@ if(BUILDCORE_TARGET STREQUAL "gba")
else()
include_directories(
SYSTEM
deps/glfw/deps
deps/glfw/include
deps/imgui
deps/imgui/backends
deps/nfde/src/include
)
add_subdirectory(deps/glad)
add_subdirectory(deps/glfw)
add_subdirectory(deps/imgui)
add_subdirectory(deps/lodepng)

View File

@ -1,9 +1,4 @@
if(NOT NOSTALGIA_BUILD_TYPE STREQUAL "GBA")
if(APPLE)
find_package(OpenGL REQUIRED)
else()
set(OPENGL_gl_LIBRARY GL)
endif()
set(
NOSTALGIA_CORE_IMPL_SRC
glfw/clipboard.cpp
@ -15,7 +10,7 @@ if(NOT NOSTALGIA_BUILD_TYPE STREQUAL "GBA")
)
set(
NOSTALGIA_CORE_IMPL_LIBS
${OPENGL_gl_LIBRARY}
glad
glfw
imgui
OxEvent

View File

@ -2,14 +2,15 @@
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#include <ox/claw/read.hpp>
#include <nostalgia/core/clipboard.hpp>
#include <nostalgia/core/media.hpp>
#include <ox/claw/read.hpp>
#include <ox/std/algorithm.hpp>
#include <ox/std/buffer.hpp>
#include <ox/std/memory.hpp>
#include <nostalgia/core/clipboard.hpp>
#include <nostalgia/core/media.hpp>
#include "tilesheeteditormodel.hpp"
namespace nostalgia::core {
@ -102,7 +103,7 @@ class DrawCommand: public TileSheetCommand {
m_img = img;
auto &subsheet = m_img->getSubSheet(subSheetIdx);
m_subSheetIdx = subSheetIdx;
m_changes.emplace_back(idx, subsheet.getPixel(m_img->bpp, idx));
m_changes.emplace_back(static_cast<uint32_t>(idx), subsheet.getPixel(m_img->bpp, idx));
m_palIdx = palIdx;
}
@ -111,7 +112,7 @@ class DrawCommand: public TileSheetCommand {
auto &subsheet = m_img->getSubSheet(subSheetIdx);
m_subSheetIdx = subSheetIdx;
for (const auto idx : idxList) {
m_changes.emplace_back(idx, subsheet.getPixel(m_img->bpp, idx));
m_changes.emplace_back(static_cast<uint32_t>(idx), subsheet.getPixel(m_img->bpp, idx));
}
m_palIdx = palIdx;
}
@ -124,7 +125,7 @@ class DrawCommand: public TileSheetCommand {
return c.idx == idx;
});
if (existing == m_changes.cend()) {
m_changes.emplace_back(idx, subsheet.getPixel(m_img->bpp, idx));
m_changes.emplace_back(static_cast<uint32_t>(idx), subsheet.getPixel(m_img->bpp, idx));
subsheet.setPixel(m_img->bpp, idx, m_palIdx);
return true;
}
@ -192,7 +193,7 @@ class CutPasteCommand: public TileSheetCommand {
const auto dstPt = p.pt + dstStart;
if (dstPt.x <= dstEnd.x && dstPt.y <= dstEnd.y) {
const auto idx = subsheet.idx(dstPt);
m_changes.emplace_back(idx, p.colorIdx, subsheet.getPixel(m_img->bpp, idx));
m_changes.emplace_back(static_cast<uint32_t>(idx), p.colorIdx, subsheet.getPixel(m_img->bpp, idx));
}
}
}
@ -240,7 +241,7 @@ class AddSubSheetCommand: public TileSheetCommand {
m_addedSheets.push_back(idx);
} else {
auto idx = m_parentIdx;
idx.emplace_back(0);
idx.emplace_back(0u);
m_addedSheets.push_back(idx);
idx.back().value = 1;
m_addedSheets.push_back(idx);
@ -562,7 +563,7 @@ void TileSheetEditorModel::cut() {
}
void TileSheetEditorModel::copy() {
auto cb = ox::make_unique<TileSheetClipboard>();;
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);
@ -608,7 +609,7 @@ void TileSheetEditorModel::drawCommand(const geo::Point &pt, std::size_t palIdx)
if (m_ongoingDrawCommand) {
m_updated = m_updated || m_ongoingDrawCommand->append(idx);
} else if (activeSubSheet.getPixel(m_img.bpp, idx) != palIdx) {
pushCommand(new DrawCommand(&m_img, m_activeSubsSheetIdx, idx, palIdx));
pushCommand(new DrawCommand(&m_img, m_activeSubsSheetIdx, idx, static_cast<int>(palIdx)));
}
}
@ -729,7 +730,7 @@ ox::Error TileSheetEditorModel::saveFile() noexcept {
bool TileSheetEditorModel::pixelSelected(std::size_t idx) const noexcept {
const auto s = activeSubSheet();
const auto pt = idxToPt(idx, s->columns);
const auto pt = idxToPt(static_cast<int>(idx), s->columns);
return m_selectionBounds.contains(pt);
}

View File

@ -7,17 +7,10 @@ if(NOT MSVC)
target_compile_options(NostalgiaGlUtils PRIVATE -Wsign-conversion)
endif()
if(APPLE)
find_package(OpenGL REQUIRED)
else()
set(OPENGL_gl_LIBRARY GL)
endif()
find_package(glad REQUIRED)
target_link_libraries(
NostalgiaGlUtils PUBLIC
OxStd
glad::glad
glad
)
install(

View File

@ -14,7 +14,6 @@
#include <OpenGL/gl3.h>
#else
#include <glad/glad.h>
#include <gl/GL.h>
#endif
#include <ox/std/error.hpp>