Skip to content

Commit

Permalink
[XR/XrContext] Added XrContext
Browse files Browse the repository at this point in the history
- This holds the XR instance, debug messenger & system ID

- Disabled -Wmissing-field-initializers for GCC & Clang, which is triggered for some OpenXR types instantiations
  • Loading branch information
Razakhel committed Nov 12, 2024
1 parent 1e8542f commit 6c4a477
Show file tree
Hide file tree
Showing 6 changed files with 435 additions and 8 deletions.
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,18 @@ set(
include/RaZ/Utils/*.inl
)

if (NOT RAZ_PLATFORM_MAC AND NOT RAZ_USE_EMSCRIPTEN AND RAZ_USE_WINDOW)
# XR currently isn't available with macOS or Emscripten and requires windowing capabilities
# TODO: this makes XR unavailable from the GUI editor
list(
APPEND
RAZ_SRC

src/RaZ/XR/*.cpp
include/RaZ/XR/*.hpp
)
endif ()

# Adding every file to be compiled
file(
GLOB
Expand Down
2 changes: 2 additions & 0 deletions cmake/CompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ function(add_compiler_flags TARGET_NAME SCOPE)

-Wno-comment
-Wno-format-nonliteral
-Wno-missing-field-initializers
)

if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 5)
Expand Down Expand Up @@ -122,6 +123,7 @@ function(add_compiler_flags TARGET_NAME SCOPE)
-Wno-global-constructors
-Wno-mismatched-tags
-Wno-missing-braces
-Wno-missing-field-initializers
-Wno-newline-eof
-Wno-padded
-Wno-reserved-id-macro
Expand Down
1 change: 1 addition & 0 deletions include/RaZ/RaZ.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
#include "Utils/Threading.hpp"
#include "Utils/ThreadPool.hpp"
#include "Utils/TypeUtils.hpp"
#include "XR/XrContext.hpp"

using namespace Raz::Literals;

Expand Down
44 changes: 44 additions & 0 deletions include/RaZ/XR/XrContext.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#pragma once

#ifndef RAZ_XRCONTEXT_HPP
#define RAZ_XRCONTEXT_HPP

#include <cstdint>
#include <string>
#include <vector>

struct XrInstance_T;
struct XrDebugUtilsMessengerEXT_T;

namespace Raz {

class XrContext {
public:
explicit XrContext(const std::string& appName);

~XrContext();

private:
using XrInstance = XrInstance_T*;
using XrDebugUtilsMessengerEXT = XrDebugUtilsMessengerEXT_T*;

void recoverApiLayers();
void recoverExtensions();
void createInstance(const std::string& appName);
void destroyInstance();
void createDebugMessenger();
void destroyDebugMessenger();

std::vector<std::string> m_apiLayers;
std::vector<const char*> m_activeApiLayers;
std::vector<std::string> m_extensions;
std::vector<const char*> m_activeExtensions;

XrInstance m_instance {};
XrDebugUtilsMessengerEXT m_debugMsgr {};
uint64_t m_systemId {};
};

} // namespace Raz

#endif // RAZ_XRCONTEXT_HPP
16 changes: 8 additions & 8 deletions src/RaZ/Render/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ namespace Raz {
namespace {

#if !defined(RAZ_PLATFORM_MAC) && !defined(USE_OPENGL_ES)
inline void GLAPIENTRY callbackDebugLog(GLenum source,
GLenum type,
unsigned int id,
GLenum severity,
int /* length */,
const char* message,
const void* /* userParam */) {
inline void GLAPIENTRY logCallback(GLenum source,
GLenum type,
unsigned int id,
GLenum severity,
int /* length */,
const char* message,
const void* /* userParam */) {
if (severity == GL_DEBUG_SEVERITY_NOTIFICATION)
return;

Expand Down Expand Up @@ -132,7 +132,7 @@ void Renderer::initialize() {
if (checkVersion(4, 3)) {
enable(Capability::DEBUG_OUTPUT);
enable(Capability::DEBUG_OUTPUT_SYNCHRONOUS);
glDebugMessageCallback(&callbackDebugLog, nullptr);
glDebugMessageCallback(&logCallback, nullptr);
}
#endif

Expand Down
Loading

0 comments on commit 6c4a477

Please sign in to comment.