moving textures to textures repo #1

This commit is contained in:
Sandro Sobczyński
2020-10-31 10:53:20 +01:00
parent ebf2a9ac24
commit 3cfe7ba8f1
11 changed files with 127 additions and 76 deletions
+1 -1
View File
@@ -54,7 +54,7 @@ public:
u8 isMd2Loaded, isObjLoaded, isDffLoaded, isSpecInitialized;
clutbuffer_t clut;
lod_t lod;
MeshTexture **textures;
MeshTexture *textures;
private:
void setupLodAndClut();
+17 -20
View File
@@ -14,12 +14,12 @@
#include <tamtypes.h>
#include <draw_sampling.h>
#include "./texture_wrap_settings.hpp"
#include "./texture_link.hpp"
/**
* Class which contains texture data
* Textures are paired with material via material id.
* Additionaly, you can load two textures for single material
* and switch materialId here to change texture.
* Class which contains texture data.
* Textures are paired with meshes via addUsage(),
* removeUsage() functions which use meshId and materialId.
*/
class MeshTexture
{
@@ -40,17 +40,12 @@ public:
*/
const u32 &getId() const { return id; };
/**
* Core role of this variable is to assign texture to correct material.
* For example you can have two textures for single material.
* Example: Same player can have two textures (team A, team B)
*/
const u32 &getMaterialId() const { return materialId; };
const u8 &getWidth() const { return width; };
const u8 &getHeight() const { return height; };
const u32 &getTextureLinksCount() const { return texLinkCount; };
texwrap_t *getWrapSettings() { return &wrapSettings; };
/**
@@ -71,17 +66,13 @@ public:
*/
char *getName() const { return name; };
/** Array of texture links. Size of getTextureLinksCount() */
TextureLink *getTextureLinks() const { return texLinks; };
// ----
// Setters
// ----
/**
* Core role of this variable is to assign texture to correct material.
* For example you can have two textures for single material.
* Example: Same player can have two textures (team A, team B)
*/
void setMaterialId(const u32 &t_val) { materialId = t_val; }
/**
* Set texture size and allocate texture data
* Do not call this method unless you know what you do.
@@ -114,16 +105,22 @@ public:
// Other
// ----
/** Assign texture to mesh and mesh material */
void addLink(u32 t_meshId, u32 t_materialId);
/** Remove mesh and mesh material assignment */
void removeLink(u32 t_meshId, u32 t_materialId);
const u8 &isNameSet() const { return _isNameSet; };
const u8 &isSizeSet() const { return _isSizeSet; };
private:
void setDefaultWrapSettings();
texwrap_t wrapSettings;
char *name;
u32 id, materialId;
TextureLink *texLinks;
u32 id, texLinkCount;
u8 width, height, _isNameSet, _isSizeSet;
unsigned char *data;
};
@@ -0,0 +1,21 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2020, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#ifndef _TYRA_TEXTURE_USAGE_
#define _TYRA_TEXTURE_USAGE_
#include <tamtypes.h>
struct TextureLink
{
u32 meshId, materialId;
};
#endif
+9 -4
View File
@@ -19,6 +19,7 @@
#include "../models/math/plane.hpp"
#include "../models/screen_settings.hpp"
#include "../models/render_data.hpp"
#include "./texture_repository.hpp"
/** Class responsible for intializing draw env, textures and buffers */
class Renderer
@@ -55,17 +56,21 @@ public:
void endFrame(float fps);
TextureRepository *getTextureRepository() { return &textureRepo; };
private:
void changeTexture(Mesh *t_mesh, u8 t_textureIndex);
u32 lastTextureId;
texbuffer_t textureBuffer;
u8 isTextureVRAMAllocated;
void allocateTextureBuffer(u16 t_width, u16 t_height);
void deallocateTextureBuffer();
void changeTexture(Mesh *t_mesh, u8 t_textureIndex);
void flipBuffers();
void beginFrameIfNeeded();
u8 isFrameEmpty, isTextureVRAMAllocated;
u8 isFrameEmpty;
Matrix perspective;
RenderData renderData;
texbuffer_t textureBuffer;
u32 lastTextureId;
TextureRepository textureRepo;
GifSender *gifSender;
VifSender *vifSender;
packet_t *flipPacket;
@@ -24,10 +24,6 @@ public:
~TextureRepository();
private:
void allocateTextureBuffer(u16 t_width, u16 t_height);
void deallocateTextureBuffer();
void changeTexture(Mesh *t_mesh, u8 t_textureIndex);
texbuffer_t textureBuffer;
};
#endif