Skip to main content

OpenGLEnumMapper Namespace

Definition

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

Functions Index

GLenumtoOpenGL (const PrimitiveType primitiveType) noexcept

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

Functions

toOpenGL()

GLenum helios::opengl::OpenGLEnumMapper::toOpenGL (const PrimitiveType primitiveType)
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::PointsGL_POINTS
  • PrimitiveType::LinesGL_LINES
  • PrimitiveType::LineLoopGL_LINE_LOOP
  • PrimitiveType::LineStripGL_LINE_STRIP
  • PrimitiveType::TrianglesGL_TRIANGLES
  • PrimitiveType::TriangleStripGL_TRIANGLE_STRIP
  • PrimitiveType::TriangleFanGL_TRIANGLE_FAN

Example usage:

 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 OpenGLEnumMapper.ixx.

41 [[nodiscard]] GLenum toOpenGL(const PrimitiveType primitiveType) noexcept {
42 switch (primitiveType) {
43 case PrimitiveType::Points:
44 return GL_POINTS;
45 case PrimitiveType::Lines:
46 return GL_LINES;
47 case PrimitiveType::LineLoop:
48 return GL_LINE_LOOP;
49 case PrimitiveType::LineStrip:
50 return GL_LINE_STRIP;
51 case PrimitiveType::Triangles:
52 return GL_TRIANGLES;
53 case PrimitiveType::TriangleStrip:
54 return GL_TRIANGLE_STRIP;
55 case PrimitiveType::TriangleFan:
56 return GL_TRIANGLE_FAN;
57 default:
58 return GL_TRIANGLES;
59 }
60 }

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.