Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
Thanks MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
OFFTKP committed Jan 14, 2024
1 parent 4999c1a commit 8a3482b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)

project(hydra
VERSION 0.2.0
LANGUAGES C CXX
LANGUAGES C CXX OBJC
HOMEPAGE_URL "https://github.com/hydra-emu/hydra"
DESCRIPTION "A multi-system, multi-platform emulator frontend"
)
Expand Down Expand Up @@ -103,6 +103,7 @@ endif()
option(BUILD_QT "Build the Qt frontend" OFF)
option(BUILD_LUA "Build with lua for script support" OFF)
option(BUILD_DISCORD_BOT "Build with discord bot support" OFF)
option(USE_NATIVE_FILE_DIALOGS "Use native file dialogs" OFF)

add_subdirectory(vendored/fmt)
add_subdirectory(vendored/argparse)
Expand Down Expand Up @@ -151,7 +152,7 @@ if(HYDRA_LINUX OR HYDRA_FREEBSD OR HYDRA_WINDOWS)
endif()

if(HYDRA_DESKTOP)
if (NOT HYDRA_FREEBSD) # TODO: fix this
if (NOT HYDRA_FREEBSD AND SE_NATIVE_FILE_DIALOGS) # TODO: fix FreeBSD
set(NFD_PORTAL ON) # use xdg-desktop-portal for file dialogs
add_subdirectory(vendored/nativefiledialog)
set(HYDRA_LIBRARIES ${HYDRA_LIBRARIES} nfd)
Expand Down
4 changes: 1 addition & 3 deletions data/shell.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@
canvas.addEventListener("webglcontextlost", function(e) { alert('FIXME: WebGL context lost, please reload the page'); e.preventDefault(); }, false);
return canvas;
})(),
setStatus: function(text) {
console.log("status: " + text);
},
setStatus: function(text) {},
monitorRunDependencies: function(left) {
// no run dependencies to log
}
Expand Down
1 change: 1 addition & 0 deletions include/gamewindow.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ private:
static GameWindow* instance;
static void video_callback(void* data, hydra::Size size);
static GLenum get_gl_format(hydra::PixelFormat format);
static void platform_specific_changes(void* data, hydra::Size size);
};
20 changes: 16 additions & 4 deletions src/gamewindow.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,24 @@ GameWindow::GameWindow(const std::filesystem::path& core_path,
loaded = emulator->LoadGame(game_path.string());
}

void GameWindow::platform_specific_changes(void* data, hydra::Size size)
{
// TODO: do this with shaders?
#ifdef HYDRA_WEB
auto gl_format = get_gl_format(GameWindow::instance->pixel_format);
if (gl_format == GL_BGRA)
{
for (int i = 0; i < size.width * size.height * 4; i += 4)
{
std::swap(((uint8_t*)data)[i], ((uint8_t*)data)[i + 2]);
}
}
#endif
}

void GameWindow::video_callback(void* data, hydra::Size size)
{
platform_specific_changes(data, size);
glBindTexture(GL_TEXTURE_2D, GameWindow::instance->texture);
hydra::Size texture_size = GameWindow::instance->texture_size;
hydra::PixelFormat pixel_format =
Expand Down Expand Up @@ -370,11 +386,7 @@ GLenum GameWindow::get_gl_format(hydra::PixelFormat format)
}
case hydra::PixelFormat::BGRA:
{
#ifdef HYDRA_WEB
return GL_RGBA;
#else
return GL_BGRA;
#endif
}
default:
{
Expand Down

0 comments on commit 8a3482b

Please sign in to comment.