finished tutorial 03

This commit is contained in:
h4570
2022-08-21 16:40:26 +02:00
parent 4303cc2c97
commit 409ee294eb
27 changed files with 349 additions and 25 deletions
@@ -43,7 +43,7 @@ class MinecraftPipeline : public Renderer3DPipeline {
* @param fullClipChecks false = faster, simple PS2 clipping. True = slower,
* experimental "against each plane" clipping.
*/
void render(std::vector<McpipBlock*> blocks, Texture* t_tex,
void render(std::vector<McpipBlock*> blocks, const Texture* t_tex,
const bool& isMulti = false, const bool& fullClipChecks = false);
inline const float& getTextureOffset() const {
+1
View File
@@ -27,6 +27,7 @@ class Renderer3D {
/** Deinitialize previous pipeline and initialize new pipeline */
void usePipeline(Renderer3DPipeline* pipeline);
void usePipeline(Renderer3DPipeline& pipeline);
private:
Renderer3DPipeline* currentPipeline;
@@ -16,11 +16,11 @@ namespace Tyra {
class CameraInfo3D {
public:
CameraInfo3D(Vec4* cameraPosition, Vec4* cameraLooksAt,
Vec4* cameraUp = nullptr);
CameraInfo3D(const Vec4* cameraPosition, const Vec4* cameraLooksAt,
const Vec4* cameraUp = nullptr);
~CameraInfo3D();
Vec4 *position, *looksAt, *up;
const Vec4 *position, *looksAt, *up;
private:
static Vec4 defaultCameraUp;
@@ -29,7 +29,7 @@ class Path3 {
void sendDrawFinishTag();
void clearScreen(zbuffer_t* z, const Color& color);
void sendTexture(Texture* texture,
void sendTexture(const Texture* texture,
const RendererCoreTextureBuffers& texBuffers);
private:
@@ -45,7 +45,7 @@ class Texture {
float getSizeInMB() const;
inline texwrap_t* getWrapSettings() { return &wrap; }
inline const texwrap_t* getWrapSettings() const { return &wrap; }
inline const std::vector<TextureLink>& getTextureLinks() const {
return links;
@@ -27,7 +27,7 @@ class RendererCoreTexture {
clutbuffer_t clut;
TextureRepository repository;
RendererCoreTextureBuffers useTexture(Texture* t_tex);
RendererCoreTextureBuffers useTexture(const Texture* t_tex);
/** Called by renderer during initialization */
void init(RendererCoreGS* gs, Path3* path3);
@@ -27,7 +27,7 @@ class RendererCoreTextureSender {
void init(Path3* path3, RendererCoreGS* gs);
RendererCoreTextureBuffers allocate(Texture* t_texture);
RendererCoreTextureBuffers allocate(const Texture* t_texture);
void deallocate(const RendererCoreTextureBuffers& texBuffers);
@@ -37,8 +37,8 @@ class RendererCoreTextureSender {
RendererCoreGS* gs;
Path3* path3;
TextureBpp getBppByPsm(const u32& psm);
texbuffer_t* allocateTextureCore(Texture* t_texture);
texbuffer_t* allocateTextureClut(Texture* t_texture);
texbuffer_t* allocateTextureCore(const Texture* t_texture);
texbuffer_t* allocateTextureClut(const Texture* t_texture);
};
} // namespace Tyra
@@ -83,8 +83,8 @@ void MinecraftPipeline::initBBox() {
bbox = new RenderBBox(block.vertices, block.count);
}
void MinecraftPipeline::render(std::vector<McpipBlock*> blocks, Texture* t_tex,
const bool& isMulti,
void MinecraftPipeline::render(std::vector<McpipBlock*> blocks,
const Texture* t_tex, const bool& isMulti,
const bool& fullClipChecks) {
auto texBuffers = rendererCore->texture.useTexture(t_tex);
+4
View File
@@ -19,6 +19,10 @@ Renderer3D::~Renderer3D() {}
void Renderer3D::init(RendererCore* core) { utility.init(core); }
void Renderer3D::usePipeline(Renderer3DPipeline& pipeline) {
usePipeline(&pipeline);
}
void Renderer3D::usePipeline(Renderer3DPipeline* pipeline) {
if (currentPipeline != pipeline) {
if (currentPipeline) currentPipeline->onUseEnd();
@@ -14,8 +14,9 @@ namespace Tyra {
Vec4 CameraInfo3D::defaultCameraUp = Vec4(0.0F, 1.0F, 0.0F);
CameraInfo3D::CameraInfo3D(Vec4* t_cameraPosition, Vec4* t_cameraLooksAt,
Vec4* t_cameraUp) {
CameraInfo3D::CameraInfo3D(const Vec4* t_cameraPosition,
const Vec4* t_cameraLooksAt,
const Vec4* t_cameraUp) {
position = t_cameraPosition;
looksAt = t_cameraLooksAt;
@@ -25,6 +26,7 @@ CameraInfo3D::CameraInfo3D(Vec4* t_cameraPosition, Vec4* t_cameraLooksAt,
up = t_cameraUp;
}
}
CameraInfo3D::~CameraInfo3D() {}
} // namespace Tyra
@@ -61,7 +61,7 @@ void Path3::clearScreen(zbuffer_t* z, const Color& color) {
dma_channel_send_packet2(clearScreenPacket, DMA_CHANNEL_GIF, true);
}
void Path3::sendTexture(Texture* texture,
void Path3::sendTexture(const Texture* texture,
const RendererCoreTextureBuffers& texBuffers) {
packet2_reset(texturePacket, false);
@@ -83,8 +83,9 @@ void Path3::sendTexture(Texture* texture,
packet2_chain_open_cnt(texturePacket, 0, 0, 0);
packet2_update(texturePacket,
draw_texture_wrapping(texturePacket->next, 0,
texture->getWrapSettings()));
draw_texture_wrapping(
texturePacket->next, 0,
const_cast<texwrap_t*>(texture->getWrapSettings())));
packet2_chain_close_tag(texturePacket);
packet2_update(texturePacket, draw_texture_flush(texturePacket->next));
@@ -35,7 +35,8 @@ void RendererCoreTexture::updateClutBuffer(texbuffer_t* clutBuffer) {
}
}
RendererCoreTextureBuffers RendererCoreTexture::useTexture(Texture* t_tex) {
RendererCoreTextureBuffers RendererCoreTexture::useTexture(
const Texture* t_tex) {
TYRA_ASSERT(t_tex != nullptr, "Provided nullptr texture!");
auto allocated = getAllocatedBuffersByTextureId(t_tex->id);
@@ -23,7 +23,7 @@ void RendererCoreTextureSender::init(Path3* t_path3, RendererCoreGS* t_gs) {
}
RendererCoreTextureBuffers RendererCoreTextureSender::allocate(
Texture* t_texture) {
const Texture* t_texture) {
texbuffer_t* core = allocateTextureCore(t_texture);
texbuffer_t* clut = nullptr;
@@ -54,7 +54,7 @@ void RendererCoreTextureSender::deallocate(
}
texbuffer_t* RendererCoreTextureSender::allocateTextureCore(
Texture* t_texture) {
const Texture* t_texture) {
auto* result = new texbuffer_t;
const auto* core = t_texture->core;
@@ -73,7 +73,7 @@ texbuffer_t* RendererCoreTextureSender::allocateTextureCore(
}
texbuffer_t* RendererCoreTextureSender::allocateTextureClut(
Texture* t_texture) {
const Texture* t_texture) {
auto* result = new texbuffer_t;
const auto* clut = t_texture->clut;