Catos Engine (Source) 0.0.1
Lightweight Game engine
Loading...
Searching...
No Matches
shader.h
Go to the documentation of this file.
1//
2// Created by allos on 10/16/2024.
3//
4
5#ifndef CATOS_SHADER_H
6#define CATOS_SHADER_H
7
8
9namespace catos {
10
11 typedef unsigned int ShaderProgram;
12
14 enum class ShaderStatus: unsigned int {
15 SUCCESSFUL = 0,
16
19 };
20
22 enum ShaderType: unsigned int {
23 VERTEX = 0x8B31,
24 FRAGMENT = 0x8B30,
25 };
26
28 const char* vertexSRC = nullptr;
29 const char* fragmentSRC = nullptr;
30 };
31
32 /*
33 * A Shader is a object that holds a program that runs on the GPU.
34 */
35 class Shader {
36
37 public:
38 Shader();
39 ~Shader();
40
42 void init(const ShaderCreateInfo& createInfo);
43
45 ShaderStatus addSubShader(const char* src, ShaderType type);
46
48 const char* getCompilationErrorMessage();
49
51 ShaderProgram getShaderProgram() { return shaderProgram; };
52
54 void bind();
55
57 void setInt(const char* name, int val);
58
59 private:
60
61 ShaderProgram loadShader(const char* src, ShaderType type);
62
63 ShaderProgram shaderProgram;
64
65 };
66
67}
68
69
70
71#endif //CATOS_SHADER_H
Definition application.h:13
ShaderType
Shader Type (more to be added in the future such as geometry).
Definition shader.h:22
@ FRAGMENT
Definition shader.h:24
@ VERTEX
Definition shader.h:23
ShaderStatus
Statuses for shader operations.
Definition shader.h:14
unsigned int ShaderProgram
Definition shader.h:11
@ SUCCESSFUL
Definition renderer.h:20
Definition shader.h:27
const char * fragmentSRC
Definition shader.h:29
const char * vertexSRC
Definition shader.h:28
Definition shader.h:35
ShaderStatus addSubShader(const char *src, ShaderType type)
Adds a new subShader to the ShaderProgram.
Definition shader.cpp:33
Shader()
Definition shader.cpp:9
void setInt(const char *name, int val)
Sets a int uniform.
Definition shader.cpp:81
~Shader()
Definition shader.cpp:29
const char * getCompilationErrorMessage()
Returns the last compilation error.
Definition shader.cpp:50
void bind()
Binds the shader.
Definition shader.cpp:77
void init(const ShaderCreateInfo &createInfo)
Creates 2 shaders for the Vertex and Fragment Shader.
Definition shader.cpp:11
ShaderProgram getShaderProgram()
Returns the raw ShaderProgram object for GL uses.
Definition shader.h:51