UltimateZoneBuilder/Source/Native/Shader.h

40 lines
921 B
C
Raw Normal View History

#pragma once
#include <string>
#include "RenderDevice.h"
enum class DeclarationUsage : int32_t { Position, Color, TextureCoordinate, Normal };
class Shader
{
public:
Shader() = default;
void ReleaseResources();
2019-12-15 21:53:33 +00:00
void Setup(const std::string& identifier, const std::string& vertexShader, const std::string& fragmentShader, bool alphatest);
bool CheckCompile();
2019-08-22 13:46:24 +00:00
void Bind();
2019-12-15 21:53:33 +00:00
std::string GetIdentifier();
std::string GetCompileError();
2019-08-14 10:36:33 +00:00
GLuint UniformLocations[(int)UniformName::NumUniforms] = { 0 };
private:
2019-08-22 13:46:24 +00:00
void CreateProgram();
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;
GLuint mProgram = 0;
GLuint mVertexShader = 0;
GLuint mFragmentShader = 0;
std::string mErrors;
Shader(const Shader&) = delete;
Shader& operator=(const Shader&) = delete;
};