free ram and tyrobj wip
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <tamtypes.h>
|
||||
#include <stddef.h>
|
||||
#include "time/timer.hpp"
|
||||
|
||||
namespace Tyra {
|
||||
@@ -25,8 +26,13 @@ class Info {
|
||||
|
||||
const u32& getFps() const { return fps; };
|
||||
|
||||
/** @return Available RAM in MB */
|
||||
float getAvailableRAM();
|
||||
|
||||
private:
|
||||
float calcFps();
|
||||
void* allocateLargestFreeRAMBlock(size_t* size);
|
||||
size_t getFreeRAMSize();
|
||||
|
||||
u8 fpsDelayer;
|
||||
u32 fps;
|
||||
|
||||
@@ -20,12 +20,12 @@ class MD2Loader : public Loader {
|
||||
MD2Loader();
|
||||
~MD2Loader();
|
||||
|
||||
MeshBuilderData* load(const char* fullpath, const float& t_scale,
|
||||
const u8& t_invertT);
|
||||
MeshBuilderData* load(const char* fullpath, const float& scale,
|
||||
const bool& invertT);
|
||||
|
||||
inline MeshBuilderData* load(const std::string& fullpath,
|
||||
const float& t_scale, const u8& t_invertT) {
|
||||
return load(fullpath.c_str(), t_scale, t_invertT);
|
||||
inline MeshBuilderData* load(const std::string& fullpath, const float& scale,
|
||||
const bool& invertT) {
|
||||
return load(fullpath.c_str(), scale, invertT);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../loader.hpp"
|
||||
#include "../builder/mesh_builder_data.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
struct TyraobjData {
|
||||
u32 vertexCount, stsCount, normalsCount, colorsCount, materialsCount,
|
||||
framesCount;
|
||||
u32* materialsFaces;
|
||||
float scale;
|
||||
bool invertT;
|
||||
};
|
||||
|
||||
struct TyraobjReadInfo {
|
||||
u32 verticesI, coordsI, normalsI, colorsI, faceI;
|
||||
s16 materialsI;
|
||||
};
|
||||
|
||||
/** Class responsible for loading&parsing custom Tyra obj files */
|
||||
class TyrobjLoader : public Loader {
|
||||
public:
|
||||
TyrobjLoader();
|
||||
~TyrobjLoader();
|
||||
|
||||
/** Load multiple tyrobj files (dynamic) */
|
||||
MeshBuilderData* load(const char* fullpath, const u16& count,
|
||||
const float& scale, const bool& invertT);
|
||||
|
||||
inline MeshBuilderData* load(const std::string& fullpath, const u16& count,
|
||||
const float& scale, const bool& invertT) {
|
||||
return load(fullpath.c_str(), count, scale, invertT);
|
||||
}
|
||||
|
||||
private:
|
||||
TyraobjData scan(FILE* file, const u32& framesCount);
|
||||
void loadFile(FILE* file, const std::string& path, const u16& frameIndex,
|
||||
const TyraobjData& inputData, MeshBuilderData* outputData);
|
||||
|
||||
void initReadInfo(TyraobjReadInfo* info);
|
||||
void readVertices(TyraobjReadInfo* info, FILE* file, const u16& frameIndex,
|
||||
const TyraobjData& inputData, MeshBuilderData* outputData);
|
||||
void readTextureCoords(TyraobjReadInfo* info, FILE* file,
|
||||
const u16& frameIndex, const TyraobjData& inputData,
|
||||
MeshBuilderData* outputData);
|
||||
void readNormals(TyraobjReadInfo* info, FILE* file, const u16& frameIndex,
|
||||
const TyraobjData& inputData, MeshBuilderData* outputData);
|
||||
void readColors(TyraobjReadInfo* info, FILE* file, const u16& frameIndex,
|
||||
const TyraobjData& inputData, MeshBuilderData* outputData);
|
||||
void readMaterials(TyraobjReadInfo* info, FILE* file, const u16& frameIndex,
|
||||
const TyraobjData& inputData, MeshBuilderData* outputData);
|
||||
void readFaces(TyraobjReadInfo* info, FILE* file, const u16& frameIndex,
|
||||
const TyraobjData& inputData, MeshBuilderData* outputData);
|
||||
};
|
||||
|
||||
} // namespace Tyra
|
||||
@@ -18,6 +18,7 @@ class Loader {
|
||||
protected:
|
||||
std::string getFilenameFromPath(const std::string& path);
|
||||
std::string getFilenameWithoutExtension(const std::string& filename);
|
||||
std::string getExtensionOfFilename(const std::string& filename);
|
||||
};
|
||||
|
||||
} // namespace Tyra
|
||||
|
||||
@@ -20,10 +20,12 @@ class RendererSettings {
|
||||
RendererSettings()
|
||||
: width(640.0F),
|
||||
height(448.0F),
|
||||
interlacedHeightF(height / 2),
|
||||
near(0.1F),
|
||||
far(4096.0F),
|
||||
projectionScale(4096.0F),
|
||||
aspectRatio(width / height) {}
|
||||
aspectRatio(width / height),
|
||||
interlacedHeightUI(static_cast<unsigned int>(interlacedHeightF)) {}
|
||||
~RendererSettings();
|
||||
|
||||
const float& getWidth() const { return width; }
|
||||
@@ -32,10 +34,9 @@ class RendererSettings {
|
||||
const float& getFar() const { return far; }
|
||||
const float& getProjectionScale() const { return projectionScale; }
|
||||
const float& getAspectRatio() const { return aspectRatio; }
|
||||
|
||||
float getInterlacedHeightF() const { return getHeight() / 2; }
|
||||
unsigned int getInterlacedHeightUI() const {
|
||||
return static_cast<unsigned int>(getInterlacedHeightF());
|
||||
const float& getInterlacedHeightF() const { return interlacedHeightF; }
|
||||
const unsigned int& getInterlacedHeightUI() const {
|
||||
return interlacedHeightUI;
|
||||
}
|
||||
|
||||
static void copy(RendererSettings* out, const RendererSettings* in);
|
||||
@@ -45,7 +46,9 @@ class RendererSettings {
|
||||
std::string getPrint() const;
|
||||
|
||||
private:
|
||||
float width, height, near, far, projectionScale, aspectRatio;
|
||||
float width, height, interlacedHeightF, near, far, projectionScale,
|
||||
aspectRatio;
|
||||
unsigned int interlacedHeightUI;
|
||||
};
|
||||
|
||||
} // namespace Tyra
|
||||
|
||||
Reference in New Issue
Block a user