Added basic debug lines

This commit is contained in:
2023-02-22 13:41:52 -08:00
parent c065ab08b3
commit 389a290362
15 changed files with 357 additions and 139 deletions

View File

@ -6,6 +6,10 @@
#include "RenderPipeline.hpp"
#include "game/DawnGame.hpp"
#if DAWN_DEBUG_BUILD
#include "scene/debug/SceneDebugLine.hpp"
#endif
using namespace Dawn;
RenderPipeline::RenderPipeline(RenderManager *renderManager) {
@ -159,6 +163,27 @@ void RenderPipeline::renderSceneCamera(Scene *scene, Camera *camera) {
++itCanvas;
}
// Debug Lines
#if DAWN_DEBUG_BUILD
Mesh lineMesh;
int32_t lineIndex = 0;
lineMesh.createBuffers(
scene->debugLines.size() * SCENE_DEBUG_LINE_VERTICE_COUNT,
scene->debugLines.size() * SCENE_DEBUG_LINE_INDICE_COUNT
);
auto itDebugLine = scene->debugLines.begin();
while(itDebugLine != scene->debugLines.end()) {
auto item = itDebugLine->createShaderItem(
&lineMesh,
&lineIndex,
camera,
&this->renderManager->simpleShader
);
shaderPassItems.push_back(item);
++itDebugLine;
}
#endif
// Now we've queued everything, let's sort the rendering queue by the priority
std::sort(
shaderPassItems.begin(),
@ -246,11 +271,7 @@ void RenderPipeline::renderSceneCamera(Scene *scene, Camera *camera) {
this->renderManager->setRenderFlags(item.renderFlags);
// Thank god that's done, now just draw the damn mesh.
item.mesh->draw(
MESH_DRAW_MODE_TRIANGLES,
item.start,
item.count
);
item.mesh->draw(item.drawMode, item.start, item.count);
++itPassItem;
}
}

View File

@ -11,6 +11,7 @@
#include "scene/components/scene/SubSceneController.hpp"
#include "ui/UIComponent.hpp"
namespace Dawn {
class RenderManager;

View File

@ -1,62 +1,64 @@
// 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 "scene/components/display/MeshRenderer.hpp"
#include "scene/components/display/Camera.hpp"
#include "display/_RenderManager.hpp"
namespace Dawn {
class Material;
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;
// 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:
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;
};
// 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:
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;
};
}