Odin OpenXr with Raylib
▲ 22 r/odinlang+2 crossposts

Odin OpenXr with Raylib

LINK: https://github.com/cody977/odin-openxr-raylib

--DISCLAIMER--

I am only a hobbyist programmer and wanted to use Odin for VR so I used Claude to get OpenXr working with Raylib. Everything is AI generated (since I could not do it alone). Has been tested and working on Windows 11 with Quest3 using Steam Link.

I will be using this to make my own VR engine but sharing as someone smarter than me can improve on it and bring the VR world to Odin.

--ABOUT--

A minimal PC VR application in Odin. raylib provides the OpenGL context and all the drawing; OpenXR provides head pose, per-eye projection, controller input, and the swapchain images the compositor displays.

The trick that makes it work: raylib's RenderTexture2D is a plain struct holding OpenGL object ids. Nothing requires those ids to come from raylib, so we build a framebuffer around the texture OpenXR hands us. From that point on BeginTextureMode renders straight into the headset's swapchain, and ordinary raylib draw calls — DrawModelEx, materials, custom shaders — work unchanged.

Features

  • Stereo rendering with correct asymmetric per-eye projection
  • Head and controller tracking
  • Full Meta Touch input: triggers, grips, thumbsticks, A/B/X/Y, menu, haptics
  • Desktop mirror window
  • ~900 lines across 10 files, no engine, no abstraction layer

Requirements

Windows, an OpenXR runtime (SteamVR or Meta Link), and a tethered headset. Odin has no Android target, so standalone Quest builds are not possible.

Setup

  1. odin run . -out:editor.exe

scene.odin is the file you edit; everything prefixed xr_ is plumbing. See the guide PDF for how it all fits together and a symptom-to-cause table for the failures that are silent in VR.

Just download the folder and run it, ensure that your headset is connected and steam VR is running first.

u/Huge-Square-3197 — 7 days ago
▲ 28 r/odinlang+1 crossposts

Affinity Engine is a custom 3D game engine and editor built from scratch in the Odin programming language, using Raylib for rendering and Dear ImGui for the editor UI.

Every system is hand-written. I have designed it for full control over how data flows, how scenes are structured, and how things render while using Raylib to handle the "hard part" of 3D.

This is a preview of the editor so far and the 3d rendering. The editor currently includes gizmo, entity creation, entity editing, entity removal, entity duplication, entity management (id's, names, transforms etc..) file management, .json scene save/load, and a "play/stop" game feature. This is very early and just meant to be used as a preview of what's to come.

The project will be focused towards people wanting to create games or 3D scenes using the Odin language. I have plans on adding Lua as a scripting language later on.

The engine is maintaining a steady performance with no noticeable spikes. A public Alpha release date is to be determined.

(1) Facebook

https://preview.redd.it/bkrwin2v5czg1.jpg?width=2048&format=pjpg&auto=webp&s=b554e28ee3b3cea0edd1111912efadc2f27f407f

reddit.com
u/Huge-Square-3197 — 4 months ago