2019-08-12 06:33:40 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include "RenderDevice.h"
|
|
|
|
|
2019-08-16 11:07:57 +00:00
|
|
|
enum class DeclarationUsage : int32_t { Position, Color, TextureCoordinate, Normal };
|
|
|
|
|
2019-08-12 06:33:40 +00:00
|
|
|
class Shader
|
|
|
|
{
|
|
|
|
public:
|
2019-08-14 05:55:21 +00:00
|
|
|
void ReleaseResources();
|
2019-08-12 06:33:40 +00:00
|
|
|
|
2019-12-15 21:53:33 +00:00
|
|
|
void Setup(const std::string& identifier, const std::string& vertexShader, const std::string& fragmentShader, bool alphatest);
|
2019-12-18 03:22:47 +00:00
|
|
|
bool CheckCompile(RenderDevice *device);
|
2019-08-22 13:46:24 +00:00
|
|
|
void Bind();
|
2019-08-12 06:33:40 +00:00
|
|
|
|
2019-12-15 21:53:33 +00:00
|
|
|
std::string GetIdentifier();
|
|
|
|
std::string GetCompileError();
|
|
|
|
|
2019-12-18 03:22:47 +00:00
|
|
|
int UniformLastUpdates[(int)UniformName::NumUniforms] = { 0 };
|
2019-08-14 10:36:33 +00:00
|
|
|
GLuint UniformLocations[(int)UniformName::NumUniforms] = { 0 };
|
2019-08-12 06:33:40 +00:00
|
|
|
|
|
|
|
private:
|
2019-12-18 03:22:47 +00:00
|
|
|
void CreateProgram(RenderDevice* device);
|
2019-08-12 06:33:40 +00:00
|
|
|
GLuint CompileShader(const std::string& code, GLenum type);
|
|
|
|
|
2019-12-15 21:53:33 +00:00
|
|
|
std::string mIdentifier;
|
2019-08-22 13:46:24 +00:00
|
|
|
std::string mVertexText;
|
|
|
|
std::string mFragmentText;
|
|
|
|
bool mAlphatest = false;
|
|
|
|
bool mProgramBuilt = false;
|
|
|
|
|
2019-08-12 06:33:40 +00:00
|
|
|
GLuint mProgram = 0;
|
|
|
|
GLuint mVertexShader = 0;
|
|
|
|
GLuint mFragmentShader = 0;
|
|
|
|
std::string mErrors;
|
2019-09-29 16:57:51 +00:00
|
|
|
};
|