forked from moonpower/azahar-UWP
Add Xbox build support and modify project structure for compatibility
This commit is contained in:
parent
25cda90472
commit
1ee9a8eb4e
@ -112,6 +112,30 @@ option(ENABLE_NATIVE_OPTIMIZATION "Enables processor-specific optimizations via
|
||||
option(CITRA_USE_PRECOMPILED_HEADERS "Use precompiled headers" ON)
|
||||
option(CITRA_WARNINGS_AS_ERRORS "Enable warnings as errors" ON)
|
||||
|
||||
option(XBOX_BUILD "Build for Xbox" OFF)
|
||||
if(XBOX_BUILD)
|
||||
add_definitions(-D__XBOX_BUILD)
|
||||
set(ENABLE_QT OFF)
|
||||
set(ENABLE_SDL2 ON)
|
||||
set(USE_DISCORD_PRESENCE OFF)
|
||||
set(ENABLE_ROOM OFF)
|
||||
set(ENABLE_ROOM_STANDALONE OFF)
|
||||
set(ENABLE_QT_TRANSLATION OFF)
|
||||
set(ENABLE_QT_UPDATE_CHECKER OFF)
|
||||
set(ENABLE_OPENGL ON)
|
||||
set(ENABLE_VULKAN OFF)
|
||||
set(ENABLE_SOFTWARE_RENDERER ON)
|
||||
set(ENABLE_SDL2_FRONTEND ON)
|
||||
set(USE_SYSTEM_SDL2 ON)
|
||||
include_directories(
|
||||
${PROJECT_SOURCE_DIR}/externals/glad/include
|
||||
${PROJECT_SOURCE_DIR}/externals/glad/include/KHR
|
||||
${PROJECT_SOURCE_DIR}/externals/sdl2/SDL/include
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
# Pass the following values to C++ land
|
||||
if (ENABLE_QT)
|
||||
add_definitions(-DENABLE_QT)
|
||||
|
||||
@ -1,8 +1,16 @@
|
||||
add_executable(citra_meta
|
||||
citra.rc
|
||||
main.cpp
|
||||
precompiled_headers.h
|
||||
)
|
||||
if(XBOX_BUILD)
|
||||
add_library(citra_meta SHARED
|
||||
citra.rc
|
||||
main.cpp
|
||||
precompiled_headers.h
|
||||
)
|
||||
else()
|
||||
add_executable(citra_meta
|
||||
citra.rc
|
||||
main.cpp
|
||||
precompiled_headers.h
|
||||
)
|
||||
endif()
|
||||
|
||||
set_target_properties(citra_meta PROPERTIES OUTPUT_NAME "azahar")
|
||||
|
||||
|
||||
@ -21,6 +21,29 @@ __declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define EXPORT __declspec(dllexport)
|
||||
#elif defined(__APPLE__)
|
||||
#define EXPORT __attribute__((visibility("default")))
|
||||
#else
|
||||
#define EXPORT
|
||||
#endif
|
||||
|
||||
#ifdef __XBOX_BUILD
|
||||
#include "/Users/moon/Documents/AzaharPlus/externals/sdl2/SDL/include/SDL.h"
|
||||
#include "externals/glad/include/glad/glad.h"
|
||||
extern "C" int main(int argc, char* argv[]);
|
||||
extern "C" EXPORT int external_main(SDL_Window* window, SDL_GLContext context, int argc, const char** argv) {
|
||||
SDL_GL_MakeCurrent(window, context);
|
||||
if (!gladLoadGLLoader((GLADloadproc)SDL_GL_GetProcAddress)) {
|
||||
std::cerr << "Failed to initialize GLAD" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return main(argc, const_cast<char**>(argv));
|
||||
}
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
#if ENABLE_ROOM
|
||||
bool launch_room = false;
|
||||
|
||||
@ -20,9 +20,14 @@ public:
|
||||
using SDL_GLContext = void*;
|
||||
|
||||
SDLGLContext() {
|
||||
#ifdef __XBOX_BUILD
|
||||
window = SDL_GL_GetCurrentWindow();
|
||||
context = SDL_GL_GetCurrentContext();
|
||||
#else
|
||||
window = SDL_CreateWindow(NULL, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 0, 0,
|
||||
SDL_WINDOW_HIDDEN | SDL_WINDOW_OPENGL);
|
||||
context = SDL_GL_CreateContext(window);
|
||||
#endif
|
||||
}
|
||||
|
||||
~SDLGLContext() override {
|
||||
@ -81,7 +86,12 @@ EmuWindow_SDL2_GL::EmuWindow_SDL2_GL(Core::System& system_, bool fullscreen, boo
|
||||
Common::g_scm_branch, Common::g_scm_desc);
|
||||
|
||||
// First, try to create a context with the requested type.
|
||||
#ifdef __XBOX_BUILD
|
||||
SDL_Window* render_window = SDL_GL_GetCurrentWindow();
|
||||
LOG_INFO(Frontend, "Using existing window");
|
||||
#else
|
||||
render_window = CreateGLWindow(window_title, Settings::values.use_gles.GetValue());
|
||||
#endif
|
||||
if (render_window == nullptr) {
|
||||
// On failure, fall back to context with flipped type.
|
||||
render_window = CreateGLWindow(window_title, !Settings::values.use_gles.GetValue());
|
||||
@ -100,7 +110,12 @@ EmuWindow_SDL2_GL::EmuWindow_SDL2_GL(Core::System& system_, bool fullscreen, boo
|
||||
Fullscreen();
|
||||
}
|
||||
|
||||
#ifdef __XBOX_BUILD
|
||||
window_context = SDL_GL_GetCurrentContext();
|
||||
LOG_INFO(Frontend, "Using existing context");
|
||||
#else
|
||||
window_context = SDL_GL_CreateContext(render_window);
|
||||
#endif
|
||||
core_context = CreateSharedContext();
|
||||
last_saved_context = nullptr;
|
||||
|
||||
|
||||
@ -27,7 +27,11 @@ GLuint LoadShader(std::string_view source, GLenum type) {
|
||||
#endif // defined(GL_EXT_clip_cull_distance)
|
||||
)";
|
||||
} else {
|
||||
#ifdef __APPLE__
|
||||
preamble = "#version 410 core\n";
|
||||
#else
|
||||
preamble = "#version 430 core\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string_view debug_type;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user