1er commit
This commit is contained in:
18
include/render/shaders/EntityShader.h
Normal file
18
include/render/shaders/EntityShader.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "ShaderProgram.h"
|
||||
|
||||
class EntityShader : public ShaderProgram{
|
||||
private:
|
||||
unsigned int location_cam = 0, location_zoom = 0, location_aspect_ratio = 0, location_translation = 0, location_viewtype = 0;
|
||||
protected:
|
||||
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);
|
||||
};
|
||||
47
include/render/shaders/ShaderProgram.h
Executable file
47
include/render/shaders/ShaderProgram.h
Executable file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* ShaderProgram.h
|
||||
*
|
||||
* Created on: 31 janv. 2020
|
||||
* Author: simon
|
||||
*/
|
||||
|
||||
#ifndef RENDER_SHADERS_SHADERPROGRAM_H_
|
||||
#define RENDER_SHADERS_SHADERPROGRAM_H_
|
||||
|
||||
#include <string>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
namespace gl{
|
||||
enum class GLenum : unsigned int;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
protected:
|
||||
virtual void getAllUniformLocation() = 0;
|
||||
int getUniformLocation(const std::string& uniformName)const;
|
||||
void loadFloat(const int location, const float value)const;
|
||||
void loadInt(const int& location, const int& value)const;
|
||||
void loadVector(const int& location, const glm::vec2& vector)const;
|
||||
void loadVector(const int& location, const glm::vec3& vector)const;
|
||||
void loadVector(const int& location, const glm::vec4& vector)const;
|
||||
void loadBoolean(const int& location, const bool& value)const;
|
||||
void loadMatrix(const int& location, const glm::mat4& matrix);
|
||||
void cleanUp() const;
|
||||
|
||||
private:
|
||||
unsigned int programID;
|
||||
unsigned int vertexShaderID;
|
||||
unsigned int fragmentShaderID;
|
||||
int loadShaderFromFile(const std::string& file, gl::GLenum type);
|
||||
int loadShader(const std::string& source, gl::GLenum type);
|
||||
};
|
||||
|
||||
#endif /* RENDER_SHADERS_SHADERPROGRAM_H_ */
|
||||
27
include/render/shaders/WorldShader.h
Normal file
27
include/render/shaders/WorldShader.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* GameShader.h
|
||||
*
|
||||
* Created on: 4 nov. 2020
|
||||
* Author: simon
|
||||
*/
|
||||
|
||||
#ifndef RENDER_SHADERS_GAMESHADER_H_
|
||||
#define RENDER_SHADERS_GAMESHADER_H_
|
||||
|
||||
#include "ShaderProgram.h"
|
||||
|
||||
class WorldShader : public ShaderProgram{
|
||||
private:
|
||||
unsigned int location_cam = 0, location_zoom = 0, location_aspect_ratio = 0, location_viewtype = 0;
|
||||
protected:
|
||||
void getAllUniformLocation();
|
||||
public:
|
||||
WorldShader();
|
||||
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_ */
|
||||
Reference in New Issue
Block a user