https://github.com/functionally/opengl-spacenavigator
https://github.com/functionally/opengl-spacenavigator
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/functionally/opengl-spacenavigator
- Owner: functionally
- License: mit
- Created: 2022-11-10T06:31:30.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-11-10T06:59:35.000Z (over 3 years ago)
- Last Synced: 2025-02-24T08:18:17.715Z (over 1 year ago)
- Language: Haskell
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: ReadMe.md
- License: LICENSE
Awesome Lists containing this project
README
Functions for using SpaceNavigator-compatible 3D Mice with OpenGL
=================================================================
This Haskell package contains functions for managing input from a SpaceNavigator <>, or a 3D mouse compatible with its protocols. OpenGL callbacks are provided, along with utilities for quantizing the input from the mouse or tracking its six degrees of freedom.
Please report issues at <>.
Skeletal example illustrating the use of a SpaceNavigator with OpenGL
---------------------------------------------------------------------
```haskell
main :: IO ()
main = do
_ <- getArgsAndInitialize
initialDisplayMode $= [WithDepthBuffer, DoubleBuffered]
_ <- createWindow "SpaceNavigator OpenGL Example"
depthFunc $= Just Less
-- Create the tracker.
tracking <- newIORef $ def {spaceNavigatorPosition = Vector3 0 0 0}
-- Register a callback which quantizes and tracks the 3D mouse input.
spaceNavigatorCallback $=! Just ( quantizeSpaceNavigator defaultQuantization $ trackSpaceNavigator defaultTracking tracking)
-- The display callback needs the tracker.
displayCallback $= display tracking
idleCallback $= Just (postRedisplay Nothing)
mainLoop
display :: IORef SpaceNavigatorTrack -> DisplayCallback
display tracking =
do
clear [ColorBuffer, DepthBuffer]
loadIdentity
-- Get the tracking state.
tracking' <- get tracking
-- Update the matrix based on the tracking
doTracking tracking'
-- All of the rendering actions go here.
renderPrimitive . . .
swapBuffers
```
Notes on hardware and software
------------------------------
This code has been validated with the following configuration of hardware and software:
* SpaceNavigator <>
* spacenavd <>, 0.5
* Ubuntu 15.04, 64-bit
* GHC 7.6.3
* OpenGL == 2.8.0.0
* GLUT == 2.4.0.0