mirror of
https://github.com/zoriya/Bomberman.git
synced 2025-12-21 13:55:10 +00:00
putting shaders changes on a new branch to avoid merge nightmare
This commit is contained in:
55
lib/Ray/sources/Shaders/Shaders.hpp
Normal file
55
lib/Ray/sources/Shaders/Shaders.hpp
Normal file
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// Created by cbihan on 04/06/2021.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <raylib.h>
|
||||
#include "Utils/Cache.hpp"
|
||||
|
||||
namespace RAY
|
||||
{
|
||||
class Shader
|
||||
{
|
||||
private:
|
||||
//! @brief The vertex file of the shader
|
||||
std::string _vertexFile;
|
||||
//! @brief The fragment file of the shader
|
||||
std::string _fragmentFile;
|
||||
|
||||
//! @brief Raylib shader struct
|
||||
std::shared_ptr<::Shader> _rayLibShader;
|
||||
|
||||
//! @brief Fetch and cache the index of the shader variable on the first set of the var
|
||||
std::map<std::string, int> _shaderIndexVars = {};
|
||||
|
||||
static Cache<::Shader> _shadersCache;
|
||||
public:
|
||||
//INTERNAL:
|
||||
const std::shared_ptr<::Shader> &getShaderPtr() const;
|
||||
|
||||
public:
|
||||
|
||||
//! @brief start using a custom shader when drawing
|
||||
static void BeginUsingCustomShader(RAY::Shader &shader);
|
||||
//! @brief stop using the custom shader
|
||||
static void EndUsingCustomShader();
|
||||
|
||||
//! @brief The set var for float values
|
||||
//! @note Throw if the var is not found
|
||||
void setShaderUniformVar(const std::string &varName, float value);
|
||||
|
||||
//! @brief ctor if no vertexfile in needed set it to nullptr
|
||||
Shader(const std::string &vertexFile, const std::string &fragmentFile);
|
||||
//! @brief Default copy ctor
|
||||
Shader(const Shader &) = default;
|
||||
//! @brief dtor
|
||||
~Shader() = default;
|
||||
//! @brief Assignment operator
|
||||
Shader &operator=(const Shader &) = default;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user