refactor rendering
This commit is contained in:
23
include/td/render/shader/CameraShaderProgram.h
Normal file
23
include/td/render/shader/CameraShaderProgram.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <td/render/shader/ShaderProgram.h>
|
||||
|
||||
namespace td {
|
||||
namespace shader {
|
||||
|
||||
class CameraShaderProgram : public ShaderProgram {
|
||||
private:
|
||||
unsigned int m_LocationProjection = 0, m_LocationView = 0;
|
||||
|
||||
public:
|
||||
CameraShaderProgram() {}
|
||||
|
||||
void SetProjectionMatrix(const Mat4f& proj) const;
|
||||
void SetViewMatrix(const Mat4f& view) const;
|
||||
|
||||
virtual void GetAllUniformLocation();
|
||||
};
|
||||
|
||||
|
||||
} // namespace shader
|
||||
} // namespace td
|
||||
@@ -1,10 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <td/Maths.h>
|
||||
#include <td/render/OpenGL.h>
|
||||
#include <string>
|
||||
|
||||
namespace td {
|
||||
|
||||
namespace render {
|
||||
class Renderer;
|
||||
} // namespace render
|
||||
|
||||
namespace shader {
|
||||
|
||||
class ShaderProgram {
|
||||
@@ -15,10 +20,10 @@ class ShaderProgram {
|
||||
void Start() const;
|
||||
void Stop() const;
|
||||
|
||||
protected:
|
||||
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;
|
||||
|
||||
|
||||
@@ -1,20 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <td/render/shader/ShaderProgram.h>
|
||||
#include <td/render/shader/CameraShaderProgram.h>
|
||||
|
||||
namespace td {
|
||||
namespace shader {
|
||||
|
||||
class WorldShader : public ShaderProgram {
|
||||
private:
|
||||
unsigned int m_LocationProjection = 0, m_LocationView = 0;
|
||||
protected:
|
||||
void GetAllUniformLocation();
|
||||
class WorldShader : public CameraShaderProgram {
|
||||
public:
|
||||
WorldShader();
|
||||
|
||||
void SetProjectionMatrix(const Mat4f& proj) const;
|
||||
void SetViewMatrix(const Mat4f& view) const;
|
||||
};
|
||||
|
||||
} // namespace shader
|
||||
|
||||
Reference in New Issue
Block a user