initial drawLine()
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "./pipeline/renderer_3d_pipeline.hpp"
|
#include "./pipeline/renderer_3d_pipeline.hpp"
|
||||||
#include "./renderer_3d_utility.hpp"
|
#include "./renderer_3d_utility.hpp"
|
||||||
|
#include "../core/renderer_core.hpp"
|
||||||
|
|
||||||
namespace Tyra {
|
namespace Tyra {
|
||||||
|
|
||||||
@@ -22,6 +23,8 @@ class Renderer3D {
|
|||||||
|
|
||||||
Renderer3DUtility utility;
|
Renderer3DUtility utility;
|
||||||
|
|
||||||
|
void init(RendererCore* core);
|
||||||
|
|
||||||
/** Deinitialize previous pipeline and initialize new pipeline */
|
/** Deinitialize previous pipeline and initialize new pipeline */
|
||||||
void usePipeline(Renderer3DPipeline* pipeline);
|
void usePipeline(Renderer3DPipeline* pipeline);
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "math/vec4.hpp"
|
#include "math/vec4.hpp"
|
||||||
#include "renderer/models/color.hpp"
|
#include "renderer/models/color.hpp"
|
||||||
#include "renderer/core/3d/bbox/core_bbox.hpp"
|
#include "renderer/core/3d/bbox/core_bbox.hpp"
|
||||||
|
#include "../core/renderer_core.hpp"
|
||||||
|
|
||||||
namespace Tyra {
|
namespace Tyra {
|
||||||
|
|
||||||
@@ -22,18 +23,22 @@ class Renderer3DUtility {
|
|||||||
Renderer3DUtility();
|
Renderer3DUtility();
|
||||||
~Renderer3DUtility();
|
~Renderer3DUtility();
|
||||||
|
|
||||||
|
void init(RendererCore* core);
|
||||||
|
|
||||||
void drawPoint(const Vec4& v);
|
void drawPoint(const Vec4& v);
|
||||||
void drawPoint(const Vec4& v, const float& size);
|
void drawPoint(const Vec4& v, const Color& color);
|
||||||
void drawPoint(const Vec4& v, const float& size, const Color& color);
|
|
||||||
|
|
||||||
void drawLine(const Vec4& from, const Vec4& to);
|
void drawLine(const Vec4& from, const Vec4& to);
|
||||||
void drawLine(const Vec4& from, const Vec4& to, const float& size);
|
void drawLine(const Vec4& from, const Vec4& to, const Color& color);
|
||||||
void drawLine(const Vec4& from, const Vec4& to, const float& size,
|
|
||||||
const Color& color);
|
|
||||||
|
|
||||||
void drawBBox(const CoreBBox& v);
|
void drawBBox(const CoreBBox& v);
|
||||||
void drawBBox(const CoreBBox& v, const float& size);
|
void drawBBox(const CoreBBox& v, const Color& color);
|
||||||
void drawBBox(const CoreBBox& v, const float& size, const Color& color);
|
|
||||||
|
private:
|
||||||
|
RendererCore* core;
|
||||||
|
|
||||||
|
prim_t basePrim;
|
||||||
|
color_t baseColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ Renderer3D::Renderer3D() { currentPipeline = nullptr; }
|
|||||||
|
|
||||||
Renderer3D::~Renderer3D() {}
|
Renderer3D::~Renderer3D() {}
|
||||||
|
|
||||||
|
void Renderer3D::init(RendererCore* core) { utility.init(core); }
|
||||||
|
|
||||||
void Renderer3D::usePipeline(Renderer3DPipeline* pipeline) {
|
void Renderer3D::usePipeline(Renderer3DPipeline* pipeline) {
|
||||||
if (currentPipeline != pipeline) {
|
if (currentPipeline != pipeline) {
|
||||||
if (currentPipeline) currentPipeline->onUseEnd();
|
if (currentPipeline) currentPipeline->onUseEnd();
|
||||||
|
|||||||
@@ -10,6 +10,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "renderer/3d/renderer_3d_utility.hpp"
|
#include "renderer/3d/renderer_3d_utility.hpp"
|
||||||
|
#include "debug/debug.hpp"
|
||||||
|
#include <math3d.h>
|
||||||
|
#include <draw.h>
|
||||||
|
#include <dma.h>
|
||||||
|
#include <packet2_utils.h>
|
||||||
|
#include <dma_tags.h>
|
||||||
|
|
||||||
namespace Tyra {
|
namespace Tyra {
|
||||||
|
|
||||||
@@ -17,37 +23,90 @@ Renderer3DUtility::Renderer3DUtility() {}
|
|||||||
|
|
||||||
Renderer3DUtility::~Renderer3DUtility() {}
|
Renderer3DUtility::~Renderer3DUtility() {}
|
||||||
|
|
||||||
void Renderer3DUtility::drawPoint(const Vec4& v) { drawPoint(v, 1.0F); }
|
void Renderer3DUtility::init(RendererCore* t_core) {
|
||||||
|
core = t_core;
|
||||||
|
|
||||||
|
basePrim.type = PRIM_LINE;
|
||||||
|
basePrim.shading = PRIM_SHADE_FLAT;
|
||||||
|
basePrim.mapping = DRAW_DISABLE;
|
||||||
|
basePrim.fogging = DRAW_DISABLE;
|
||||||
|
basePrim.blending = DRAW_DISABLE;
|
||||||
|
basePrim.antialiasing = DRAW_DISABLE;
|
||||||
|
basePrim.mapping_type = PRIM_MAP_ST;
|
||||||
|
basePrim.colorfix = PRIM_UNFIXED;
|
||||||
|
|
||||||
|
baseColor.r = 0x80;
|
||||||
|
baseColor.g = 0x80;
|
||||||
|
baseColor.b = 0x80;
|
||||||
|
baseColor.a = 0x80;
|
||||||
|
baseColor.q = 1.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer3DUtility::drawPoint(const Vec4& v) {
|
||||||
|
drawPoint(v, Color(128.0F, 0.0F, 0.0F, 128.0F));
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer3DUtility::drawLine(const Vec4& from, const Vec4& to) {
|
void Renderer3DUtility::drawLine(const Vec4& from, const Vec4& to) {
|
||||||
drawLine(from, to, 1.0F);
|
drawLine(from, to, Color(255.0F, 32.0F, 32.0F, 128.0F));
|
||||||
}
|
|
||||||
void Renderer3DUtility::drawBBox(const CoreBBox& v) { drawBBox(v, 1.0F); }
|
|
||||||
|
|
||||||
void Renderer3DUtility::drawPoint(const Vec4& v, const float& size) {
|
|
||||||
drawPoint(v, size, Color(128.0F, 0.0F, 0.0F, 128.0F));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer3DUtility::drawLine(const Vec4& from, const Vec4& to,
|
void Renderer3DUtility::drawBBox(const CoreBBox& v) {
|
||||||
const float& size) {
|
drawBBox(v, Color(255.0F, 32.0F, 32.0F, 128.0F));
|
||||||
drawLine(from, to, size, Color(128.0F, 0.0F, 0.0F, 128.0F));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer3DUtility::drawBBox(const CoreBBox& v, const float& size) {
|
void Renderer3DUtility::drawPoint(const Vec4& v, const Color& color) {
|
||||||
drawBBox(v, size, Color(128.0F, 0.0F, 0.0F, 128.0F));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Renderer3DUtility::drawPoint(const Vec4& v, const float& size,
|
|
||||||
const Color& color) {
|
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer3DUtility::drawLine(const Vec4& from, const Vec4& to,
|
void Renderer3DUtility::drawLine(const Vec4& from, const Vec4& to,
|
||||||
const float& size, const Color& color) {
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
void Renderer3DUtility::drawBBox(const CoreBBox& v, const float& size,
|
|
||||||
const Color& color) {
|
const Color& color) {
|
||||||
|
const u16 packetSize = 20;
|
||||||
|
auto* packet = packet2_create(20, P2_TYPE_NORMAL, P2_MODE_CHAIN, false);
|
||||||
|
|
||||||
|
auto mvp = core->renderer3D.getViewProj();
|
||||||
|
auto* inputVerts = new Vec4[2];
|
||||||
|
auto* inputColors = new color_f_t[2];
|
||||||
|
inputVerts[0] = mvp * from;
|
||||||
|
inputVerts[1] = mvp * to;
|
||||||
|
inputColors[0] = {color.r, color.g, color.b, color.a};
|
||||||
|
inputColors[1] = {color.r, color.g, color.b, color.a};
|
||||||
|
|
||||||
|
auto* outputVerts = new xyz_t[2];
|
||||||
|
auto* outputColors = new color_t[2];
|
||||||
|
draw_convert_xyz(outputVerts, 2048, 2048, static_cast<int>(0xFFFFFF / 32.0F),
|
||||||
|
2, reinterpret_cast<vertex_f_t*>(inputVerts));
|
||||||
|
draw_convert_rgbq(outputColors, 2, reinterpret_cast<vertex_f_t*>(inputVerts),
|
||||||
|
inputColors, 0x80);
|
||||||
|
|
||||||
|
packet2_chain_open_end(packet, 0, 0);
|
||||||
|
|
||||||
|
basePrim.type = PRIM_LINE;
|
||||||
|
|
||||||
|
packet2_update(packet,
|
||||||
|
draw_prim_start(packet->next, 0, &basePrim, &baseColor));
|
||||||
|
for (auto i = 0; i < 2; i++) {
|
||||||
|
packet2_add_u64(packet, outputColors[i].rgbaq);
|
||||||
|
packet2_add_u64(packet, outputVerts[i].xyz);
|
||||||
|
}
|
||||||
|
packet2_update(packet, draw_prim_end(packet->next, 2, DRAW_RGBAQ_REGLIST));
|
||||||
|
|
||||||
|
packet2_update(packet, draw_finish(packet->next));
|
||||||
|
|
||||||
|
packet2_chain_close_tag(packet);
|
||||||
|
|
||||||
|
TYRA_ASSERT(packet2_get_qw_count(packet) < packetSize);
|
||||||
|
|
||||||
|
dma_channel_wait(DMA_CHANNEL_GIF, 0);
|
||||||
|
dma_channel_send_packet2(packet, DMA_CHANNEL_GIF, true);
|
||||||
|
dma_channel_wait(DMA_CHANNEL_GIF, 0);
|
||||||
|
|
||||||
|
delete[] inputVerts;
|
||||||
|
delete[] inputColors;
|
||||||
|
delete[] outputVerts;
|
||||||
|
delete[] outputColors;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer3DUtility::drawBBox(const CoreBBox& v, const Color& color) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ Renderer::~Renderer() {}
|
|||||||
void Renderer::init() {
|
void Renderer::init() {
|
||||||
core.init();
|
core.init();
|
||||||
renderer2D.init(&core);
|
renderer2D.init(&core);
|
||||||
|
renderer3D.init(&core);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::beginFrame() { core.beginFrame(); }
|
void Renderer::beginFrame() { core.beginFrame(); }
|
||||||
|
|||||||
Reference in New Issue
Block a user