GIGA REFACTOR

This commit is contained in:
2022-03-02 18:51:42 +01:00
parent 553b2f6aad
commit 6df59b1487
92 changed files with 1807 additions and 1785 deletions

View File

@@ -2,17 +2,29 @@
#include "ShaderProgram.h"
namespace td {
namespace shader {
class EntityShader : public ShaderProgram {
private:
unsigned int location_cam = 0, location_zoom = 0, location_aspect_ratio = 0, location_translation = 0, location_viewtype = 0;
unsigned int m_LocationCam = 0;
unsigned int m_LocationZoom = 0;
unsigned int m_LocationAspectRatio = 0;
unsigned int m_LocationTranslation = 0;
unsigned int m_LocationViewtype = 0;
protected:
void getAllUniformLocation();
virtual void GetAllUniformLocation();
public:
EntityShader();
void loadShader();
void setCamPos(const glm::vec2& camPos);
void setZoom(float zoom);
void setAspectRatio(float aspectRatio);
void setModelPos(const glm::vec2& modelPos);
void setIsometricView(float isometric);
void LoadShader();
void SetCamPos(const glm::vec2& camPos);
void SetZoom(float zoom);
void SetAspectRatio(float aspectRatio);
void SetModelPos(const glm::vec2& modelPos);
void SetIsometricView(float isometric);
};
} // namespace shader
} // namespace td

View File

@@ -1,46 +1,44 @@
/*
* ShaderProgram.h
*
* Created on: 31 janv. 2020
* Author: simon
*/
#ifndef RENDER_SHADERS_SHADERPROGRAM_H_
#define RENDER_SHADERS_SHADERPROGRAM_H_
#pragma once
#include <string>
#include <glm/glm.hpp>
#include "render/GL.h"
namespace td {
namespace shader {
class ShaderProgram {
public:
ShaderProgram();
virtual ~ShaderProgram();
void start() const;
void stop() const;
void loadProgramFile(const std::string& vertexFile, const std::string& fragmentFile);
void loadProgram(const std::string& vertexSource, const std::string& fragmentSource);
void Start() const;
void Stop() const;
void LoadProgramFile(const std::string& vertexFile, const std::string& fragmentFile);
void LoadProgram(const std::string& vertexSource, const std::string& fragmentSource);
protected:
virtual void getAllUniformLocation() = 0;
int getUniformLocation(const std::string& uniformName) const;
virtual void GetAllUniformLocation() = 0;
int GetUniformLocation(const std::string& uniformName) const;
void loadFloat(unsigned int location, float value) const;
void loadInt(unsigned int location, int value) const;
void loadVector(unsigned int location, const glm::vec2& vector) const;
void loadVector(unsigned int location, const glm::vec3& vector) const;
void loadVector(unsigned int location, const glm::vec4& vector) const;
void loadBoolean(unsigned int location, bool value) const;
void loadMatrix(unsigned int location, const glm::mat4& matrix) const;
void cleanUp() const;
void LoadFloat(unsigned int location, float value) const;
void LoadInt(unsigned int location, int value) const;
void LoadVector(unsigned int location, const glm::vec2& vector) const;
void LoadVector(unsigned int location, const glm::vec3& vector) const;
void LoadVector(unsigned int location, const glm::vec4& vector) const;
void LoadBoolean(unsigned int location, bool value) const;
void LoadMatrix(unsigned int location, const glm::mat4& matrix) const;
void CleanUp() const;
private:
unsigned int m_ProgramID;
unsigned int m_VertexShaderID;
unsigned int m_FragmentShaderID;
unsigned int loadShaderFromFile(const std::string& file, GLenum type);
unsigned int loadShader(const std::string& source, GLenum type);
unsigned int LoadShaderFromFile(const std::string& file, GLenum type);
unsigned int LoadShader(const std::string& source, GLenum type);
};
#endif /* RENDER_SHADERS_SHADERPROGRAM_H_ */
} // namespace shader
} // namespace td

View File

@@ -1,27 +1,23 @@
/*
* GameShader.h
*
* Created on: 4 nov. 2020
* Author: simon
*/
#ifndef RENDER_SHADERS_GAMESHADER_H_
#define RENDER_SHADERS_GAMESHADER_H_
#pragma once
#include "ShaderProgram.h"
namespace td {
namespace shader {
class WorldShader : public ShaderProgram {
private:
unsigned int location_cam = 0, location_zoom = 0, location_aspect_ratio = 0, location_viewtype = 0;
unsigned int m_LocationCam = 0, m_LocationZoom = 0, m_LocationAspectRatio = 0, m_LocationViewtype = 0;
protected:
void getAllUniformLocation();
void GetAllUniformLocation();
public:
WorldShader();
void loadShader();
void setCamPos(const glm::vec2& camPos);
void setZoom(float zoom);
void setAspectRatio(float aspectRatio);
void setIsometricView(float isometric);
void LoadShader();
void SetCamPos(const glm::vec2& camPos);
void SetZoom(float zoom);
void SetAspectRatio(float aspectRatio);
void SetIsometricView(float isometric);
};
#endif /* RENDER_SHADERS_GAMESHADER_H_ */
} // namespace shader
} // namespace td