removed unnecessary factory pattern

This commit is contained in:
Lauchmelder 2021-12-23 04:55:19 +01:00
parent 711d18e718
commit 5875f1246f
9 changed files with 55 additions and 71 deletions

View file

@ -11,7 +11,7 @@ inline
namespace lol
{
AbstractShader::AbstractShader(const std::string& vertexShader, const std::string& fragmentShader) :
UniqueShader::UniqueShader(const std::string& vertexShader, const std::string& fragmentShader) :
id(0)
{
GLint success;
@ -71,17 +71,17 @@ namespace lol
glDeleteShader(vertexShaderID);
}
AbstractShader::~AbstractShader()
UniqueShader::~UniqueShader()
{
glDeleteProgram(id);
}
void AbstractShader::Use()
void UniqueShader::Use()
{
glUseProgram(id);
}
void AbstractShader::SetUniform(const std::string& name, const glm::mat4& value)
void UniqueShader::SetUniform(const std::string& name, const glm::mat4& value)
{
GLint location = glGetUniformLocation(id, name.c_str());
if (location == -1)
@ -90,7 +90,7 @@ namespace lol
glUniformMatrix4fv(location, 1, GL_FALSE, glm::value_ptr(value));
}
void AbstractShader::SetUniform(const std::string& name, const glm::vec4& value)
void UniqueShader::SetUniform(const std::string& name, const glm::vec4& value)
{
GLint location = glGetUniformLocation(id, name.c_str());
if (location == -1)

View file

@ -4,7 +4,8 @@
namespace lol
{
Texture2D::Texture2D()
UniqueTexture::UniqueTexture() :
textureID(0)
{
}

View file

@ -6,14 +6,14 @@
namespace lol
{
AbstractVertexArrayObject::~AbstractVertexArrayObject()
UniqueVertexArrayObject::~UniqueVertexArrayObject()
{
glDeleteBuffers(1, &ebo);
glDeleteBuffers(1, &vbo);
glDeleteVertexArrays(1, &vao);
}
void AbstractVertexArrayObject::Render(GLenum mode)
void UniqueVertexArrayObject::Render(GLenum mode)
{
assert(vao != 0);
@ -22,7 +22,7 @@ namespace lol
glDrawElements(mode, indexCount, GL_UNSIGNED_INT, 0);
}
AbstractVertexArrayObject::AbstractVertexArrayObject(const VertexArray& vertices, const IndexArray& indices, const Layout& layout, Usage usage) :
UniqueVertexArrayObject::UniqueVertexArrayObject(const VertexArray& vertices, const IndexArray& indices, const Layout& layout, Usage usage) :
vao(0), vbo(0), ebo(0), indexCount(indices.size())
{
glGenVertexArrays(1, &vao);