Skip to content

Commit

Permalink
first pass at windows build
Browse files Browse the repository at this point in the history
- use glfw + opengl3
- imgui demo working
- use Visual Studio Code 2022
  • Loading branch information
ypujante committed Sep 26, 2022
1 parent 66eba8c commit 25f849c
Show file tree
Hide file tree
Showing 19 changed files with 253 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.DS_Store
.idea
cmake-build-debug
cmake-build-*
build

4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ set(RE_SDK_VERSION 4.3.0)
# or via -p option in configure.py script or in cmake-gui
if(APPLE)
set(RE_SDK_ROOT "/Users/Shared/ReasonStudios/JukeboxSDK_${RE_SDK_VERSION}/SDK" CACHE PATH "Location of RE SDK")
else()
elseif(WIN32)
set(RE_SDK_ROOT "C:/Users/Public/Documents/ReasonStudios/JukeboxSDK_${RE_SDK_VERSION}/SDK" CACHE PATH "Location of RE SDK")
endif()

Expand Down Expand Up @@ -111,6 +111,8 @@ set(RE_EDIT_FONTS_DIR "${CMAKE_CURRENT_LIST_DIR}/external/fonts")
if(APPLE)
list(APPEND re-edit_BUILD_SOURCES "${CMAKE_CURRENT_LIST_DIR}/src/cpp/re/edit/MTLTextureManager.cpp")
set(re-edit_MAIN_SRC "${re-edit_CPP_SRC_DIR}/re/edit/macos/main.cpp" "${re-edit_CPP_SRC_DIR}/re/edit/macos/metal.cpp")
elseif(WIN32)
set(re-edit_MAIN_SRC "${re-edit_CPP_SRC_DIR}/re/edit/windows/main.cpp")
endif()

# Build the static library
Expand Down
Binary file added external/glfw/glfw/windows/lib-vc2022/glfw3.dll
Binary file not shown.
Binary file added external/glfw/glfw/windows/lib-vc2022/glfw3.lib
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions external/glfw/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Version 3.3.8
Downloaded from https://www.glfw.org/
6 changes: 6 additions & 0 deletions external/ocornut/imgui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ set(imgui_BUILD_SOURCES
if(APPLE)
find_library(SDL2Fwk SDL2 REQUIRED)
list(APPEND imgui_BUILD_SOURCES "${imgui_CPP_SRC_DIR}/backends/imgui_impl_metal.mm")
elseif(WIN32)
list(APPEND imgui_BUILD_SOURCES "${imgui_CPP_SRC_DIR}/backends/imgui_impl_opengl3.cpp")
endif()

add_library(imgui STATIC "${imgui_BUILD_SOURCES}")
Expand All @@ -28,6 +30,10 @@ if(APPLE)
target_include_directories(imgui PUBLIC "metal-cpp")
target_link_directories(imgui PUBLIC "${glfw_ROOT_DIR}/macos-lib-universal")
target_link_libraries(imgui PUBLIC glfw3 "-framework QuartzCore" "-framework Cocoa" "-framework Metal" "-framework MetalKit" "-framework IOKit" "-framework AppKit")
elseif(WIN32)
target_include_directories(imgui PUBLIC "${imgui_CPP_SRC_DIR}/backends")
target_link_directories(imgui PUBLIC "${glfw_ROOT_DIR}/windows/lib-vc2022")
target_link_libraries(imgui PUBLIC glfw3.lib opengl32.lib gdi32.lib shell32.lib)
endif()

add_executable("binary_to_compressed_c" "${imgui_CPP_SRC_DIR}/misc/fonts/binary_to_compressed_c.cpp")
4 changes: 2 additions & 2 deletions src/cpp/re/edit/AppContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ class AppContext
Panel *getPanel(PanelType iType) const;

public: // UserPreferences
constexpr UserPreferences const &getUserPreferences() const { return *fUserPreferences; }
constexpr UserPreferences &getUserPreferences() { return *fUserPreferences; }
inline UserPreferences const &getUserPreferences() const { return *fUserPreferences; }
inline UserPreferences &getUserPreferences() { return *fUserPreferences; }

public: // Properties
inline std::vector<Object const *> findObjects(Object::Filter const &iFilter) const { return fPropertyManager->findObjects(iFilter); }
Expand Down
41 changes: 40 additions & 1 deletion src/cpp/re/edit/FilmStrip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@
*/

#include "FilmStrip.h"
#include <dirent.h>
#include <sys/stat.h>
#include "Errors.h"
#include <re/mock/fmt.h>
#include <regex>

#if WIN32
#include <filesystem>
#else
#include <dirent.h>
#endif

namespace re::edit {

//------------------------------------------------------------------------
Expand Down Expand Up @@ -178,6 +183,39 @@ std::vector<FilmStrip::File> FilmStripMgr::scanDirectory(std::string const &iDir

std::vector<FilmStrip::File> res{};

#if WIN32
std::error_code errorCode;
auto iter = std::filesystem::directory_iterator(iDirectory, errorCode);
if(!errorCode)
{
for(const auto &ent: iter)
{
std::cmatch m;
auto filename = ent.path().filename().string();
if(std::regex_search(filename.c_str(), m, FILENAME_REGEX))
{
auto entry = re::mock::fmt::path(iDirectory, filename);
struct stat buf{};
if(stat(entry.c_str(), &buf) == 0)
{
auto inferredNumFrames = m[2].matched ? std::stoi(m[2].str()) : 1;
auto key = filename;
key = key.substr(0, key.size() - 4); // remove .png
res.emplace_back(FilmStrip::File{entry, key, static_cast<long>(ent.last_write_time().time_since_epoch().count()), inferredNumFrames});
}
else
{
RE_EDIT_LOG_ERROR("Error (%d) with file [%s] : ", errno, entry);
}
}
}
}
else
{
RE_EDIT_LOG_ERROR("Could not scan directory [%s]", iDirectory);
}

#else
DIR *dir;
struct dirent *ent;
if((dir = opendir(iDirectory.c_str())) != nullptr)
Expand Down Expand Up @@ -208,6 +246,7 @@ std::vector<FilmStrip::File> FilmStripMgr::scanDirectory(std::string const &iDir
{
RE_EDIT_LOG_ERROR("Could not scan directory [%s]", iDirectory);
}
#endif

return res;
}
Expand Down
3 changes: 2 additions & 1 deletion src/cpp/re/edit/FilmStrip.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <map>
#include <memory>
#include <vector>
#include <functional>
#include <imgui.h>

namespace re::edit {
Expand Down Expand Up @@ -56,7 +57,7 @@ class FilmStrip
data_t *fData{};
};

constexpr std::string const &key() const { return fFile->fKey; };
inline std::string const &key() const { return fFile->fKey; };
constexpr std::string const &errorMessage() const { return fErrorMessage; };

inline bool isValid() const { return fData != nullptr; }
Expand Down
4 changes: 2 additions & 2 deletions src/cpp/re/edit/Graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ class Graphics : public Attribute

constexpr void move(ImVec2 const &iDelta) { fPosition = fPosition + iDelta; fEdited = true; }

constexpr bool hasTexture() const { return getTexture() != nullptr; }
constexpr Texture const *getTexture() const { return fTexture.get(); }
inline bool hasTexture() const { return getTexture() != nullptr; }
inline Texture const *getTexture() const { return fTexture.get(); }
void setTexture(std::shared_ptr<Texture> iTexture) { fTexture = std::move(iTexture); fEdited = true; }
void setSize(ImVec2 const &iSize) { fSize = iSize; fEdited = true; }

Expand Down
6 changes: 6 additions & 0 deletions src/cpp/re/edit/PropertyManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ static char const *toOwnerString(PropertyOwner iOwner)
return "Document";
case PropertyOwner::kGUIOwner:
return "GUI";
default:
RE_EDIT_FAIL("not reached");
}
}

Expand Down Expand Up @@ -265,6 +267,8 @@ static char const *toTypeString(TJBox_ValueType iValueType)
return "Native Object";
case kJBox_Incompatible:
return "Incompatible";
default:
RE_EDIT_FAIL("not reached");
}
}

Expand All @@ -281,6 +285,8 @@ static char const *toPersistenceString(lua::EPersistence iPersistence)
return "Song";
case lua::EPersistence::kNone:
return "None";
default:
RE_EDIT_FAIL("not reached");
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/cpp/re/edit/Texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ class Texture

virtual ~Texture() = default;

constexpr std::string const &key() const { return fFilmStrip->key(); };
inline std::string const &key() const { return fFilmStrip->key(); };

constexpr bool isValid() const { return fFilmStrip->isValid(); }
inline bool isValid() const { return fFilmStrip->isValid(); }

constexpr float width() const { return static_cast<float>(fFilmStrip->width()); }
constexpr float height() const { return static_cast<float>(fFilmStrip->height()); }
Expand Down
6 changes: 4 additions & 2 deletions src/cpp/re/edit/Views.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <vector>
#include <set>
#include <string>
#include <optional>
#include <functional>
#include "imgui.h"

namespace re::edit::views {
Expand All @@ -42,8 +44,8 @@ class MultiSelectionList
void clearSelection();
void setupTableHeader(int iColumnIndex);
inline bool isSelected(std::string const &s) const { return fSelected.find(s) != fSelected.end(); }
constexpr bool empty() const { return fList.empty(); }
constexpr size_t selectedCount() const { return fSelected.size(); }
inline bool empty() const { return fList.empty(); }
inline size_t selectedCount() const { return fSelected.size(); }

public:
std::vector<std::string> fList{};
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/re/edit/Widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Widget
constexpr int &getFrameNumber() { return fGraphics->fFrameNumber; }
constexpr void setFrameNumber(int iFrameNumber) { fGraphics->fFrameNumber = iFrameNumber; }

constexpr Texture const *getTexture() const { return fGraphics->getTexture(); }
inline Texture const *getTexture() const { return fGraphics->getTexture(); }

inline bool contains(ImVec2 const &iPosition) const { return fGraphics->contains(iPosition); }
inline bool overlaps(ImVec2 const &iTopLeft, ImVec2 const &iBottomRight) const { return fGraphics->overlaps(iTopLeft, iBottomRight); }
Expand Down
10 changes: 8 additions & 2 deletions src/cpp/re/edit/WidgetAttribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,10 @@ void PropertyPathList::editView(AppContext &iCtx)
{
auto sortBy = [&iCtx, this](std::vector<std::string> &ioString, std::string const &iSortCriteria) {
fSortCriteria = iSortCriteria;
iCtx.sortProperties(ioString, iSortCriteria == "Path" ? kByPathComparator : kByTagComparator);
if(iSortCriteria == "Path")
iCtx.sortProperties(ioString, kByPathComparator);
else
iCtx.sortProperties(ioString, kByTagComparator);
};
ImGui::OpenPopup(popupTitleName.c_str());
fStringListEditView = views::StringListEdit(iCtx.findPropertyNames(fFilter),
Expand Down Expand Up @@ -1137,7 +1140,10 @@ void ReadOnly::onChanged(AppContext &iCtx)
};

auto valueAtt = iCtx.getCurrentWidget()->findAttributeByIdAndType<Value>(fValueAttributeId);
valueAtt->fValue.fFilter = fValue ? kReadOnlyValueFilter : kReadWriteValueFilter;
if(fValue)
valueAtt->fValue.fFilter = kReadOnlyValueFilter;
else
valueAtt->fValue.fFilter = kReadWriteValueFilter;
}

}
Expand Down
4 changes: 2 additions & 2 deletions src/cpp/re/edit/lua/Device2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ void Device2D::processGfxNode(std::string const &iName, ImVec2 iOffset, panel_no
if(lua_type(L, -1) == LUA_TTABLE)
{
auto node = gfx_node{
.fName = iName,
.fPosition = iOffset
/* .fName = */ iName,
/* .fPosition = */ iOffset
};

iterateLuaTable([this, &node](lua_table_key_t const &key) {
Expand Down
Loading

0 comments on commit 25f849c

Please sign in to comment.