Looking Glass Documentation
Buy Looking GlassDiscord
  • Looking Glass User Guide
  • NEW! โœจLooking Glass Goโœจ
  • Displays
    • ๐Ÿ”ฎLooking Glass Go
      • โšกGet Started with Looking Glass Go
      • ๐Ÿ“ฑUsing the Go Mobile App
      • ๐Ÿ”†Liteformsโ„ข
      • ๐Ÿ–ฅ๏ธStandalone and Desktop Modes
      • ๐Ÿ”ŒPower and LED States
      • ๐Ÿช„Default Playlist
      • โญ๏ธWhat's Next?
      • ๐Ÿ‘œAccessories
      • โš™๏ธAdvanced Playlist Creation
      • โš™๏ธManual Firmware Update
      • โ“Common Troubleshooting Issues
    • ๐Ÿ”ฎLooking Glass 16" Light Field Displays
      • ๐Ÿช„Looking Glass 16" Light Field Display (Landscape)
      • ๐Ÿช„Looking Glass 16" Light Field Display (Portrait)
      • โ“Common Troubleshooting Issues
    • ๐Ÿ”ฎLooking Glass 32" Light Field Displays
      • ๐Ÿช„Looking Glass 32" Light Field Display (Landscape)
      • ๐Ÿช„Looking Glass 32" Light Field Display (Portrait)
      • โ“Common Troubleshooting Issues
    • ๐Ÿ”ฎLooking Glass 65" Light Field Display
    • ๐Ÿ”ฎLooking Glass Portrait
      • โšกGet Started with Looking Glass Portrait
      • ๐ŸŽ‡Demo Holograms
      • โ“Common Troubleshooting Issues
  • Software Tools
    • ๐Ÿ“šOverview
    • ๐ŸŒ‰Looking Glass Bridge
      • โœจUsing Looking Glass Bridge
      • ๐ŸชŸDisplay Settings on Windows
      • ๐ŸŽDisplay Settings on macOS
      • ๐ŸงDisplay Settings on Linux
      • ๐Ÿ‘ทTroubleshooting
    • ๐Ÿ“ฝ๏ธLooking Glass Studio
      • ๐Ÿ“šUsing Looking Glass Studio
      • RGB-D Photo / Video
      • Quilt Images / Video
      • iPhone Portrait Photos
      • Android Depth Photos
        • Samsung Portrait Mode
      • Light Field Photosets
      • Exporting Holograms
      • Troubleshooting
    • ๐ŸงŠLooking Glass Blocks
      • โœจConvert any image into a hologram
      • โฌ†๏ธUploading, editing and sharing Quilts
      • ๐ŸฅฝViewing your holograms on different platforms
    • ๐ŸŽฌHologram Video
    • ๐Ÿ”†Liteformsโ„ข
      • ๐ŸชŸGet Started on Windows
      • ๐ŸŽGet Started on MacOS
      • ๐Ÿง™Making Custom Liteforms
      • ๐ŸชConfigure Liteforms for Kiosk Setup
    • ๐Ÿ‘€Looking Glass Model Viewer
    • ๐ŸงชExperiments
      • ๐Ÿ“ฝ๏ธMedia Encoder
      • โฉLooking Glass Media Encoder
  • Key Concepts
    • ๐Ÿ”‘Hologram 101
      • ๐ŸŽ‰Making great holograms
      • ๐ŸŒŽHolograms in the real world
      • ๐Ÿ‘พHolograms, but virtual
    • ๐Ÿ”How does Looking Glass Work?
    • ๐Ÿ“ธVirtual Camera
    • ๐ŸงŠ3D Design Guidelines
      • Lighting
      • Post-Processing
      • Scene Composition
      • Materials & Textures
      • Performance
    • ๐Ÿ’กQuilts
      • ๐ŸŽฌQuilt Video Encoding
    • ๐Ÿ’กLight Fields
      • โšกLinear Light Field Capture
    • ๐Ÿ“ฝ๏ธFilming a Looking Glass
  • Creator Tools
    • ๐ŸŽจOverview
    • ๐Ÿ”ŒUnity
      • โšกUsing Unity with Looking Glass
      • Setting up your Development Environment
      • Example Scenes
      • Prefabs
        • Hologram Camera
        • 3D Cursor
        • Dual Monitor Application
      • Script Reference
        • HologramCamera.cs
        • LKGDisplaySystem.cs
        • QuiltCapture.cs
        • Cursor3D.cs
        • OrbitControls.cs
        • BlockUploader.cs
        • MobileDMAController.cs
        • iOS Sample Scene Scripts
          • ChangeInteractionModality.cs
          • XYSlider.cs
          • XYSpotlight.cs
          • AudioRotateControl.cs
          • ModelController.cs
          • DemoIOSUIController.cs
          • PageHandler.cs
          • PageConnectHandler.cs
          • PageCalibrateHandler.cs
          • PageTestHandler.cs
          • DynamicAlcove.cs
      • Package Integrations
        • Built-in Render Pipeline Post-Processing
      • Developing for iOS
      • Depth of Field and Other Post-Processing Effects
      • Quilt Video Audio and Playback
      • Developing for Ultraleap Hand Tracking on Looking Glass
      • Looking Glass Pro (Legacy)
      • Additional Support
      • Change Log
    • ๐ŸนBlender
    • ๐Ÿ”ŒUnreal Engine
      • ๐Ÿ—’๏ธChange Log and Old Versions
      • ๐Ÿ’ฝInstalling the Unreal Engine plugin
      • ๐ŸŽฅUsing the Unreal Engine Plugin
        • Using the HoloPlay Capture
        • Exporting Quilt Images and Video with Sequencer
      • Accessing HoloPlay Data with Blueprint Scripting
      • Packaging the Project
      • Unreal Engine 4 (Legacy Support)
        • Unreal Engine 4 Quick Start
          • Using the HoloPlay Capture
          • Exporting Quilt Images and Video with Sequencer
    • ๐ŸŒWebXR
      • ๐Ÿ”ถPlayCanvas
      • 3๏ธโƒฃ3๏ธโƒฃ Three.JS
      • โš›๏ธReact-Three-Fiber
      • ๐ŸŒˆSpline
  • Tutorials
    • ๐Ÿ“ฑRunning Looking Glass Displays with iOS Devices
    • โ“‚๏ธCapturing Light Fields in Maya
    • ๐Ÿง‘โ€๐Ÿ”ฌUsing ShaderToy with Looking Glass
    • ๐ŸŽจSculpting with Adobe Medium and Looking Glass
    • ๐Ÿ”Turn Videogames Holographic with Refract
    • ๐Ÿ–๏ธBuilding with Leap Motion
  • Developer Docs
    • โš™๏ธLooking Glass Bridge SDK
      • ๐Ÿช›Web Application Integration
      • ๐Ÿ”ŒIntegrating Native Applications
      • ๐Ÿ““Native Function Reference
    • ๐ŸฆLooking Glass Core Migration Guide
  • Third Party Software
    • ๐Ÿ—ก๏ธ3D Slicer
    • ๐Ÿ”ฌVTK (Visualization Toolkit)
    • ๐Ÿ—บ๏ธParaView
    • ๐Ÿ”ฉCommunity Made Tools & Projects
  • Legacy Software
    • ๐Ÿ“ก3D Model Importer
      • 3D Model Importer App Guide
      • 3D Model Importer App Reference
    • ๐ŸŽญDiorama
      • Change Log
    • ๐ŸŽž๏ธDepth Recorder
    • ๐Ÿ“ธLightfield Photo App
    • ๐ŸLooking Glass Core Overview
    • ๐Ÿฝ๏ธLooking Glass Core SDK
      • C API Overview
        • HoloPlayCore.h
          • State Functions
          • General-Query-Functions
          • Device-Query-Functions
        • libHoloPlayCore.h
        • HoloPlayShaders.h
    • ๐Ÿ”ฐLooking Glass Core JS
      • API
        • HoloPlayCore.Client
        • HoloPlayCore.Message
        • HoloPlay Service Related
        • examples
  • Legacy Hardware
    • ๐Ÿ”ปLooking Glass 8.9"
    • ๐Ÿ”ปLooking Glass 15.6"
    • ๐Ÿ”ปLooking Glass 8K
    • ๐Ÿ”ปLooking Glass 16"
    • ๐Ÿ”ปLooking Glass 32"
    • ๐Ÿ”ปLooking Glass Pro
  • ๐Ÿ’ฌContact Us
  • ๐Ÿ› ๏ธFAQ & Troubleshooting
Powered by GitBook

Follow us

  • Twitter
  • Instagram
  • LinkedIn
On this page
  • Overview
  • Configure a Shared GPU Rendering Context
  • Initialize Bridge
  • Create a Looking Glass window
  • Render Views of a 3D Scene
  • Trigger the Bridge Post-Processing

Was this helpful?

  1. Developer Docs
  2. Looking Glass Bridge SDK

Integrating Native Applications

Bring support for the Looking Glass display to your application

PreviousWeb Application IntegrationNextNative Function Reference

Last updated 1 month ago

Was this helpful?

Overview

See our samples on how to use the SDK .

Integrating with the Bridge SDK consists of five steps:

  1. Configure a shared GPU rendering context

  2. Initialize Bridge to spawn a post-processing thread and allocate resources

  3. Create a Looking Glass window using the shared rendering context

  4. Render views of a 3D scene into a framebuffer object

  5. Trigger the Bridge post-processing step with the framebuffer object

This method of integration works for all Looking Glass displays. It is supported on Windows and MacOS using OpenGL. It is supported on Windows using DirectX 11 and 12. It is supported on MacOS using Metal. This method will apply a special transformation function that will map each diode on the Looking Glass display to the correct color corresponding to the direction of light emitted from the diode. This was previously the responsibility of the developer using HoloPlay Core. This example will demonstrate the aforementioned steps using OpenGL.

Configure a Shared GPU Rendering Context

The first step is to configure a GPU rendering context. This example code uses GLFW with GLAD:

// initialize glfw
if (!glfwInit()) return -1;

// create preview window
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow* window = glfwCreateWindow(800, 800, "Bridge SDK example", nullptr, nullptr);

if (!window) {
	glfwTerminate();
	return -1;
}
glfwMakeContextCurrent(window);

Initialize Bridge

The second step is to initialize Bridge. This step is required before calling any other Bridge functions.

initialize_bridge("Bridge SDK example");

// query the available Looking Glass displays
int lkg_display_count = 0;
std::vector<unsigned long> lkg_displays;
get_displays(&lkg_display_count, nullptr);
lkg_displays.resize(lkg_display_count);
get_displays(&lkg_display_count, lkg_displays.data());

Create a Looking Glass window

The third step is to create a window that can be used to render to a Looking Glass display.

// perform any desired queries on the Looking Glass displays
std::wstring serial;
std::vector<std::wstring> lkg_display_serials;
int serial_count = 0;

// query all connected Looking Glass displays
for (auto it : lkg_displays) {
    get_device_serial_for_display(it, &serial_count, nullptr);
    serial.resize(serial_count);
    get_device_serial_for_display(it, &serial_count, serial.data());
    lkg_display_serials.push_back(serial);
}

// Note: callers are required to allocate enough memory for return parameters \
of variable length

// create window using configuration from the target Looking Glass display
unsigned long lkg_wnd;
instance_window_gl(&lkg_wnd, lkg_displays.front());

Render Views of a 3D Scene

The fourth step is to render a 3D scene into a framebuffer object using a quilt layout.

// Configure your 3D scene geometry and rendering pipeline...

// Get idealized rendering parameters for the display
get_default_quilt_settings(lkg_wnd, &lkg_aspect, &lkg_quilt_w, &lkg_quilt_h, &lkg_vx, &lkg_vy);
lkg_view_w  = int(float(lkg_quilt_w) / float(lkg_vx));
lkg_view_h = int(float(lkg_quilt_h) / float(lkg_vy));

// Configure texture for the framebuffer
glGenTextures(1, &lkg_render_texture);
glBindTexture(GL_TEXTURE_2D, lkg_render_texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, lkg_quilt_w, lkg_quilt_h, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);

// Configure the renderbuffer for depth
glGenRenderbuffers(1, &lkg_depth_buffer);
glBindRenderbuffer(GL_RENDERBUFFER, lkg_depth_buffer); 
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT32, lkg_quilt_w, lkg_quilt_h);

// Configure the shared framebuffer object
glGenFramebuffers(1, &lkg_render_fbo);
glBindFramebuffer(GL_FRAMEBUFFER, lkg_render_fbo);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, lkg_render_texture, 0);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, lkg_depth_buffer);

// Render views into framebuffer using quilt layout
glBindFramebuffer(GL_FRAMEBUFFER, lkg_render_fbo);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
float cam_dist = 0.005f;
float cam_offset = -(float)(lkg_vx * lkg_vy - 1) / 2.0f * cam_dist;
for (int y = 0; y < lkg_vx; y++) {
	for (int x = 0; x < lkg_vy; x++) {
		glViewport(x*lkg_view_w, y*lkg_view_h, lkg_view_w, lkg_view_h);
		
		// drawScene(your_shader, your_geometry, cam_offset);
		
		cam_offset += cam_dist;
    }
}

Trigger the Bridge Post-Processing

The fifth and last step consists of trigger the post-processing shader pipeline necessary to apply the Looking Glass optical transformation.

draw_interop_quilt_texture_gl(lkg_wnd, 
                              lkg_render_texture,
                              PixelFormats::RGBA,
                              lkg_quilt_w,
                              lkg_quilt_h,
                              lkg_vx,
                              lkg_vy,
                              1.0f,
                              1.0f);

Note: Upon termination the application should also call uninitialize_bridge when deallocating any other resources used by the program.

โš™๏ธ
๐Ÿ”Œ
here