45 lines
947 B
C++
45 lines
947 B
C++
#pragma once
|
|
|
|
#include "raylib.h"
|
|
#include <unordered_map>
|
|
#include <string>
|
|
|
|
struct MaterialData
|
|
{
|
|
unsigned int shaderId;
|
|
Color albedo;
|
|
|
|
MaterialData() : shaderId(0), albedo(WHITE) {}
|
|
};
|
|
|
|
class MaterialManager
|
|
{
|
|
public:
|
|
MaterialManager();
|
|
~MaterialManager();
|
|
|
|
// Create a material with a shader ID
|
|
// Returns a unique ID for the material
|
|
unsigned int Create(unsigned int shaderId, Color albedo = WHITE);
|
|
|
|
// Remove a material by ID
|
|
void Remove(unsigned int id);
|
|
|
|
// Get material data by ID (returns nullptr if not found)
|
|
MaterialData* Get(unsigned int id);
|
|
|
|
// Update material shader
|
|
void SetShader(unsigned int id, unsigned int shaderId);
|
|
|
|
// Update material albedo
|
|
void SetAlbedo(unsigned int id, Color albedo);
|
|
|
|
// Clear all materials
|
|
void Clear();
|
|
|
|
private:
|
|
std::unordered_map<unsigned int, MaterialData> materials;
|
|
unsigned int nextId;
|
|
bool cleared;
|
|
};
|