|
Monad Engine da02fba2
> Undercity Codex_
|
OpenGL 3.3 Core Profile abstraction layer. More...
#include <GraphicsAPI.h>
Public Member Functions | |
| bool | Init () |
| Set up initial OpenGL state (depth test, face culling, etc.). | |
| std::shared_ptr< ShaderProgram > | CreateShaderProgram (const std::string &vertexSource, const std::string &fragmentSource) |
| Compile vertex + fragment GLSL source and link into a program. | |
| const std::shared_ptr< ShaderProgram > & | GetDefaultShaderProgram () |
| Returns the built-in default shader (Blinn-Phong + diffuse texture). | |
| GLuint | CreateVertexBuffer (const std::vector< float > &vertices) |
| Upload a flat array of floats to a new GPU vertex buffer. | |
| GLuint | CreateIndexBuffer (const std::vector< uint32_t > &indices) |
| Upload a flat array of u32 indices to a new GPU index buffer. | |
| void | SetClearColor (float r, float g, float b, float a) |
| Set the colour that glClear() fills the framebuffer with. | |
| void | ClearBuffers () |
| Clear the colour and depth buffers ready for the next frame. | |
| void | BindShaderProgram (ShaderProgram *shaderProgram) |
| Bind a compiled shader program to the current GL state. | |
| void | BindMaterial (Material *material) |
| Upload all material parameters as uniforms to the active shader. | |
| void | BindMesh (Mesh *mesh) |
| Bind the mesh's VAO so the next draw call uses its geometry. | |
| void | UnbindMesh (Mesh *mesh) |
| void | DrawMesh (Mesh *mesh) |
| Issue a draw call for the bound mesh. | |
OpenGL 3.3 Core Profile abstraction layer.
Responsibilities:
Definition at line 40 of file GraphicsAPI.h.
| void mnd::GraphicsAPI::BindMaterial | ( | Material * | material | ) |
Upload all material parameters as uniforms to the active shader.
| material | Material whose float / texture params are applied. |
Definition at line 196 of file GraphicsAPI.cpp.
Referenced by mnd::RenderQueue::Draw().
| void mnd::GraphicsAPI::BindMesh | ( | Mesh * | mesh | ) |
Bind the mesh's VAO so the next draw call uses its geometry.
| mesh | Mesh whose VAO/VBO/EBO layout is activated. |
Definition at line 207 of file GraphicsAPI.cpp.
Referenced by mnd::RenderQueue::Draw(), and mnd::ParticleSystem::Render().
| void mnd::GraphicsAPI::BindShaderProgram | ( | ShaderProgram * | shaderProgram | ) |
Bind a compiled shader program to the current GL state.
| shaderProgram | The program to activate; must not be nullptr. |
Definition at line 185 of file GraphicsAPI.cpp.
| void mnd::GraphicsAPI::ClearBuffers | ( | ) |
Clear the colour and depth buffers ready for the next frame.
Definition at line 180 of file GraphicsAPI.cpp.
Referenced by mnd::Engine::Run().
| GLuint mnd::GraphicsAPI::CreateIndexBuffer | ( | const std::vector< uint32_t > & | indices | ) |
Upload a flat array of u32 indices to a new GPU index buffer.
| indices | Triangle list indices into the vertex buffer. |
Definition at line 164 of file GraphicsAPI.cpp.
| std::shared_ptr< ShaderProgram > mnd::GraphicsAPI::CreateShaderProgram | ( | const std::string & | vertexSource, |
| const std::string & | fragmentSource | ||
| ) |
Compile vertex + fragment GLSL source and link into a program.
| vertexSource | GLSL source string for the vertex stage. |
| fragmentSource | GLSL source string for the fragment stage. |
Definition at line 18 of file GraphicsAPI.cpp.
References kShaderInfoLogSize, LOG_ERROR, and LOG_INFO.
Referenced by GetDefaultShaderProgram(), mnd::ParticleSystem::Init(), and mnd::Material::Load().
| GLuint mnd::GraphicsAPI::CreateVertexBuffer | ( | const std::vector< float > & | vertices | ) |
Upload a flat array of floats to a new GPU vertex buffer.
| vertices | Interleaved vertex data (position, normal, UV, …). |
Definition at line 153 of file GraphicsAPI.cpp.
| void mnd::GraphicsAPI::DrawMesh | ( | Mesh * | mesh | ) |
Issue a draw call for the bound mesh.
Uses indexed drawing (glDrawElements) when the mesh has an EBO, otherwise falls back to glDrawArrays.
| mesh | The mesh to draw (must already be bound via BindMesh). |
Definition at line 229 of file GraphicsAPI.cpp.
Referenced by mnd::RenderQueue::Draw().
| const std::shared_ptr< ShaderProgram > & mnd::GraphicsAPI::GetDefaultShaderProgram | ( | ) |
Returns the built-in default shader (Blinn-Phong + diffuse texture).
Loaded once during Init(). Materials that do not specify their own shader fall back to this program.
Definition at line 72 of file GraphicsAPI.cpp.
References CreateShaderProgram().
| bool mnd::GraphicsAPI::Init | ( | ) |
Set up initial OpenGL state (depth test, face culling, etc.).
Definition at line 12 of file GraphicsAPI.cpp.
Referenced by mnd::OpenGLRendererBackend::Init().
| void mnd::GraphicsAPI::SetClearColor | ( | float | r, |
| float | g, | ||
| float | b, | ||
| float | a | ||
| ) |
Set the colour that glClear() fills the framebuffer with.
| r,g,b,a | Linear RGBA components in [0, 1]. |
Definition at line 175 of file GraphicsAPI.cpp.
Referenced by mnd::Engine::Run().
| void mnd::GraphicsAPI::UnbindMesh | ( | Mesh * | mesh | ) |
Definition at line 218 of file GraphicsAPI.cpp.
Referenced by mnd::RenderQueue::Draw().