Skip to content

Commit

Permalink
test oculus openxr env
Browse files Browse the repository at this point in the history
  • Loading branch information
ferriarnus committed Nov 19, 2024
1 parent d51fea3 commit 2b97efb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -880,14 +880,9 @@ private void initializeOpenXRSession() {

session = new XrSession(sessionPtr.get(0), instance);

XrSessionBeginInfo sessionBeginInfo = XrSessionBeginInfo.calloc(stack);
sessionBeginInfo.type(XR10.XR_TYPE_SESSION_BEGIN_INFO);
sessionBeginInfo.next(NULL);
sessionBeginInfo.primaryViewConfigurationType(XR10.XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO);

error = XR10.xrBeginSession(session, sessionBeginInfo);
logError(error, "xrBeginSession", "");
this.isActive = true;
while (!this.isActive) {
pollVREvents();
}

}
}
Expand Down Expand Up @@ -988,7 +983,7 @@ private void initializeOpenXRSwapChain() {
XrSwapchainCreateInfo swapchainCreateInfo = XrSwapchainCreateInfo.calloc(stack);
swapchainCreateInfo.type(XR10.XR_TYPE_SWAPCHAIN_CREATE_INFO);
swapchainCreateInfo.next(NULL);
swapchainCreateInfo.createFlags(XR10.XR_SWAPCHAIN_CREATE_STATIC_IMAGE_BIT);
swapchainCreateInfo.createFlags(0);
swapchainCreateInfo.usageFlags(XR10.XR_SWAPCHAIN_USAGE_COLOR_ATTACHMENT_BIT);
swapchainCreateInfo.format(chosenFormat);
swapchainCreateInfo.sampleCount(1);
Expand Down Expand Up @@ -1355,7 +1350,6 @@ private long createAction(String name, String localisedName, String type, XrActi
case "pose" -> hands.actionType(XR10.XR_ACTION_TYPE_POSE_INPUT);
case "haptic" -> hands.actionType(XR10.XR_ACTION_TYPE_VIBRATION_OUTPUT);
}
hands.countSubactionPaths(0);
if(subactionPaths != null) {
LongBuffer buffer = stackCallocLong(subactionPaths.length);
for(String path : subactionPaths) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private void triggerHapticPulse(ControllerType controller, float durationSeconds
info.action(new XrAction(MCOpenXR.get().haptics[i], actionSet));

XrHapticVibration vibration = XrHapticVibration.calloc(stack);
vibration.type(XR10.XR_ACTION_TYPE_VIBRATION_OUTPUT);
vibration.type(XR10.XR_TYPE_HAPTIC_VIBRATION);
vibration.next(NULL);
vibration.duration((long) (durationSeconds * 1_000_000_000));
vibration.frequency(frequency);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@
import org.vivecraft.client_vr.provider.VRRenderer;
import org.vivecraft.client_vr.render.RenderConfigException;

import java.nio.ByteBuffer;
import java.nio.IntBuffer;

import static org.lwjgl.system.MemoryUtil.memAddress;
import static org.lwjgl.system.MemoryUtil.memUTF8;

public class OpenXRStereoRenderer extends VRRenderer {
private final MCOpenXR openxr;
private int swapIndex;
Expand Down Expand Up @@ -129,9 +125,10 @@ public void endFrame() throws RenderConfigException {
GL31.glBlitFramebuffer(0,0, getRightEyeTarget().viewWidth, getRightEyeTarget().viewHeight, 0,0, rightFramebuffers[swapIndex].viewWidth, rightFramebuffers[swapIndex].viewHeight, GL31.GL_STENCIL_BUFFER_BIT | GL31.GL_COLOR_BUFFER_BIT, GL31.GL_NEAREST);

try (MemoryStack stack = MemoryStack.stackPush()){
PointerBuffer layers = stack.callocPointer(1);
int error;
if (this.openxr.shouldRender) {
PointerBuffer layers = stack.callocPointer(1);
int error;

error = XR10.xrReleaseSwapchainImage(
openxr.swapchain,
XrSwapchainImageReleaseInfo.calloc(stack)
Expand All @@ -144,17 +141,18 @@ public void endFrame() throws RenderConfigException {
.views(projectionLayerViews);

layers.put(compositionLayerProjection);

layers.flip();

error = XR10.xrEndFrame(
openxr.session,
XrFrameEndInfo.calloc(stack)
.type(XR10.XR_TYPE_FRAME_END_INFO)
.displayTime(openxr.time)
.environmentBlendMode(XR10.XR_ENVIRONMENT_BLEND_MODE_OPAQUE)
.layers(layers));
this.openxr.logAll(error, "xrEndFrame", "");
}
layers.flip();

error = XR10.xrEndFrame(
openxr.session,
XrFrameEndInfo.calloc(stack)
.type(XR10.XR_TYPE_FRAME_END_INFO)
.displayTime(openxr.time)
.environmentBlendMode(XR10.XR_ENVIRONMENT_BLEND_MODE_OPAQUE)
.layers(layers));
this.openxr.logAll(error, "xrEndFrame", "");

projectionLayerViews.close();
}
Expand Down

0 comments on commit 2b97efb

Please sign in to comment.