Files
2025-12-15 23:22:33 +08:00

58 lines
2.3 KiB
C++

/***********************************************************************************************************************
*
* Copyright (c) 2010 - 2025 by Tech Soft 3D, Inc.
* The information contained herein is confidential and proprietary to Tech Soft 3D, Inc., and considered a trade secret
* as defined under civil and criminal statutes. Tech Soft 3D shall pursue its civil and criminal remedies in the event
* of unauthorized use or misappropriation of its trade secrets. Use of this information by anyone other than authorized
* employees of Tech Soft 3D, Inc. is granted only under a written non-disclosure agreement, expressly prescribing the
* scope and manner of such use.
*
***********************************************************************************************************************/
#ifndef SHADER_H
#define SHADER_H
#include <string>
#include <vector>
#include <glad/glad.h>
#include <glm/mat4x4.hpp>
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
#include <glm/vec4.hpp>
#include "../../utils/properties.h"
class Shader
{
public:
GLuint ID;
int current_graphics_id = -1;
Shader(const char* vertexFile, const char* fragmentFile);
void use();
void detach();
void add_light_properties(const glm::vec3& light_position);
void update_view_matrix(const glm::mat4& mat) const;
void update_model_matrix(const glm::mat4& mat) const;
void update_world_matrix(const glm::mat4& mat) const;
void update_projection_matrix(const glm::mat4& mat) const;
void update_mesh_style(const utils::properties::style::Graphics& graphics, bool& is_first);
void set_vec3(const std::string& name, const glm::vec3& value) const;
private:
void update_mesh_color(const glm::vec4& rgba) const;
void update_mesh_material(const utils::properties::style::Material& material) const;
void compile_errors(unsigned int shader, const std::string & type);
void set_value(const std::string& name, float value) const;
void set_vec2(const std::string& name, const glm::vec2& value) const;
void set_vec2(const std::string& name, float x, float y) const;
void set_vec3(const std::string& name, float x, float y, float z) const;
void set_vec4(const std::string& name, const glm::vec4& value) const;
void set_vec4(const std::string& name, float x, float y, float z, float w) const;
void set_mat4(const std::string& name, const glm::mat4& mat) const;
};
#endif // SHADER_H