Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mingw #153

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Mingw #153

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changes/sdk/pr.153.gh.OpenXR-SDK-Source.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
- issue.151.gh.OpenXR-SDK-Source
---
Improve portability and fix building of loader on MinGW. Toolchain files now provided for cross-building for Windows from Debian.
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ if((OPENGL_FOUND OR OpenGLES_FOUND)
)
endif()
set_target_properties(openxr-gfxwrapper PROPERTIES FOLDER ${HELPER_FOLDER})
if(WIN32)
target_link_libraries(openxr-gfxwrapper PUBLIC gdi32)
endif()

message(
STATUS
"Enabling OpenGL support in hello_xr, loader_test, and conformance, if configured"
Expand Down
33 changes: 33 additions & 0 deletions src/cmake/mingw-w64-toolchain-32bit.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Toolchain file for 32-bit MinGW build on *nix
# Developed for use with Debian and its derivatives
#
# Copyright 2019 Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0

set(CMAKE_SYSTEM_NAME "Windows")

set(TARGET i686-w64-mingw32)
set(PREFIX ${TARGET}-)
set(SUFFIX -posix) # required for threads
set(CMAKE_C_COMPILER ${PREFIX}gcc${SUFFIX})
set(CMAKE_CXX_COMPILER ${PREFIX}g++${SUFFIX})
set(CMAKE_RC_COMPILER ${PREFIX}windres)

set(CMAKE_C_COMPILER_AR ${PREFIX}gcc-ar${SUFFIX})
set(CMAKE_CXX_COMPILER_AR ${PREFIX}gcc-ar${SUFFIX})
set(CMAKE_C_COMPILER_RANLIB ${PREFIX}gcc-ranlib${SUFFIX})
set(CMAKE_CXX_COMPILER_RANLIB ${PREFIX}gcc-ranlib${SUFFIX})
set(CMAKE_NM ${PREFIX}gcc-nm${SUFFIX})
set(CMAKE_OBJCOPY ${PREFIX}objcopy)
set(CMAKE_OBJDUMP ${PREFIX}objdump)
set(CMAKE_RANLIB ${PREFIX}ranlib)
set(CMAKE_STRIP ${PREFIX}strip)

if(NOT CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX /usr/${TARGET})
endif()

set(CMAKE_FIND_ROOT_PATH /usr/${TARGET})
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
33 changes: 33 additions & 0 deletions src/cmake/mingw-w64-toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Toolchain file for 64-bit MinGW build on *nix
# Developed for use with Debian and its derivatives
#
# Copyright 2019 Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0

set(CMAKE_SYSTEM_NAME "Windows")

set(TARGET x86_64-w64-mingw32)
set(PREFIX ${TARGET}-)
set(SUFFIX -posix) # required for threads
set(CMAKE_C_COMPILER ${PREFIX}gcc${SUFFIX})
set(CMAKE_CXX_COMPILER ${PREFIX}g++${SUFFIX})
set(CMAKE_RC_COMPILER ${PREFIX}windres)

set(CMAKE_C_COMPILER_AR ${PREFIX}gcc-ar${SUFFIX})
set(CMAKE_CXX_COMPILER_AR ${PREFIX}gcc-ar${SUFFIX})
set(CMAKE_C_COMPILER_RANLIB ${PREFIX}gcc-ranlib${SUFFIX})
set(CMAKE_CXX_COMPILER_RANLIB ${PREFIX}gcc-ranlib${SUFFIX})
set(CMAKE_NM ${PREFIX}gcc-nm${SUFFIX})
set(CMAKE_OBJCOPY ${PREFIX}objcopy)
set(CMAKE_OBJDUMP ${PREFIX}objdump)
set(CMAKE_RANLIB ${PREFIX}ranlib)
set(CMAKE_STRIP ${PREFIX}strip)

if(NOT CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX /usr/${TARGET})
endif()

set(CMAKE_FIND_ROOT_PATH /usr/${TARGET})
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
18 changes: 11 additions & 7 deletions src/tests/hello_xr/graphicsplugin_opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
// SPDX-License-Identifier: Apache-2.0

#include "pch.h"

#ifdef __MINGW32__
#define GL_ATTRIBUTE __attribute__((stdcall))
#else
#define GL_ATTRIBUTE
#endif
#include "common.h"
#include "geometry.h"
#include "graphicsplugin.h"
Expand Down Expand Up @@ -149,17 +155,15 @@ struct OpenGLGraphicsPlugin : public IGraphicsPlugin {

#if !defined(XR_USE_PLATFORM_MACOS)
glEnable(GL_DEBUG_OUTPUT);
glDebugMessageCallback(
[](GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message,
const void* userParam) {
((OpenGLGraphicsPlugin*)userParam)->DebugMessageCallback(source, type, id, severity, length, message);
},
this);
glDebugMessageCallback((GLDEBUGPROC)&OpenGLGraphicsPlugin::DebugMessageCallbackTrampoline, this);
#endif // !defined(XR_USE_PLATFORM_MACOS)

InitializeResources();
}

static void GL_ATTRIBUTE DebugMessageCallbackTrampoline(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
const GLchar* message, const void* userParam) {
((OpenGLGraphicsPlugin*)userParam)->DebugMessageCallback(source, type, id, severity, length, message);
}
void InitializeResources() {
glGenFramebuffers(1, &m_swapchainFramebuffer);

Expand Down
Loading