EAGL.Examples.LearnOpenGL.GettingStarted.HelloWindowClear (eagl v0.3.0)
View SourceLearnOpenGL 1.2 - Hello Window Clear
This example demonstrates setting a custom clear color for the OpenGL framebuffer. It builds upon the 1.1 Hello Window example by showing how to control the background color.
Original C++ Source
This example is based on the original LearnOpenGL C++ tutorial: https://github.com/JoeyDeVries/LearnOpenGL/tree/master/src/1.getting_started/1.2.hello_window_clear
Framework Adaptation Notes
In the original LearnOpenGL C++ tutorial, this example introduces the concept of:
glClearColor()
- setting the clear color stateglClear(GL_COLOR_BUFFER_BIT)
- actually clearing the buffer
EAGL's Window framework automatically handles clearing for clean state, but this example demonstrates the pedagogical concepts by:
- Explicitly calling
glClearColor()
to set a custom color - Showing the difference between state-setting and state-using functions
- Explaining the OpenGL state machine concept
Original Tutorial Concepts Demonstrated
- OpenGL State Machine:
glClearColor
sets state,glClear
uses that state - Color Buffer Clearing: Essential for preventing visual artifacts
- RGBA Color Values: Understanding the 0.0-1.0 range for color components
- Render Loop Integration: Where clearing fits in the rendering pipeline
Key Learning Points
- Understanding OpenGL's state-setting vs state-using functions
- The importance of clearing buffers each frame
- How color values work in OpenGL (0.0-1.0 range)
- The difference between this and 1.1 (black vs colored background)
Usage
EAGL.Examples.LearnOpenGL.GettingStarted.HelloWindowClear.run_example()
Press ENTER to exit the example.