io7m
io7m-jcanephora 0.45.0
3.7
JCGLClearType

- 3.7.1. Description
- 3.7.2. Usage example

3.7.1
Description
1
The JCGLClearType interface provides functions for clearing the contents of framebuffers.
3.7.2
Usage example
1
The following code creates a clearing specification that will clear the current framebuffer to a dark grey color, and the current depth buffer to 1.0:
3.7.2.1. Blending

    JCGLClearType g;

    final JCGLClearSpecification.Builder cb = JCGLClearSpecification.builder();
    cb.setColorBufferClear(new VectorI4F(0.1f, 0.1f, 0.1f, 1.0f));
    cb.setDepthBufferClear(1.0f);
    JCGLClearSpecification c = cb.build();

    g.clear(c);

2
The JCGLClearSpecification value can be re-used indefinitely. The API also provides optional strict checking which can, for example, raise an exception if the programmer attempts to clear the depth or stencil buffer without the current framebuffer actually having one [4].

[4]
This is usually the result of the programmer forgetting to attach a depth/stencil attachment on framebuffer creation, and can lead to difficult-to-trace bugs.