EAGL.Examples.LearnOpenGL.GettingStarted.HelloTriangleExercise2 (eagl v0.1.0)
View SourcePort of LearnOpenGL's Hello Triangle Exercise 2 to EAGL framework.
Original: https://learnopengl.com/Getting-started/Hello-Triangle (Exercise 2) Chapter 1, Section 2.4: Hello Triangle Exercise 2
This example demonstrates:
- Creating two triangles using a single VAO and VBO
- Using an Element Buffer Object (EBO) to avoid vertex duplication
- Drawing with glDrawElements instead of glDrawArrays
- Efficient vertex data sharing between triangles
The two triangles share vertices to form a rectangle:
3 ---- 2
| / |
| / |
| / |
| / |
0 ---- 1
Run with: mix run -e "EAGL.Examples.LearnOpenGL.GettingStarted.HelloTriangleExercise2.run_example()" Or use the script: ./priv/scripts/triangle2
Summary
Functions
@spec run_example() :: :ok | {:error, term()}