CSEngine
Loading...
Searching...
No Matches
ShaderUtil.h
1//
2// Created by ounols on 19. 4. 30.
3//
4
5#pragma once
6
7#include "../GLProgramHandle.h"
8#include "GLMeshID.h"
9
10namespace CSE {
11
21 class ShaderUtil {
22 public:
29
36
48 static GLProgramHandle* CreateProgramHandle(const GLchar* vertexSource, const GLchar* fragmentSource,
49 GLProgramHandle* handle = nullptr);
50
62 static GLuint
63 createProgram(const GLchar* vertexSource, const GLchar* fragmentSource, const GLProgramHandle& handle);
64
65 static GLuint createProgram(GLuint vertexShader, GLuint fragmentShader, const GLProgramHandle& handle);
66
78 static GLuint loadShader(GLenum shaderType, const char* pSource, const GLProgramHandle& handle);
79
89 static std::map<std::string, std::string> GetImportantVariables(const GLchar* source);
90
98 static void BindVariables(GLProgramHandle* handle);
99
111 static void BindCameraToShader(const GLProgramHandle& handle, const mat4& camera, const vec3& cameraPosition,
112 const mat4& projection, const mat4& transform);
113
122 static void BindAttributeToShader(const GLProgramHandle& handle, const GLMeshID& meshId);
123
133 static void BindSkinningDataToShader(const GLProgramHandle& handle, const GLMeshID& meshId,
134 const std::vector<mat4>& jointMatrix);
135
136 static void BindAttributeToPlane();
137
138 static void BindAttributeToCubeMap();
139
140 private:
146 static std::string m_defineVersion;
147 };
148
149}
This class provides utility functions for shaders.
Definition ShaderUtil.h:21
static void BindVariables(GLProgramHandle *handle)
Binds variables to the shader.
static GLProgramHandle * CreateProgramHandle(const GLchar *vertexSource, const GLchar *fragmentSource, GLProgramHandle *handle=nullptr)
Creates a program handle.
static void BindAttributeToShader(const GLProgramHandle &handle, const GLMeshID &meshId)
Binds the attributes to the shader.
ShaderUtil()
Constructor for the ShaderUtil class.
static std::map< std::string, std::string > GetImportantVariables(const GLchar *source)
Gets the important variables from the shader source code.
~ShaderUtil()
Destructor for the ShaderUtil class.
static GLuint loadShader(GLenum shaderType, const char *pSource, const GLProgramHandle &handle)
Loads a shader.
static GLuint createProgram(const GLchar *vertexSource, const GLchar *fragmentSource, const GLProgramHandle &handle)
Creates a program.
static void BindSkinningDataToShader(const GLProgramHandle &handle, const GLMeshID &meshId, const std::vector< mat4 > &jointMatrix)
Binds the skinning data to the shader.
static void BindCameraToShader(const GLProgramHandle &handle, const mat4 &camera, const vec3 &cameraPosition, const mat4 &projection, const mat4 &transform)
Binds the camera data to the shader.