EAGL.Window (eagl v0.6.0)
View SourceOpenGL window management and application lifecycle.
Correct window creation with cross-platform OpenGL context setup and automated event handling based on wings_gl.erl patterns.
Original Source
Window creation timing, context setup, and event handling patterns are
based on Wings3D's wings_gl.erl
module:
https://github.com/dgud/wings/blob/master/src/wings_gl.erl
Usage
defmodule MyApp do
use EAGL.Window
def run_example do
# 2D rendering (default)
EAGL.Window.run(__MODULE__, "My 2D App")
# 3D rendering with depth testing
EAGL.Window.run(__MODULE__, "My 3D App", depth_testing: true)
# Custom size and tutorial mode
EAGL.Window.run(__MODULE__, "Tutorial",
size: {1280, 720},
return_to_exit: true
)
end
@impl true
def setup do
# Initialize shaders, load models, set up state
{:ok, initial_state}
end
@impl true
def render(width, height, state) do
# Clear screen and render content
:gl.clearColor(0.2, 0.3, 0.3, 1.0)
:gl.clear(@gl_color_buffer_bit)
# ... render content
:ok
end
@impl true
def cleanup(state) do
# Clean up OpenGL resources
:ok
end
end
Summary
Functions
Creates and runs an OpenGL window using the given callback module. The callback module must implement the GLWindowBehaviour.
Functions
Creates and runs an OpenGL window using the given callback module. The callback module must implement the GLWindowBehaviour.
Options:
- size: {width, height} tuple, defaults to {1024, 768}. Sets the initial window size.
- depth_testing: boolean, defaults to false. When true, enables depth testing and requests a depth buffer.
- return_to_exit: boolean, defaults to false. When true, pressing ENTER will automatically close the window.