Dawn/src/dawn/display/shader/Shader.hpp

65 lines
1.9 KiB
C++

// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "display/shader/ShaderProgram.hpp"
#include "display/mesh/Mesh.hpp"
#include "display/_RenderManager.hpp"
namespace Dawn {
class Material;
class MeshRenderer;
class Camera;
struct ShaderPassItem {
ShaderProgram *shaderProgram = nullptr;
int32_t priority = 0;
Mesh *mesh;
int32_t start = 0;
int32_t count = -1;
float_t w = 0;
renderflag_t renderFlags = RENDER_MANAGER_RENDER_FLAG_DEPTH_TEST;
enum MeshDrawMode drawMode = MESH_DRAW_MODE_TRIANGLES;
// Parameters
std::map<shaderparameter_t, struct Color> colorValues;
std::map<shaderparameter_t, bool_t> boolValues;
std::map<shaderparameter_t, glm::mat4> matrixValues;
std::map<shaderparameter_t, glm::vec3> vec3Values;
std::map<shaderparameter_t, textureslot_t> textureValues;
std::map<shaderparameter_t, float_t> floatValues;
// Textures
std::map<textureslot_t, Texture*> textureSlots;
};
class Shader {
public:
int32_t shaderId = -1;
int_fast16_t renderId = 0;
/**
* Compile all programs for this shader. This amy not remain forever as I
* may decide to allow shaders to share programs somehow. For now though
* this is clean enough.
*/
virtual void compile() = 0;
/**
* Returns the list of pass items to render for the given scene item.
*
* @param mesh Mesh Renderer for the scene item.
* @param material Material for the scene item.
* @param camera Camera for the scene.
* @return List of passes to render.
*/
virtual std::vector<struct ShaderPassItem> getPassItems(
Mesh *mesh,
Material *material,
Camera *camera
) = 0;
};
}