EAGL.Examples.LearnOpenGL.GettingStarted.CameraKeyboardDt (eagl v0.8.0)

View Source

LearnOpenGL 7.2 - Camera (Keyboard + Delta Time)

This example demonstrates interactive camera movement using keyboard input with delta time for frame-rate independent movement. The user can move the camera around the scene using WASD keys.

Original C++ Source

This example is based on the original LearnOpenGL C++ tutorial: https://github.com/JoeyDeVries/LearnOpenGL/tree/master/src/1.getting_started/7.2.camera_keyboard_dt

Framework Adaptation Notes

This example introduces interactive camera control concepts:

  • Keyboard input handling for camera movement
  • Delta time calculation for frame-rate independent movement
  • Camera direction vectors for forward/backward and strafe movement
  • Real-time camera position updates based on user input

Key Learning Points

  • Interactive Camera Control: Using keyboard input to move the camera in real-time
  • Delta Time: Ensuring consistent movement speed regardless of frame rate
  • Camera Direction Vectors: Understanding forward, right, and up vectors for 3D movement
  • Continuous Input: Handling multiple keys pressed simultaneously for smooth movement

Camera Movement Controls

  • W: Move forward (in the direction the camera is facing)
  • S: Move backward (opposite to camera direction)
  • A: Strafe left (perpendicular to camera direction)
  • D: Strafe right (perpendicular to camera direction)

Implementation Details

  • Camera starts at position (0, 0, 3) looking down the negative Z-axis
  • Movement speed is scaled by delta time for consistent speed across different frame rates
  • Camera maintains a fixed forward direction (down negative Z-axis)
  • Multiple keys can be pressed simultaneously for diagonal movement

Visual Effect

Shows multiple textured cubes that the user can navigate around:

  • Camera responds immediately to keyboard input
  • Smooth, continuous movement while keys are held
  • Consistent movement speed regardless of frame rate
  • Free camera movement through 3D space
  • 10 cubes with static rotations based on their index (20 degrees × index)

Usage

EAGL.Examples.LearnOpenGL.GettingStarted.CameraKeyboardDt.run_example()

Use WASD keys to move the camera. Press ENTER to exit.

Summary

Functions

run_example(opts \\ [])