[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() else()
include_directories( include_directories(
SYSTEM SYSTEM
deps/glfw/deps
deps/glfw/include deps/glfw/include
deps/imgui deps/imgui
deps/imgui/backends deps/imgui/backends
deps/nfde/src/include deps/nfde/src/include
) )
add_subdirectory(deps/glad)
add_subdirectory(deps/glfw) add_subdirectory(deps/glfw)
add_subdirectory(deps/imgui) add_subdirectory(deps/imgui)
add_subdirectory(deps/lodepng) add_subdirectory(deps/lodepng)

View File

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

View File

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

View File

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

View File

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