AGL
A graphics library
Examples

Built-in meshes

The following example shows how to enable fog, set colors, and draw different primitives. The properties correspond to uniform variables in the active shader. This example uses per-pixel phong shading, defined here. The full code is here.


Custom meshes

Dynamic mesh

To create a dynamic triangle mesh, override agl::TriangleMesh and call agl::Mesh::setIsDynamic. Below, we override the agl::Plane primitive. The full code is here.

Point mesh

The following example overrides agl::PointMesh` to draw a a strange attractor using 400,000 points. The full code is here.

Textures

Textures can be loaded using agl::Renderer::loadTexture and passed to the active shader with agl::Renderer::texture.

Dynamic Texture

Textures can be modified from your application. In the following example, the texture changes with the 'up' key. The full code is here.

Procedural texture

We can create textures directly from code. Below we draw a checker pattern using the agl::Image class. The full code is here.

checker

Sprites

The following example shows how primitives using the same shader can each have their texture. The full code is here.

Note
If the same slot id is used for both textures, the new texture replaces the old one. If multiple textures are needed within the same shader, they should each have their own slot id.

checker

Cubemap

The follow code shows how to load a cubemap using agl::Renderer::texture and agl::Renderer::loadCubemap. The full code is here.

Shadertoy

You can write fragment programs that do ray tracing and ray marching – like in shadertoy. Below we draw a quad the faces the camera and has the same dimensions as the window. The scene is then drawn in glsl-raymarch.fs. The application code is here.