EAGL.Examples.LearnOpenGL.GettingStarted.TransformationsExercise1 (eagl v0.7.0)
View SourceLearnOpenGL 5.2 - Transformations Exercise 1
This exercise demonstrates multiple transformation techniques by rendering two containers with different transformation behaviors. It builds on the basic transformations from 5.1 and shows how to apply different transformations to multiple objects in a single scene.
Original C++ Source
This example is based on the original LearnOpenGL C++ tutorial exercises: https://github.com/JoeyDeVries/LearnOpenGL/tree/master/src/1.getting_started/5.1.transformations
Exercise Focus
This exercise demonstrates:
- Multiple Draw Calls: Rendering the same geometry with different transformations
- Varying Transformations: Different transformation matrices for different objects
- Animation Techniques: Scaling with sine functions and continuous rotation
- Matrix Isolation: How each object gets its own transformation matrix
EAGL Implementation
This implementation renders two textured rectangles:
- First Container: Positioned at bottom-right, rotates continuously
- Second Container: Positioned at top-left, scales up and down using sine wave
The key insight is that we can render the same VAO multiple times with different transformation matrices to create distinct objects in the scene.
Key Learning Points
- Object Instancing: Same geometry, different transformations
- Sine Wave Animation: Using trigonometric functions for smooth scaling
- Matrix Independence: Each draw call uses its own transformation matrix
- Performance: Multiple draw calls vs instanced rendering considerations
- Transformation Variety: Rotation vs scaling animations
Mathematical Background
- Sine Wave Scaling:
sin(time)
creates oscillation between -1 and 1 - Absolute Scaling: Using
abs(sin(time))
to prevent negative scaling - Time-based Animation: System time drives smooth, continuous motion
- Matrix Composition: Different combinations of transformations per object
Visual Effect
Two containers are displayed simultaneously:
- Bottom-right container rotates smoothly around its center
- Top-left container pulses in size, scaling larger and smaller rhythmically
Usage
EAGL.Examples.LearnOpenGL.GettingStarted.TransformationsExercise1.run_example()
Press ENTER to exit the example.