40 lines
915 B
C++
40 lines
915 B
C++
#pragma once
|
|
|
|
#include "raylib.h"
|
|
#include <unordered_map>
|
|
#include <string>
|
|
|
|
struct ShaderSource {
|
|
std::string vsPath;
|
|
std::string fsPath;
|
|
};
|
|
|
|
class ShaderManager
|
|
{
|
|
public:
|
|
ShaderManager();
|
|
~ShaderManager();
|
|
|
|
// Load a shader from vertex and fragment shader files
|
|
// Returns a unique ID for the shader, or 0 on failure
|
|
unsigned int Load(const std::string& vsPath, const std::string& fsPath);
|
|
|
|
// Unload a shader by ID
|
|
void Unload(unsigned int id);
|
|
|
|
// Get a shader by ID (returns nullptr if not found)
|
|
Shader* Get(unsigned int id);
|
|
|
|
// Get source metadata for a shader if available
|
|
const ShaderSource* GetSource(unsigned int id) const;
|
|
|
|
// Unload all shaders
|
|
void UnloadAll();
|
|
|
|
private:
|
|
std::unordered_map<unsigned int, Shader> shaders;
|
|
std::unordered_map<unsigned int, ShaderSource> shaderSources;
|
|
unsigned int nextId;
|
|
bool unloaded;
|
|
};
|