assets-related refactor

This commit is contained in:
MihailRis 2024-04-10 17:44:17 +03:00
parent 216e38e411
commit befc9cf09c
14 changed files with 242 additions and 202 deletions

View file

@ -1,35 +1,46 @@
#ifndef GRAPHICS_CORE_SHADER_H_
#define GRAPHICS_CORE_SHADER_H_
#include <string>
#include <glm/glm.hpp>
#include "../../typedefs.h"
#include <string>
#include <unordered_map>
#include <glm/glm.hpp>
class GLSLExtension;
class Shader {
uint id;
std::unordered_map<std::string, uint> uniformLocations;
uint getUniformLocation(const std::string& name);
public:
static GLSLExtension* preprocessor;
Shader(unsigned int id);
Shader(uint id);
~Shader();
void use();
void uniformMatrix(std::string name, glm::mat4 matrix);
void uniform1i(std::string name, int x);
void uniform1f(std::string name, float x);
void uniform2f(std::string name, float x, float y);
void uniform2f(std::string name, glm::vec2 xy);
void uniform2i(std::string name, glm::ivec2 xy);
void uniform3f(std::string name, float x, float y, float z);
void uniform3f(std::string name, glm::vec3 xyz);
void uniformMatrix(const std::string&, glm::mat4 matrix);
void uniform1i(const std::string& name, int x);
void uniform1f(const std::string& name, float x);
void uniform2f(const std::string& name, float x, float y);
void uniform2f(const std::string& name, glm::vec2 xy);
void uniform2i(const std::string& name, glm::ivec2 xy);
void uniform3f(const std::string& name, float x, float y, float z);
void uniform3f(const std::string& name, glm::vec3 xyz);
/// @brief Create shader program using vertex and fragment shaders source.
/// @param vertexFile vertex shader file name
/// @param fragmentFile fragment shader file name
/// @param vertexSource vertex shader source code
/// @param fragmentSource fragment shader source code
/// @return linked shader program containing vertex and fragment shaders
static Shader* create(
std::string vertexFile,
std::string fragmentFile,
std::string vertexSource,
std::string fragmentSource
const std::string& vertexFile,
const std::string& fragmentFile,
const std::string& vertexSource,
const std::string& fragmentSource
);
};