easy-gl › Feature
Feature
An enum class used with Device::supports(), Device::require(), and Capabilities::supports(). Defines named capabilities that may or may not be present depending on the OpenGL version or extensions available.
enum class Feature {
VertexArrayObject,
Shader,
Program,
Buffer,
BasicRendering,
DebugOutput,
ComputeShader,
GeometryShader,
TessellationShader,
Texture3D,
TextureFloat,
TextureRG,
SamplerObject,
Instancing,
UniformBufferObject,
FramebufferObject,
Multisampling,
DrawBuffers,
MapBuffer,
DirectStateAccess,
ClipControl,
TextureCompression,
AnisotropicFiltering,
OpenGlOnlyImmediateMode,
OpenGlOnlyPolygonMode,
OpenGlOnlyLineWidthWide
};
Using Feature for runtime branching
if (device.supports(easygl::Feature::AnisotropicFiltering)) {
tex.set_parameter(easygl::TextureTarget::Texture2D,
easygl::TextureParameter::MaxAnisotropy, 16.0f);
}
if (device.supports(easygl::Feature::TessellationShader)) {
device.set_patch_vertices(3);
// submit tessellated draw ...
} else {
// fallback to triangle mesh ...
}
Requiring a feature (throw on missing)
// Abort early with a clear message if FBOs are not available
device.require(easygl::Feature::FramebufferObject);
device.require(easygl::Feature::UniformBufferObject);
OpenGlOnlyImmediateMode, OpenGlOnlyPolygonMode, and OpenGlOnlyLineWidthWide are features that exist only on desktop OpenGL and are never available on OpenGL ES. Check before using glBegin/glEnd, glPolygonMode, or wide line widths.