summaryrefslogtreecommitdiffstats
path: root/graphics/Shader.hpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-05-12 15:49:50 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-05-12 15:49:50 +0200
commite62817b8252974b8a98393275874ee303840bf13 (patch)
tree4565935f06e369f4a84410b0c098958e07a750c7 /graphics/Shader.hpp
parent2017-05-10 (diff)
downloadAltCraft-e62817b8252974b8a98393275874ee303840bf13.tar
AltCraft-e62817b8252974b8a98393275874ee303840bf13.tar.gz
AltCraft-e62817b8252974b8a98393275874ee303840bf13.tar.bz2
AltCraft-e62817b8252974b8a98393275874ee303840bf13.tar.lz
AltCraft-e62817b8252974b8a98393275874ee303840bf13.tar.xz
AltCraft-e62817b8252974b8a98393275874ee303840bf13.tar.zst
AltCraft-e62817b8252974b8a98393275874ee303840bf13.zip
Diffstat (limited to 'graphics/Shader.hpp')
-rw-r--r--graphics/Shader.hpp72
1 files changed, 17 insertions, 55 deletions
diff --git a/graphics/Shader.hpp b/graphics/Shader.hpp
index 83e06e1..8178d2a 100644
--- a/graphics/Shader.hpp
+++ b/graphics/Shader.hpp
@@ -1,60 +1,22 @@
-#pragma once
-
#include <string>
+#include <fstream>
+#include <sstream>
+#include <iostream>
-class Shader {
- std::string shaderSource;
- GLuint shaderId;
- bool isVertex = true;
-
- Shader(const Shader &);
-
-public:
- Shader(std::string fileName, bool vertex = true);
-
- ~Shader();
-
- void bind();
-
- GLuint GetId() {
- return shaderId;
- }
+#include <GL/glew.h>
-};
-
-class ShaderProgram {
- GLuint shaderProgram;
+class Shader
+{
+private:
+ const GLchar *vertex;
+ const GLchar *fragment;
public:
- ShaderProgram() {
- shaderProgram = glCreateProgram();
- }
-
- ~ShaderProgram() {
- glDeleteProgram(shaderProgram);
- }
-
- void Attach(Shader &shader) {
- glAttachShader(shaderProgram, shader.GetId());
- }
-
- void Link() {
- glLinkProgram(shaderProgram);
- GLint success;
- GLchar infoLog[512];
- glGetProgramiv(shaderProgram, GL_LINK_STATUS, &success);
- if (!success) {
- glGetProgramInfoLog(shaderProgram, 512, NULL, infoLog);
- std::cout << "Shader program linking failed: " << infoLog << std::endl;
- }
- glUseProgram(shaderProgram);
- }
-
- GLuint GetId() {
- return shaderProgram;
- }
-
- explicit operator GLuint() const {
- return shaderProgram;
- }
-
+ // Идентификатор программы
+ GLuint Program;
+ // Конструктор считывает и собирает шейдер
+ Shader(const GLchar* vertexPath, const GLchar* fragmentPath);
+ // Использование программы
+ void Use();
+
+ void Reload();
}; \ No newline at end of file