39 lines
1.1 KiB
C++
39 lines
1.1 KiB
C++
//
|
|
// Created by sebastian on 09.02.26.
|
|
//
|
|
|
|
#include "GUIRenderer.h"
|
|
|
|
#include <vector>
|
|
|
|
#include "../toolbox/MathUtils.h"
|
|
#include "loader/Loader.h"
|
|
|
|
GUIRenderer::GUIRenderer(Loader &loader) {
|
|
std::vector<float> positions = {-1, 1, -1,-1,1,1,1,-1};
|
|
auto model = loader.loadToVAO(positions);
|
|
rawModel = std::make_unique<RawModel>(model);
|
|
}
|
|
|
|
void GUIRenderer::render(const std::vector<GUITexture>& guiTextures) {
|
|
guiShader.start();
|
|
glBindVertexArray(rawModel->vaoID);
|
|
glEnableVertexAttribArray(0);
|
|
for (GUITexture texture : guiTextures) {
|
|
glActiveTexture(GL_TEXTURE0);
|
|
glBindTexture(GL_TEXTURE_2D, texture.getTextureID());
|
|
glm::mat4 transformationMatrix = MathUtils::createTransformationMatrix(texture.getPosition(), texture.getScale());
|
|
guiShader.loadTransformationMatrix(transformationMatrix);
|
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, rawModel->vertexCount);
|
|
}
|
|
//render
|
|
glDisableVertexAttribArray(0);
|
|
glBindVertexArray(0);
|
|
guiShader.stop();
|
|
}
|
|
|
|
void GUIRenderer::cleanUp() {
|
|
guiShader.cleanUp();
|
|
}
|
|
|