rename engine to src
This commit is contained in:
91
src/shader.h
Normal file
91
src/shader.h
Normal file
@@ -0,0 +1,91 @@
|
||||
#pragma once
|
||||
#include "util.h"
|
||||
|
||||
namespace ui {
|
||||
|
||||
enum class kShaderUniform : uint16_t
|
||||
{
|
||||
MVP = const_hash("mvp"),
|
||||
Tex = const_hash("tex"),
|
||||
TexA = const_hash("tex_alpha"),
|
||||
TexFG = const_hash("tex_fg"),
|
||||
TexBG = const_hash("tex_bg"),
|
||||
TexMix = const_hash("tex_mix"),
|
||||
TexMixA = const_hash("tex_mix_alpha"),
|
||||
TexMask = const_hash("tex_mask"),
|
||||
TexStroke = const_hash("tex_stroke"),
|
||||
TexStencil = const_hash("tex_stencil"),
|
||||
StencilOffset = const_hash("stencil_offset"),
|
||||
StencilAlpha = const_hash("stencil_alpha"),
|
||||
MixAlpha = const_hash("mix_alpha"),
|
||||
Wet = const_hash("wet"),
|
||||
Lock = const_hash("lock"),
|
||||
Col = const_hash("col"),
|
||||
Tof = const_hash("tof"),
|
||||
Tsz = const_hash("tsz"),
|
||||
Alpha = const_hash("alpha"),
|
||||
Mask = const_hash("mask"),
|
||||
Resolution = const_hash("resolution"),
|
||||
Highlight = const_hash("highlight"),
|
||||
BlendMode = const_hash("blend_mode"),
|
||||
Noise = const_hash("noise"),
|
||||
Direction = const_hash("dir"),
|
||||
};
|
||||
|
||||
enum class kShader : uint16_t
|
||||
{
|
||||
Color = const_hash("color"),
|
||||
ColorQuad = const_hash("color-quad"),
|
||||
ColorTri = const_hash("color-tri"),
|
||||
ColorHue = const_hash("color-hue"),
|
||||
Texture = const_hash("texture"),
|
||||
TextureAlpha= const_hash("texture-alpha"),
|
||||
TextureAlphaSep= const_hash("texture-alpha-sep"),
|
||||
CompErase = const_hash("comp-erase"),
|
||||
CompDraw = const_hash("comp-draw"),
|
||||
UVs = const_hash("uvs"),
|
||||
UVs_2 = const_hash("uvs2"),
|
||||
Font = const_hash("font"),
|
||||
Atlas = const_hash("atlas"),
|
||||
Stroke = const_hash("stroke"),
|
||||
StrokePreview = const_hash("stroke-preview"),
|
||||
Checkerboard= const_hash("checkerboard"),
|
||||
Equirect = const_hash("equirect"),
|
||||
BrushStroke = const_hash("brush-stroke"),
|
||||
VertexColor = const_hash("vertex-color"),
|
||||
};
|
||||
|
||||
class Shader
|
||||
{
|
||||
std::map<kShaderUniform, GLuint> m_umap;
|
||||
GLuint prog;
|
||||
public:
|
||||
kShader name;
|
||||
bool create(const char* vertex, const char* fragment);
|
||||
void use();
|
||||
void u_vec4(kShaderUniform id, const glm::vec4& v);
|
||||
void u_vec2(kShaderUniform id, const glm::vec2& v);
|
||||
void u_mat4(kShaderUniform id, const glm::mat4& m);
|
||||
void u_int(kShaderUniform id, int i);
|
||||
void u_float(kShaderUniform id, float f);
|
||||
GLint GetAttribLocation(const char* name);
|
||||
};
|
||||
|
||||
class ShaderManager
|
||||
{
|
||||
static std::map<kShader, Shader> m_shaders;
|
||||
static Shader* m_current;
|
||||
public:
|
||||
static bool create(kShader id, const char* vertex, const char* fragment);
|
||||
static void use(kShader id);
|
||||
static void use(const char* name);
|
||||
static Shader* get(kShader id);
|
||||
static void u_vec4(kShaderUniform id, const glm::vec4& v);
|
||||
static void u_vec2(kShaderUniform id, const glm::vec2& v);
|
||||
static void u_mat4(kShaderUniform id, const glm::mat4& m);
|
||||
static void u_int(kShaderUniform id, int i);
|
||||
static void u_float(kShaderUniform id, float f);
|
||||
static void invalidate();
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user