Skip to main content

OpenGLEnumMapper Namespace

Definition

namespace helios::ext::opengl::rendering::OpenGLEnumMapper { ... }

Functions Index

GLenumtoOpenGL (helios::rendering::mesh::PrimitiveType primitiveType) noexcept

Translates a helios abstract PrimitiveType enum to its corresponding OpenGL GLenum value. More...

Functions

toOpenGL()

GLenum helios::ext::opengl::rendering::OpenGLEnumMapper::toOpenGL (helios::rendering::mesh::PrimitiveType primitiveType)
nodiscard noexcept

Translates a helios abstract PrimitiveType enum to its corresponding OpenGL GLenum value.

This utility function maps API-agnostic primitive types defined by helios to their OpenGL equivalents. It is used internally by OpenGLMeshRenderer and other OpenGL rendering components.

Supported mappings:

  • `PrimitiveType::Points` → `GL_POINTS`
  • `PrimitiveType::Lines` → `GL_LINES`
  • `PrimitiveType::LineLoop` → `GL_LINE_LOOP`
  • `PrimitiveType::LineStrip` → `GL_LINE_STRIP`
  • `PrimitiveType::Triangles` → `GL_TRIANGLES`
  • `PrimitiveType::TriangleStrip` → `GL_TRIANGLE_STRIP`
  • `PrimitiveType::TriangleFan` → `GL_TRIANGLE_FAN`

Example usage: ```cpp auto glPrimitive = OpenGLEnumMapper::toOpenGL(PrimitiveType::Triangles); glDrawElements(glPrimitive, indexCount, GL_UNSIGNED_INT, nullptr); ```

Parameters
primitiveType

The API-agnostic PrimitiveType value.

Returns

The corresponding OpenGL primitive type as a GLenum. Falls back to `GL_TRIANGLES` if the mapping is not explicitly defined.

info

This function is marked `[[nodiscard]]` to encourage proper usage of the return value.

Definition at line 41 of file OpenGLEnums.ixx.

41 [[nodiscard]] GLenum toOpenGL(helios::rendering::mesh::PrimitiveType primitiveType) noexcept {
42 switch (primitiveType) {
44 return GL_POINTS;
46 return GL_LINES;
48 return GL_LINE_LOOP;
50 return GL_LINE_STRIP;
52 return GL_TRIANGLES;
54 return GL_TRIANGLE_STRIP;
56 return GL_TRIANGLE_FAN;
57 default:
58 return GL_TRIANGLES;
59 }
60 }

References helios::rendering::mesh::LineLoop, helios::rendering::mesh::Lines, helios::rendering::mesh::LineStrip, helios::rendering::mesh::Points, helios::rendering::mesh::TriangleFan, helios::rendering::mesh::Triangles and helios::rendering::mesh::TriangleStrip.

Referenced by helios::ext::opengl::rendering::OpenGLMeshRenderer::render.


The documentation for this namespace was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.