Класс шейдерной программы

This commit is contained in:
2022-11-14 20:17:34 +03:00
parent bce0048b52
commit 44d767bdfe
5 changed files with 194 additions and 116 deletions

30
include/Shader.h Normal file
View File

@@ -0,0 +1,30 @@
#ifndef SHADER_H
#define SHADER_H
#include <glad/glad.h>
#include <map>
#include <string>
// Класс шейдерной программы
class ShaderProgram
{
public:
ShaderProgram();
ShaderProgram(const ShaderProgram &copy);
~ShaderProgram();
ShaderProgram& operator=(const ShaderProgram& other);
void use(); // Использование шейдеров
void load(GLuint type, const char* filename); // Функция для загрузки шейдеров
void link(); // Формирование программы из загруженных шейдеров
GLuint getUniformLoc(const char* name); // Возвращает местоположение uniform-переменной
void bindUniformBlock(const char* name, int binding); // Привязка uniform-блока
void bindTextures(const char* textures_base_shader_names[], int count); // Инициализация текстур на шейдере
private:
GLuint program; // Дескриптор
static std::map<int, int> handler_count; // Получение количества использований по дескриптору шейдера (Shared pointer)
std::map<const char*, GLuint> uniformLocations; // Местоположения uniform-переменных
};
#endif // SHADER_H

View File

@@ -20,7 +20,6 @@ class Texture
Texture& operator=(const Texture& other); // Оператор присваивания
static void init_textures(GLuint programID); // Инициализация текстур на шейдере
void use(); // Привязка текстуры
static void disable(GLuint type); // Отвязка текстуры по типу
GLuint getType(); // Возвращает тип текстуры