cae  0.0.0
Cross-API graphics engine
Loading...
Searching...
No Matches
cae::OPGL Class Referencefinal

Class for the OpenGL plugin. More...

#include <OPGL.hpp>

+ Inheritance diagram for cae::OPGL:
+ Collaboration diagram for cae::OPGL:

Public Member Functions

 OPGL ()=default
 
 ~OPGL () override=default
 
 OPGL (const OPGL &)=delete
 
OPGLoperator= (const OPGL &)=delete
 
 OPGL (OPGL &&)=delete
 
OPGLoperator= (OPGL &&)=delete
 
std::string getName () const override
 Get the name of the plugin.
 
utl::PluginType getType () const override
 Get the type of the plugin.
 
utl::PluginPlatform getPlatform () const override
 Get the handled platform of the plugin.
 
void setVSyncEnabled (const bool enabled) override
 Enable or disable VSync.
 
void setClearColor (const Color &color) override
 Set the clear color.
 
bool isVSyncEnabled () const override
 Check if VSync is enabled.
 
void initialize (const NativeWindowHandle &nativeWindowHandle, const Color &clearColor) override
 Initialize the renderer with a native window handle and clear color.
 
void createPipeline (const ShaderID &id, const ShaderIRModule &vertex, const ShaderIRModule &fragment) override
 Create a rendering pipeline with vertex and fragment shaders.
 
void draw (const WindowSize &windowSize, const ShaderID &shaderId, glm::mat4 mvp) override
 Draw the scene using the specified shader and window size.
 
void createMesh (const std::vector< float > &vertices) override
 Create a mesh with the given vertex data.
 
- Public Member Functions inherited from cae::ARenderer
 ~ARenderer () override=default
 
- Public Member Functions inherited from cae::IRenderer
 ~IRenderer () override=default
 
- Public Member Functions inherited from utl::IPlugin
virtual ~IPlugin ()=default
 

Static Private Member Functions

static GLuint createGLShader (GLenum type, const ShaderIRModule &data, const GladGLContext &gl)
 

Private Attributes

std::unique_ptr< IContextm_context
 
std::unordered_map< ShaderID, GLuint > m_programs
 
Mesh m_mesh
 
GLuint m_ubo
 

Detailed Description

Class for the OpenGL plugin.

Definition at line 32 of file OPGL.hpp.

Constructor & Destructor Documentation

◆ OPGL() [1/3]

cae::OPGL::OPGL ( )
default

◆ ~OPGL()

cae::OPGL::~OPGL ( )
overridedefault

◆ OPGL() [2/3]

cae::OPGL::OPGL ( const OPGL & )
delete

◆ OPGL() [3/3]

cae::OPGL::OPGL ( OPGL && )
delete

Member Function Documentation

◆ createGLShader()

GLuint cae::OPGL::createGLShader ( GLenum type,
const ShaderIRModule & data,
const GladGLContext & gl )
staticprivate

Definition at line 108 of file opgl.cpp.

References cae::ShaderIRModule::entryPoint, and cae::ShaderIRModule::spirv.

◆ createMesh()

void cae::OPGL::createMesh ( const std::vector< float > & vertices)
overridevirtual

Create a mesh with the given vertex data.

Parameters
verticesVertex data to create the mesh

Implements cae::IRenderer.

Definition at line 83 of file opgl.cpp.

References cae::Mesh::vertexCount.

◆ createPipeline()

void cae::OPGL::createPipeline ( const ShaderID & id,
const ShaderIRModule & vertex,
const ShaderIRModule & fragment )
overridevirtual

Create a rendering pipeline with vertex and fragment shaders.

Parameters
idShader ID
vertexVertex shader IR module
fragmentFragment shader IR module

Implements cae::IRenderer.

Definition at line 56 of file opgl.cpp.

◆ draw()

void cae::OPGL::draw ( const WindowSize & windowSize,
const ShaderID & shaderId,
glm::mat4 mvp )
overridevirtual

Draw the scene using the specified shader and window size.

Parameters
windowSizeCurrent window size
shaderIdShader ID to use for drawing
mvpModel-View-Projection matrix

Implements cae::IRenderer.

Definition at line 38 of file opgl.cpp.

References cae::WindowSize::height, and cae::WindowSize::width.

◆ getName()

std::string cae::OPGL::getName ( ) const
inlinenodiscardoverridevirtual

Get the name of the plugin.

Returns
The name of the plugin

Implements utl::IPlugin.

Definition at line 43 of file OPGL.hpp.

◆ getPlatform()

utl::PluginPlatform cae::OPGL::getPlatform ( ) const
inlinenodiscardoverridevirtual

Get the handled platform of the plugin.

Returns
The handled platform of the plugin

Implements utl::IPlugin.

Definition at line 45 of file OPGL.hpp.

References utl::ALL.

◆ getType()

utl::PluginType cae::OPGL::getType ( ) const
inlinenodiscardoverridevirtual

Get the type of the plugin.

Returns
The type of the plugin

Implements utl::IPlugin.

Definition at line 44 of file OPGL.hpp.

References utl::RENDERER.

◆ initialize()

void cae::OPGL::initialize ( const NativeWindowHandle & nativeWindowHandle,
const Color & clearColor )
overridevirtual

Initialize the renderer with a native window handle and clear color.

Parameters
nativeWindowHandleNative window handle
clearColorClear color (default: white)

Implements cae::IRenderer.

Definition at line 15 of file opgl.cpp.

References cae::Color::a, cae::Color::b, cae::Color::g, m_context, m_ubo, and cae::Color::r.

◆ isVSyncEnabled()

bool cae::OPGL::isVSyncEnabled ( ) const
inlinenodiscardoverridevirtual

Check if VSync is enabled.

Returns
Whether VSync is enabled

Implements cae::IRenderer.

Definition at line 54 of file OPGL.hpp.

References m_context.

◆ operator=() [1/2]

OPGL & cae::OPGL::operator= ( const OPGL & )
delete

◆ operator=() [2/2]

OPGL & cae::OPGL::operator= ( OPGL && )
delete

◆ setClearColor()

void cae::OPGL::setClearColor ( const Color & color)
inlineoverridevirtual

Set the clear color.

Parameters
colorClear color to set

Implements cae::IRenderer.

Definition at line 48 of file OPGL.hpp.

References cae::Color::a, cae::Color::b, cae::Color::g, m_context, and cae::Color::r.

◆ setVSyncEnabled()

void cae::OPGL::setVSyncEnabled ( const bool enabled)
inlineoverridevirtual

Enable or disable VSync.

Parameters
enabledWhether VSync is enabled

Implements cae::IRenderer.

Definition at line 47 of file OPGL.hpp.

References m_context.

Member Data Documentation

◆ m_context

std::unique_ptr<IContext> cae::OPGL::m_context
private

Definition at line 63 of file OPGL.hpp.

Referenced by initialize(), isVSyncEnabled(), setClearColor(), and setVSyncEnabled().

◆ m_mesh

Mesh cae::OPGL::m_mesh
private

Definition at line 65 of file OPGL.hpp.

◆ m_programs

std::unordered_map<ShaderID, GLuint> cae::OPGL::m_programs
private

Definition at line 64 of file OPGL.hpp.

◆ m_ubo

GLuint cae::OPGL::m_ubo
private

Definition at line 67 of file OPGL.hpp.

Referenced by initialize().


The documentation for this class was generated from the following files: