ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > CopperCube > Programming and Scripting
forum topic indicator OpenXR Integration
person icon
ArchAngel
Guest
Quote
2025-01-27 00:04:51

So, Ive managed to make some progress with c++ and have already made a custom binary using openxr sdk and openxr_loader.lib and tried to make a .cpp as a main to fuction the xrSession using the COculusRiftSupport.cpp and .h as reference. Managed to build it but still having an issue because when i publish my game with it, it will publish but force closes when it try's to play. when i take it out of the directory and play it, it doesnt force close but will show error that openxr_loader.dll wasnt found because it need to stay in the directory obviously. but that shows that it does integrate it but maybe im just doing something wrong with my program before building it. Anyone willing to help with some experience would be appreciated, thanks.

person icon
ArchAngel
Guest
Quote
2025-01-27 00:45:13

This is one of the binaries im working on main.cpp [code]include "C:\Users\EBENEZER\Desktop\CCModXR\CCModXR\CCModXR\COculusRiftSupport-0.3.h"
include <CFlaceAnimatorCameraFPS.h>
include <CCameraSceneNode.h>

ifdef MAIN_INITIALIZED

ifdef WIN32
ifdef _DEBUG
pragma comment(lib, "openxr_loaderd.lib") // Debug version of the OpenXR loader
else
pragma comment(lib, "openxr_loader.lib") // Release version of the OpenXR loader
endif
endif

include <Windows.h>
include <iostream> // For error reporting and debugging

using namespace irr;

CQuest3Support::CQuest3Support()
: xrInstance(0), xrSystemId(XR_NULL_SYSTEM_ID), xrSession(0),
xrHeadSpace(0), DistortionMeshCreated(false), QuestDeviceAvailable(false),
DeviceIsFakedOnly(false), UserWantedToQuit(false), UseDistortion(true),
CurrentlyRenderingLeftEye(false), WorldUnitScale(1.0f), InitInterpupillaryDistance(0.0f),
RenderTargetTexture(0), HandleLastCameraUsed(0), Width(1280), Height(720) {
RenderTargetSize[0] = 1280;
RenderTargetSize[1] = 720;
EyePos = irr::core::vector3df(0.0f, 0.0f, 0.0f);
EyeYaw = 0.0f;
EyePitch = 0.0f;
EyeRoll = 0.0f;
}

CQuest3Support::~CQuest3Support() {
if (RenderTargetTexture) {
RenderTargetTexture->drop();
}
if (xrSession != XR_NULL_HANDLE) {
xrDestroySession(xrSession);
}
if (xrInstance != XR_NULL_HANDLE) {
xrDestroyInstance(xrInstance);
}
}

void CQuest3Support::globalQuest3Init() {
std::cout << "Global initialization for Quest 3 completed." << std::endl;
}

bool CQuest3Support::initBeforeWindowCreation() {
XrInstanceCreateInfo instanceCreateInfo = { XR_TYPE_INSTANCE_CREATE_INFO };
strcpy(instanceCreateInfo.applicationInfo.applicationName, "Quest3App");
instanceCreateInfo.applicationInfo.apiVersion = XR_CURRENT_API_VERSION;

XrResult result = xrCreateInstance(&instanceCreateInfo, &xrInstance);
if (XR_FAILED(result)) {
std::cerr << "Failed to create OpenXR instance: " << result << std::endl;
UserWantedToQuit = true;
return false;
}

XrSystemGetInfo systemInfo = { XR_TYPE_SYSTEM_GET_INFO };
systemInfo.formFactor = XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY;

result = xrGetSystem(xrInstance, &systemInfo, &xrSystemId);
if (XR_FAILED(result)) {
std::cerr << "Failed to get OpenXR system: " << result << std::endl;
UserWantedToQuit = true;
return false;
}

QuestDeviceAvailable = xrSystemId != XR_NULL_SYSTEM_ID;
return QuestDeviceAvailable;
}

bool CQuest3Support::userWantedToQuit() {
return UserWantedToQuit;
}

void CQuest3Support::adjustIrrlichtCreationParameters(SIrrlichtCreationParameters& params) {
if (QuestDeviceAvailable) {
params.DriverType = video::EDT_OPENGL;
params.WindowSize = core::dimension2d<u32>(Width, Height);
params.Fullscreen = true;
}
}

bool CQuest3Support::onAfterDeviceCreated(IrrlichtDevice* device) {
Device = device;
if (!device || !QuestDeviceAvailable) {
return false;
}

video::IVideoDriver* driver = device->getVideoDriver();
if (driver->queryFeature(video::EVDF_RENDER_TO_TARGET)) {
RenderTargetTexture = driver->addRenderTargetTexture(
core::dimension2d<s32>(RenderTargetSize[0], RenderTargetSize[1]));
if (!RenderTargetTexture) {
std::cerr << "Failed to create render target texture." << std::endl;
return false;
}
}
else {
std::cerr << "Render to target not supported." << std::endl;
return false;
}

createDistortionMesh();
return true;
}

irr::core::vector3df CQuest3Support::getIrrVector(const XrVector3f& xrVector) {
return irr::co

person icon
ArchAngel
Guest
Quote
2025-01-27 00:46:07

[code]include "C:\Users\EBENEZER\Desktop\CCModXR\CCModXR\CCModXR\COculusRiftSupport-0.3.h"
include <CFlaceAnimatorCameraFPS.h>
include <CCameraSceneNode.h>

ifdef MAIN_INITIALIZED

ifdef WIN32
ifdef _DEBUG
pragma comment(lib, "openxr_loaderd.lib") // Debug version of the OpenXR loader
else
pragma comment(lib, "openxr_loader.lib") // Release version of the OpenXR loader
endif
endif

include <Windows.h>
include <iostream> // For error reporting and debugging

using namespace irr;

CQuest3Support::CQuest3Support()
: xrInstance(0), xrSystemId(XR_NULL_SYSTEM_ID), xrSession(0),
xrHeadSpace(0), DistortionMeshCreated(false), QuestDeviceAvailable(false),
DeviceIsFakedOnly(false), UserWantedToQuit(false), UseDistortion(true),
CurrentlyRenderingLeftEye(false), WorldUnitScale(1.0f), InitInterpupillaryDistance(0.0f),
RenderTargetTexture(0), HandleLastCameraUsed(0), Width(1280), Height(720) {
RenderTargetSize[0] = 1280;
RenderTargetSize[1] = 720;
EyePos = irr::core::vector3df(0.0f, 0.0f, 0.0f);
EyeYaw = 0.0f;
EyePitch = 0.0f;
EyeRoll = 0.0f;
}

CQuest3Support::~CQuest3Support() {
if (RenderTargetTexture) {
RenderTargetTexture->drop();
}
if (xrSession != XR_NULL_HANDLE) {
xrDestroySession(xrSession);
}
if (xrInstance != XR_NULL_HANDLE) {
xrDestroyInstance(xrInstance);
}
}

void CQuest3Support::globalQuest3Init() {
std::cout << "Global initialization for Quest 3 completed." << std::endl;
}

bool CQuest3Support::initBeforeWindowCreation() {
XrInstanceCreateInfo instanceCreateInfo = { XR_TYPE_INSTANCE_CREATE_INFO };
strcpy(instanceCreateInfo.applicationInfo.applicationName, "Quest3App");
instanceCreateInfo.applicationInfo.apiVersion = XR_CURRENT_API_VERSION;

XrResult result = xrCreateInstance(&instanceCreateInfo, &xrInstance);
if (XR_FAILED(result)) {
std::cerr << "Failed to create OpenXR instance: " << result << std::endl;
UserWantedToQuit = true;
return false;
}

XrSystemGetInfo systemInfo = { XR_TYPE_SYSTEM_GET_INFO };
systemInfo.formFactor = XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY;

result = xrGetSystem(xrInstance, &systemInfo, &xrSystemId);
if (XR_FAILED(result)) {
std::cerr << "Failed to get OpenXR system: " << result << std::endl;
UserWantedToQuit = true;
return false;
}

QuestDeviceAvailable = xrSystemId != XR_NULL_SYSTEM_ID;
return QuestDeviceAvailable;
}

bool CQuest3Support::userWantedToQuit() {
return UserWantedToQuit;
}

void CQuest3Support::adjustIrrlichtCreationParameters(SIrrlichtCreationParameters& params) {
if (QuestDeviceAvailable) {
params.DriverType = video::EDT_OPENGL;
params.WindowSize = core::dimension2d<u32>(Width, Height);
params.Fullscreen = true;
}
}

bool CQuest3Support::onAfterDeviceCreated(IrrlichtDevice* device) {
Device = device;
if (!device || !QuestDeviceAvailable) {
return false;
}

video::IVideoDriver* driver = device->getVideoDriver();
if (driver->queryFeature(video::EVDF_RENDER_TO_TARGET)) {
RenderTargetTexture = driver->addRenderTargetTexture(
core::dimension2d<s32>(RenderTargetSize[0], RenderTargetSize[1]));
if (!RenderTargetTexture) {
std::cerr << "Failed to create render target texture." << std::endl;
return false;
}
}
else {
std::cerr << "Render to target not supported." << std::endl;
return false;
}

createDistortionMesh();
return true;
}

irr::core::vector3df CQuest3Support::getIrrVector(const XrVector3f& xrVector) {
return irr::core::vector3df(xrVector.x, xrVector.y, xrVector.z);
}

void CQuest3Supp

person icon
ArchAngel
Guest
Quote
2025-01-27 00:47:01

Sorry maybe to long for the
source code
to work

person icon
guest_Robbo
Guest
Quote
2025-01-27 00:47:09

Never tried such stuff before.

You would obviously be using a high quality code editor like Visual Studio Code/Community to debug stuff ?

They seem to have a lot of new features to help diagnose code issues.

person icon
ArchAngel
Guest
Quote
2025-01-27 01:12:17

define MAIN_INITIALIZED
include "C:\\Users\\EBENEZER\Desktop\\CCModXR\\CCModXR\\CCModXR\\COculusRiftSupport-0.3.h"
include <iostream> // For error reporting

int main() {
// Create an instance of CQuest3Support
CQuest3Support quest3Support;

// Initialize the Quest 3 support before creating the rendering window
if (!quest3Support.initBeforeWindowCreation()) {
std::cerr << "Failed to initialize Quest 3 support before window creation." << std::endl;
return -1;
}

// Adjust Irrlicht parameters
irr::SIrrlichtCreationParameters params;
quest3Support.adjustIrrlichtCreationParameters(params);

// Create the Irrlicht device
irr::IrrlichtDevice* device = irr::createDeviceEx(params);
if (!device) {
std::cerr << "Failed to create Irrlicht device." << std::endl;
return -1;
}

// Initialize device-specific settings
if (!quest3Support.onAfterDeviceCreated(device)) {
std::cerr << "Quest 3 device support initialization failed." << std::endl;
device->drop();
return -1;
}

// Main rendering loop
while (device->run()) {
device->getVideoDriver()->beginScene(true, true, irr::video::SColor(255, 100, 101, 140));
quest3Support.drawScene(device->getSceneManager());
device->getVideoDriver()->endScene();
}

// Clean up and exit
device->drop();
return 0;
}


person icon
ArchAngel
Guest
Quote
2025-01-27 01:12:55

This is acually the main the other was another file that goes with it

person icon
guest_guest
Guest
Quote
2025-01-27 09:53:02

@ArchAngel

Are you actually trying something to get CopperCube projects to run as vr games on meta quest 3? If so, that would be great news.

person icon
ArchAngel
Guest
Quote
2025-01-27 19:03:01

Yes, that’s what I’m currently working towards. I’m approaching it at a few different angles and hopefully one of them will work. I have the studio edition so I’m working on a custom binary for those who can use them and for those who can’t I’m creating a c++ server and coppercube side scripts to interact with the server for updates on frames/ headset position/ and motion controller support. May still be a little before I get one running with everything included but stay posted.

person icon
ArchAngel
Guest
Quote
2025-01-27 19:11:07

Also even though it will work on the Quest, it will still be PCVR. So you would need to be connected to pc either via WiFi or link cable.

person icon
ArchAngel
Guest
Quote
2025-01-27 19:14:24

At least until I create an android version.

person icon
ArchAngel
Guest
Quote
2025-01-29 15:25:44

So current state of OpenXrServer.exe- I have been able to get the server to load into OpenXR and attempt to submit the frames for the view to start showing in the headset. But currently failing to load the texture to start viewing, I should have that fixed today! Then incorporating headset tracking and updating, then motion controller tracking as well. Currently working on two different versions, one to not be published with your coppercube game and one to be published with your coppercube game. For the second of the two I’m only having an issue because when published with the ccb game, coppercube runs the custom binary first, which makes it fail because the open r server need the game running first so that it can pull the current OpenGL framebuffer to start, so currently troubleshooting through both. Will give another update when more is completed.


Create reply:










 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


icon_holyicon_cryicon_devilicon_lookicon_grinicon_kissicon_monkeyicon_hmpf
icon_sadicon_happyicon_smileicon_uhicon_blink   






Copyright© Ambiera e.U. all rights reserved.
Contact | Imprint | Products | Privacy Policy | Terms and Conditions |