16#include "aeongames/Material.hpp"
17#include "aeongames/Texture.hpp"
18#include "aeongames/Mesh.hpp"
20#include "OpenGLFunctions.hpp"
21#include "OpenGLMaterial.hpp"
22#include "OpenGLRenderer.hpp"
23#include "OpenGLPipeline.hpp"
28 mOpenGLRenderer{aOpenGLRenderer},
29 mMaterial{&aMaterial},
41 mOpenGLRenderer.LoadTexture ( *texture );
45 OpenGLMaterial::~OpenGLMaterial ( )
60 mOpenGLRenderer{aOpenGLMaterial.mOpenGLRenderer},
61 mMaterial{aOpenGLMaterial.mMaterial},
62 mUniformBuffer{
std::move ( aOpenGLMaterial.mUniformBuffer ) }
68 const auto& samplers = mMaterial->GetSamplers();
69 for ( GLenum i = 0; i < samplers.size(); ++i )
74 mOpenGLRenderer.GetTextureId ( *std::get<1> ( samplers[i] ).Cast<
Texture>() ) );
75 OPENGL_CHECK_ERROR_THROW;
80 if ( mMaterial->GetUniformBuffer().size() )
83 if ( uniform_block !=
nullptr )
85 glBindBufferBase ( GL_UNIFORM_BUFFER, uniform_block->
binding, mUniformBuffer.GetBufferId() );
86 OPENGL_CHECK_ERROR_THROW;
Represents a surface material with uniform properties and texture samplers.
DLL const std::vector< uint8_t > & GetUniformBuffer() const
Get the raw uniform buffer.
DLL const std::vector< std::tuple< uint32_t, ResourceId > > & GetSamplers() const
Get all sampler bindings.
@ MATERIAL
Material binding.
void Finalize()
Release the buffer resources.
OpenGLMaterial(OpenGLRenderer &aOpenGLRenderer, const Material &aMaterial)
Construct from a renderer and material resource.
void Bind(const OpenGLPipeline &aPipeline) const
Binds the material to the specified pipeline.
OpenGL shader program pipeline with attribute and uniform reflection.
const OpenGLUniformBlock * GetUniformBlock(uint32_t name) const
Get a uniform block by its name hash, or nullptr if not found.
const GLuint GetSamplerLocation(uint32_t name_hash) const
Get the uniform location of a sampler by its name hash.
OpenGL rendering backend implementing the Renderer interface.
void UnloadTexture(const Texture &aTexture) final
Unloads a texture from GPU memory.
Represents a 2D texture image resource.
<- This is here just for the literals