-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathYRShader.h
More file actions
46 lines (34 loc) · 1.16 KB
/
Copy pathYRShader.h
File metadata and controls
46 lines (34 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once
#include <glad/glad.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
class YRShader
{
public:
/*
shaderProgram id
*/
unsigned int id;
/*
read file from file paths and create vertex shader and fragment shader, then
link them and generate shader program.
*/
YRShader(std::string& vertexShaderFilePath, std::string& fragmentShaderFilePath);
void use();
void setBool(const std::string& name, bool value) const;
void setInt(const std::string& name, int value) const;
void setFloat(const std::string& name, float value) const;
void setMat4(const std::string& name, glm::mat4& value) const;
void setVec3(const std::string& name, glm::vec3& value) const;
/*
create a vertex shader from vertex shader source.
*/
unsigned int createVertexShader(const char* vertexShaderSource);
unsigned int createFragmentShader(const char* fragmentShaderSource);
unsigned int creatLinkShadersProgram(unsigned int& vertexShader, unsigned int& fragmentShader);
};