SP3-237
Renamed MeshWriter to MeshCompiler Implemented texture compiler
This commit is contained in:
parent
5d022b7123
commit
201b19e8a6
|
@ -1,9 +1,9 @@
|
|||
#include "SHpch.h"
|
||||
#include "SHMeshWriter.h"
|
||||
#include "SHMeshCompiler.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
void SHADE::SHMeshWriter::WriteMeshBinary(SHMeshAsset const& asset, AssetPath path) noexcept
|
||||
void SHADE::SHMeshCompiler::CompileMeshBinary(SHMeshAsset const& asset, AssetPath path) noexcept
|
||||
{
|
||||
std::ofstream file{path, std::ios::out | std::ios::binary};
|
||||
if (!file.is_open())
|
|
@ -5,10 +5,10 @@
|
|||
|
||||
namespace SHADE
|
||||
{
|
||||
class SHMeshWriter
|
||||
class SHMeshCompiler
|
||||
{
|
||||
private:
|
||||
public:
|
||||
static void WriteMeshBinary(SHMeshAsset const& asset, AssetPath path) noexcept;
|
||||
static void CompileMeshBinary(SHMeshAsset const& asset, AssetPath path) noexcept;
|
||||
};
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
#include "SHpch.h"
|
||||
#include "SHTextureCompiler.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
void SHTextureCompiler::CompileTextureBinary(SHTextureAsset const& asset, AssetPath path)
|
||||
{
|
||||
std::ofstream file{path, std::ios::out | std::ios::binary};
|
||||
if (!file.is_open())
|
||||
{
|
||||
SHLOG_ERROR("Unable to open file for writing texture file: {}", path.string());
|
||||
}
|
||||
|
||||
auto const intBytes{sizeof(uint32_t)};
|
||||
|
||||
file.write(
|
||||
reinterpret_cast<char const*>(&asset.numBytes),
|
||||
intBytes
|
||||
);
|
||||
|
||||
file.write(
|
||||
reinterpret_cast<char const*>(&asset.width),
|
||||
intBytes
|
||||
);
|
||||
|
||||
file.write(
|
||||
reinterpret_cast<char const*>(&asset.height),
|
||||
intBytes
|
||||
);
|
||||
|
||||
file.write(
|
||||
reinterpret_cast<char const*>(&asset.format),
|
||||
sizeof(SHTexture::PixelChannel)
|
||||
);
|
||||
|
||||
file.write(
|
||||
reinterpret_cast<char const*>(asset.mipOffsets.data()),
|
||||
intBytes * asset.mipOffsets.size()
|
||||
);
|
||||
|
||||
file.write(
|
||||
reinterpret_cast<char const*>(asset.pixelData),
|
||||
asset.numBytes
|
||||
);
|
||||
|
||||
file.close();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include "Assets/Asset Types/SHTextureAsset.h"
|
||||
#include "Assets/SHAssetMacros.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
struct SHTextureCompiler
|
||||
{
|
||||
static void CompileTextureBinary(SHTextureAsset const& asset, AssetPath path);
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue