Implemented basic game dll interaction
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
DECLARE_NAME_REF(Gfx, Graphics)
|
||||
class Asset
|
||||
{
|
||||
public:
|
||||
@@ -17,8 +18,8 @@ public:
|
||||
Asset(const std::filesystem::path& path);
|
||||
virtual ~Asset();
|
||||
|
||||
virtual void save() = 0;
|
||||
virtual void load() = 0;
|
||||
virtual void save(Gfx::PGraphics graphics) = 0;
|
||||
virtual void load(Gfx::PGraphics graphics) = 0;
|
||||
|
||||
// returns the name of the file, without extension
|
||||
std::string getFileName() const;
|
||||
|
||||
@@ -21,9 +21,9 @@ AssetRegistry::~AssetRegistry()
|
||||
{
|
||||
}
|
||||
|
||||
void AssetRegistry::init(const std::string& rootFolder)
|
||||
void AssetRegistry::init(const std::string& rootFolder, Gfx::PGraphics graphics)
|
||||
{
|
||||
get().init(rootFolder, WindowManager::getGraphics());
|
||||
get().initialize(rootFolder, graphics);
|
||||
}
|
||||
|
||||
void AssetRegistry::importFile(const std::string &filePath)
|
||||
@@ -133,14 +133,14 @@ AssetRegistry::AssetRegistry()
|
||||
{
|
||||
}
|
||||
|
||||
void AssetRegistry::init(const std::filesystem::path &_rootFolder, Gfx::PGraphics graphics)
|
||||
void AssetRegistry::initialize(const std::filesystem::path &_rootFolder, Gfx::PGraphics _graphics)
|
||||
{
|
||||
AssetRegistry ® = get();
|
||||
reg.rootFolder = _rootFolder;
|
||||
reg.fontLoader = new FontLoader(graphics);
|
||||
reg.meshLoader = new MeshLoader(graphics);
|
||||
reg.textureLoader = new TextureLoader(graphics);
|
||||
reg.materialLoader = new MaterialLoader(graphics);
|
||||
this->graphics = _graphics;
|
||||
this->rootFolder = _rootFolder;
|
||||
this->fontLoader = new FontLoader(graphics);
|
||||
this->meshLoader = new MeshLoader(graphics);
|
||||
this->textureLoader = new TextureLoader(graphics);
|
||||
this->materialLoader = new MaterialLoader(graphics);
|
||||
}
|
||||
|
||||
std::string AssetRegistry::getRootFolder()
|
||||
|
||||
@@ -19,7 +19,7 @@ class AssetRegistry
|
||||
{
|
||||
public:
|
||||
~AssetRegistry();
|
||||
static void init(const std::string& rootFolder);
|
||||
static void init(const std::string& rootFolder, Gfx::PGraphics graphics);
|
||||
|
||||
static std::string getRootFolder();
|
||||
|
||||
@@ -47,7 +47,7 @@ private:
|
||||
static AssetRegistry& get();
|
||||
|
||||
AssetRegistry();
|
||||
void init(const std::filesystem::path& rootFolder, Gfx::PGraphics graphics);
|
||||
void initialize(const std::filesystem::path& rootFolder, Gfx::PGraphics graphics);
|
||||
|
||||
void importMesh(const std::filesystem::path& filePath, const std::string& importPath);
|
||||
void importTexture(const std::filesystem::path& filePath, const std::string& importPath);
|
||||
@@ -66,6 +66,7 @@ private:
|
||||
|
||||
std::filesystem::path rootFolder;
|
||||
AssetFolder assetRoot;
|
||||
Gfx::PGraphics graphics;
|
||||
UPTextureLoader textureLoader;
|
||||
UPFontLoader fontLoader;
|
||||
UPMeshLoader meshLoader;
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
#include "FontAsset.h"
|
||||
#include "Graphics/GraphicsResources.h"
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include "Window/WindowManager.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
@@ -25,55 +22,12 @@ FontAsset::~FontAsset()
|
||||
|
||||
}
|
||||
|
||||
void FontAsset::save()
|
||||
void FontAsset::save(Gfx::PGraphics graphics)
|
||||
{
|
||||
assert(false && "Cannot save font files");
|
||||
}
|
||||
|
||||
// in case of the space character there is no bitmap
|
||||
// so we create a single pixel empty texture
|
||||
uint8 transparentPixel = 0;
|
||||
|
||||
void FontAsset::load()
|
||||
void FontAsset::load(Gfx::PGraphics graphics)
|
||||
{
|
||||
FT_Library ft;
|
||||
FT_Error error = FT_Init_FreeType(&ft);
|
||||
assert(!error);
|
||||
FT_Face face;
|
||||
error = FT_New_Face(ft, getFullPath().c_str(), 0, &face);
|
||||
assert(!error);
|
||||
FT_Set_Pixel_Sizes(face, 0, 48);
|
||||
for(uint32 c = 0; c < 256; ++c)
|
||||
{
|
||||
Gfx::PGraphics graphics = WindowManager::getGraphics();
|
||||
if(FT_Load_Char(face, c, FT_LOAD_RENDER))
|
||||
{
|
||||
std::cout << "error loading " << (char)c << std::endl;
|
||||
continue;
|
||||
}
|
||||
Glyph& glyph = glyphs[c];
|
||||
glyph.size = IVector2(face->glyph->bitmap.width, face->glyph->bitmap.rows);
|
||||
glyph.bearing = IVector2(face->glyph->bitmap_left, face->glyph->bitmap_top);
|
||||
glyph.advance = face->glyph->advance.x;
|
||||
TextureCreateInfo imageData;
|
||||
imageData.format = Gfx::SE_FORMAT_R8_UINT;
|
||||
imageData.width = face->glyph->bitmap.width;
|
||||
imageData.height = face->glyph->bitmap.rows;
|
||||
imageData.resourceData.data = face->glyph->bitmap.buffer;
|
||||
imageData.resourceData.size = imageData.width * imageData.height;
|
||||
if(imageData.width == 0 || imageData.width == 0)
|
||||
{
|
||||
glyph.size.x = 1;
|
||||
glyph.size.y = 1;
|
||||
glyph.bearing.x = 0;
|
||||
glyph.bearing.y = 0;
|
||||
imageData.width = 1;
|
||||
imageData.height = 1;
|
||||
imageData.resourceData.size = sizeof(uint8);
|
||||
imageData.resourceData.data = &transparentPixel;
|
||||
}
|
||||
glyph.texture = graphics->createTexture2D(imageData);
|
||||
}
|
||||
FT_Done_Face(face);
|
||||
FT_Done_FreeType(ft);
|
||||
}
|
||||
@@ -11,8 +11,8 @@ public:
|
||||
FontAsset(const std::string& directory, const std::string& name);
|
||||
FontAsset(const std::filesystem::path& fullPath);
|
||||
virtual ~FontAsset();
|
||||
virtual void save() override;
|
||||
virtual void load() override;
|
||||
virtual void save(Gfx::PGraphics graphics) override;
|
||||
virtual void load(Gfx::PGraphics graphics) override;
|
||||
|
||||
struct Glyph
|
||||
{
|
||||
@@ -24,6 +24,7 @@ public:
|
||||
const std::map<uint32, Glyph> getGlyphData() const { return glyphs; }
|
||||
private:
|
||||
std::map<uint32, Glyph> glyphs;
|
||||
friend class FontLoader;
|
||||
};
|
||||
DECLARE_REF(FontAsset)
|
||||
} // namespace Seele
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
#include "Graphics/Graphics.h"
|
||||
#include "FontAsset.h"
|
||||
#include "AssetRegistry.h"
|
||||
#include "Graphics/GraphicsResources.h"
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
@@ -27,7 +30,49 @@ void FontLoader::importAsset(const std::filesystem::path& filePath, const std::s
|
||||
import(filePath, asset);
|
||||
}
|
||||
|
||||
// in case of the space character there is no bitmap
|
||||
// so we create a single pixel empty texture
|
||||
uint8 transparentPixel = 0;
|
||||
void FontLoader::import(std::filesystem::path path, PFontAsset asset)
|
||||
{
|
||||
asset->load();
|
||||
FT_Library ft;
|
||||
FT_Error error = FT_Init_FreeType(&ft);
|
||||
assert(!error);
|
||||
FT_Face face;
|
||||
error = FT_New_Face(ft, asset->getFullPath().c_str(), 0, &face);
|
||||
assert(!error);
|
||||
FT_Set_Pixel_Sizes(face, 0, 48);
|
||||
for(uint32 c = 0; c < 256; ++c)
|
||||
{
|
||||
if(FT_Load_Char(face, c, FT_LOAD_RENDER))
|
||||
{
|
||||
std::cout << "error loading " << (char)c << std::endl;
|
||||
continue;
|
||||
}
|
||||
FontAsset::Glyph& glyph = asset->glyphs[c];
|
||||
glyph.size = IVector2(face->glyph->bitmap.width, face->glyph->bitmap.rows);
|
||||
glyph.bearing = IVector2(face->glyph->bitmap_left, face->glyph->bitmap_top);
|
||||
glyph.advance = face->glyph->advance.x;
|
||||
TextureCreateInfo imageData;
|
||||
imageData.format = Gfx::SE_FORMAT_R8_UINT;
|
||||
imageData.width = face->glyph->bitmap.width;
|
||||
imageData.height = face->glyph->bitmap.rows;
|
||||
imageData.resourceData.data = face->glyph->bitmap.buffer;
|
||||
imageData.resourceData.size = imageData.width * imageData.height;
|
||||
if(imageData.width == 0 || imageData.width == 0)
|
||||
{
|
||||
glyph.size.x = 1;
|
||||
glyph.size.y = 1;
|
||||
glyph.bearing.x = 0;
|
||||
glyph.bearing.y = 0;
|
||||
imageData.width = 1;
|
||||
imageData.height = 1;
|
||||
imageData.resourceData.size = sizeof(uint8);
|
||||
imageData.resourceData.data = &transparentPixel;
|
||||
}
|
||||
glyph.texture = graphics->createTexture2D(imageData);
|
||||
}
|
||||
FT_Done_Face(face);
|
||||
FT_Done_FreeType(ft);
|
||||
asset->setStatus(Asset::Status::Ready);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "MaterialAsset.h"
|
||||
#include "Material/Material.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
@@ -22,20 +23,12 @@ MaterialAsset::~MaterialAsset()
|
||||
}
|
||||
|
||||
|
||||
void MaterialAsset::save()
|
||||
void MaterialAsset::save(Gfx::PGraphics graphics)
|
||||
{
|
||||
}
|
||||
|
||||
void MaterialAsset::load()
|
||||
void MaterialAsset::load(Gfx::PGraphics graphics)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void MaterialAsset::beginFrame()
|
||||
{
|
||||
}
|
||||
|
||||
void MaterialAsset::endFrame()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -11,10 +11,8 @@ public:
|
||||
MaterialAsset(const std::string &directory, const std::string &name);
|
||||
MaterialAsset(const std::filesystem::path &fullPath);
|
||||
virtual ~MaterialAsset();
|
||||
virtual void beginFrame();
|
||||
virtual void endFrame();
|
||||
virtual void save() override;
|
||||
virtual void load() override;
|
||||
virtual void save(Gfx::PGraphics graphics) override;
|
||||
virtual void load(Gfx::PGraphics graphics) override;
|
||||
PMaterial getMaterial() const { return material; }
|
||||
private:
|
||||
PMaterial material;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "MaterialInstanceAsset.h"
|
||||
#include "Material/MaterialInstance.h"
|
||||
#include "Material/Material.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
@@ -23,10 +24,10 @@ MaterialInstanceAsset::~MaterialInstanceAsset()
|
||||
}
|
||||
|
||||
|
||||
void MaterialInstanceAsset::save()
|
||||
void MaterialInstanceAsset::save(Gfx::PGraphics graphics)
|
||||
{
|
||||
}
|
||||
|
||||
void MaterialInstanceAsset::load()
|
||||
void MaterialInstanceAsset::load(Gfx::PGraphics graphics)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -11,10 +11,8 @@ public:
|
||||
MaterialInstanceAsset(const std::string &directory, const std::string &name);
|
||||
MaterialInstanceAsset(const std::filesystem::path &fullPath);
|
||||
virtual ~MaterialInstanceAsset();
|
||||
virtual void beginFrame();
|
||||
virtual void endFrame();
|
||||
virtual void save() override;
|
||||
virtual void load() override;
|
||||
virtual void save(Gfx::PGraphics graphics) override;
|
||||
virtual void load(Gfx::PGraphics graphics) override;
|
||||
private:
|
||||
PMaterialInstance material;
|
||||
};
|
||||
|
||||
@@ -38,7 +38,7 @@ void MaterialLoader::import(std::filesystem::path name, PMaterialAsset asset)
|
||||
json j;
|
||||
stream >> j;
|
||||
std::string materialName = j["name"].get<std::string>() + "Material";
|
||||
Gfx::PDescriptorLayout layout = WindowManager::getGraphics()->createDescriptorLayout(materialName + "Layout");
|
||||
Gfx::PDescriptorLayout layout = graphics->createDescriptorLayout(materialName + "Layout");
|
||||
//Shader file needs to conform to the slang standard, which prohibits _
|
||||
materialName.erase(std::remove(materialName.begin(), materialName.end(), '_'), materialName.end());
|
||||
materialName.erase(std::remove(materialName.begin(), materialName.end(), '.'), materialName.end());
|
||||
@@ -111,7 +111,7 @@ void MaterialLoader::import(std::filesystem::path name, PMaterialAsset asset)
|
||||
{
|
||||
PSamplerParameter p = new SamplerParameter(param.key(), 0, bindingCounter);
|
||||
layout->addDescriptorBinding(bindingCounter++, Gfx::SE_DESCRIPTOR_TYPE_SAMPLER);
|
||||
p->data = WindowManager::getGraphics()->createSamplerState({});
|
||||
p->data = graphics->createSamplerState({});
|
||||
parameters.add(p);
|
||||
}
|
||||
else
|
||||
@@ -128,6 +128,7 @@ void MaterialLoader::import(std::filesystem::path name, PMaterialAsset asset)
|
||||
codeStream.close();
|
||||
layout->create();
|
||||
asset->material = new Material(
|
||||
graphics,
|
||||
std::move(parameters),
|
||||
std::move(layout),
|
||||
uniformDataSize,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "MeshAsset.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
#include "Graphics/Mesh.h"
|
||||
#include "Graphics/VertexShaderInput.h"
|
||||
#include "Material/MaterialInterface.h"
|
||||
@@ -21,10 +22,10 @@ MeshAsset::~MeshAsset()
|
||||
{
|
||||
|
||||
}
|
||||
void MeshAsset::save()
|
||||
void MeshAsset::save(Gfx::PGraphics graphics)
|
||||
{
|
||||
}
|
||||
void MeshAsset::load()
|
||||
void MeshAsset::load(Gfx::PGraphics graphics)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ public:
|
||||
MeshAsset(const std::string& directory, const std::string& name);
|
||||
MeshAsset(const std::filesystem::path& fullPath);
|
||||
virtual ~MeshAsset();
|
||||
virtual void save() override;
|
||||
virtual void load() override;
|
||||
virtual void save(Gfx::PGraphics graphics) override;
|
||||
virtual void load(Gfx::PGraphics graphics) override;
|
||||
void addMesh(PMesh mesh);
|
||||
const Array<PMesh> getMeshes();
|
||||
//Workaround while no editor
|
||||
|
||||
@@ -259,7 +259,7 @@ void MeshLoader::loadTextures(const aiScene* scene, const std::filesystem::path&
|
||||
unsigned char* texData = new unsigned char[tex->mWidth * tex->mHeight * 4];
|
||||
convertAssimpARGB(texData, tex->pcData, tex->mWidth * tex->mHeight);
|
||||
stbi_write_png(texPngPath.string().c_str(), tex->mWidth, tex->mHeight, 4, tex->pcData, tex->mWidth * 32);
|
||||
delete texData;
|
||||
delete[] texData;
|
||||
}
|
||||
std::cout << "Loading model texture " << texPngPath.string() << std::endl;
|
||||
AssetRegistry::importFile(texPngPath.string());
|
||||
@@ -300,6 +300,5 @@ void MeshLoader::import(std::filesystem::path path, PMeshAsset meshAsset)
|
||||
}
|
||||
meshAsset->physicsMesh = std::move(collider);
|
||||
meshAsset->setStatus(Asset::Status::Ready);
|
||||
meshAsset->save();
|
||||
std::cout << "Finished loading " << path << std::endl;
|
||||
}
|
||||
|
||||
@@ -25,13 +25,13 @@ TextureAsset::~TextureAsset()
|
||||
|
||||
}
|
||||
|
||||
void TextureAsset::save()
|
||||
void TextureAsset::save(Gfx::PGraphics graphics)
|
||||
{
|
||||
//TODO: make this an actual file, not just a png wrapper
|
||||
assert(false && "Editing textures is not yet supported");
|
||||
}
|
||||
|
||||
void TextureAsset::load()
|
||||
void TextureAsset::load(Gfx::PGraphics graphics)
|
||||
{
|
||||
setStatus(Status::Loading);
|
||||
ktxTexture2* kTexture;
|
||||
@@ -40,19 +40,32 @@ void TextureAsset::load()
|
||||
ktxTexture2_CreateFromNamedFile(getFullPath().c_str(),
|
||||
KTX_TEXTURE_CREATE_LOAD_IMAGE_DATA_BIT,
|
||||
&kTexture);
|
||||
|
||||
TextureCreateInfo createInfo;
|
||||
createInfo.width = kTexture->baseWidth;
|
||||
createInfo.height = kTexture->baseHeight;
|
||||
createInfo.depth = kTexture->baseDepth;
|
||||
createInfo.bArray = kTexture->isArray;
|
||||
createInfo.arrayLayers = kTexture->numLayers;
|
||||
createInfo.arrayLayers = kTexture->isArray ? kTexture->numLayers : kTexture->numFaces;
|
||||
createInfo.format = Vulkan::cast((VkFormat)kTexture->vkFormat);
|
||||
createInfo.mipLevels = kTexture->numLevels;
|
||||
createInfo.usage = Gfx::SE_IMAGE_USAGE_SAMPLED_BIT;
|
||||
createInfo.resourceData.data = ktxTexture_GetData(ktxTexture(kTexture));
|
||||
createInfo.resourceData.size = ktxTexture_GetDataSize(ktxTexture(kTexture));
|
||||
createInfo.resourceData.owner = Gfx::QueueType::DEDICATED_TRANSFER;
|
||||
Gfx::PTexture2D tex = WindowManager::getGraphics()->createTexture2D(createInfo);
|
||||
Gfx::PTexture tex;
|
||||
if (kTexture->isCubemap)
|
||||
{
|
||||
tex = graphics->createTextureCube(createInfo);
|
||||
}
|
||||
else if (kTexture->isArray)
|
||||
{
|
||||
tex = graphics->createTexture3D(createInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
tex = graphics->createTexture2D(createInfo);
|
||||
}
|
||||
tex->transferOwnership(Gfx::QueueType::GRAPHICS);
|
||||
setTexture(tex);
|
||||
setStatus(Asset::Status::Ready);
|
||||
|
||||
@@ -11,8 +11,8 @@ public:
|
||||
TextureAsset(const std::string& directory, const std::string& name);
|
||||
TextureAsset(const std::filesystem::path& fullPath);
|
||||
virtual ~TextureAsset();
|
||||
virtual void save() override;
|
||||
virtual void load() override;
|
||||
virtual void save(Gfx::PGraphics graphics) override;
|
||||
virtual void load(Gfx::PGraphics graphics) override;
|
||||
void setTexture(Gfx::PTexture _texture)
|
||||
{
|
||||
std::scoped_lock lck(lock);
|
||||
|
||||
@@ -15,7 +15,7 @@ TextureLoader::TextureLoader(Gfx::PGraphics graphics)
|
||||
: graphics(graphics)
|
||||
{
|
||||
placeholderAsset = new TextureAsset(std::filesystem::absolute("./textures/placeholder.ktx"));
|
||||
placeholderAsset->load();
|
||||
placeholderAsset->load(graphics);
|
||||
AssetRegistry::get().assetRoot.textures[""] = placeholderAsset;
|
||||
}
|
||||
|
||||
@@ -41,35 +41,80 @@ PTextureAsset TextureLoader::getPlaceholderTexture()
|
||||
|
||||
void TextureLoader::import(std::filesystem::path path, PTextureAsset textureAsset)
|
||||
{
|
||||
int x, y, n;
|
||||
unsigned char* data = stbi_load(path.string().c_str(), &x, &y, &n, 4);
|
||||
int totalWidth, totalHeight, n;
|
||||
unsigned char* data = stbi_load(path.string().c_str(), &totalWidth, &totalHeight, &n, 4);
|
||||
ktxTexture2* kTexture;
|
||||
ktxTextureCreateInfo createInfo;
|
||||
|
||||
createInfo.vkFormat = VK_FORMAT_R8G8B8A8_SRGB;
|
||||
createInfo.baseWidth = x;
|
||||
createInfo.baseHeight = y;
|
||||
createInfo.baseDepth = 1;
|
||||
createInfo.numDimensions = 1 + (y > 1);
|
||||
createInfo.numLevels = 1;
|
||||
createInfo.numLayers = 1;
|
||||
createInfo.numFaces = 1;
|
||||
createInfo.isArray = false;
|
||||
createInfo.generateMipmaps = true;
|
||||
if (totalWidth / 4 == totalHeight / 3)
|
||||
{
|
||||
uint32 faceWidth = totalWidth / 4;
|
||||
uint32 faceHeight = totalHeight / 3;
|
||||
// Cube map
|
||||
createInfo.vkFormat = VK_FORMAT_R8G8B8A8_SRGB;
|
||||
createInfo.baseWidth = totalWidth / 4;
|
||||
createInfo.baseHeight = totalHeight / 3;
|
||||
createInfo.baseDepth = 1;
|
||||
createInfo.numFaces = 6;
|
||||
createInfo.numDimensions = 3;
|
||||
createInfo.numLevels = 1;
|
||||
createInfo.numLayers = 1;
|
||||
createInfo.isArray = false;
|
||||
createInfo.generateMipmaps = true;
|
||||
|
||||
ktxTexture2_Create(&createInfo,
|
||||
KTX_TEXTURE_CREATE_ALLOC_STORAGE,
|
||||
&kTexture);
|
||||
ktxTexture2_Create(&createInfo,
|
||||
KTX_TEXTURE_CREATE_ALLOC_STORAGE,
|
||||
&kTexture);
|
||||
|
||||
ktxTexture_SetImageFromMemory(ktxTexture(kTexture),
|
||||
0, 0, 0, data, x * y * 4 * sizeof(unsigned char));
|
||||
auto loadCubeFace = [kTexture, faceWidth, totalWidth, data](int xPos, int yPos, int faceName)
|
||||
{
|
||||
std::vector<unsigned char> vec(faceWidth * faceWidth * 4);
|
||||
for (int y = 0; y < faceWidth; ++y)
|
||||
{
|
||||
for (int x = 0; x < faceWidth; ++x)
|
||||
{
|
||||
int imgX = x + (xPos * faceWidth);
|
||||
int imgY = y + (yPos * faceWidth);
|
||||
std::memcpy(&vec[(x + (faceWidth * y)) * 4], &data[(imgX + (totalWidth * imgY)) * 4], 4);
|
||||
}
|
||||
}
|
||||
ktxTexture_SetImageFromMemory(ktxTexture(kTexture),
|
||||
0, 0, faceName, vec.data(), vec.size());
|
||||
};
|
||||
loadCubeFace(1, 0, 0);
|
||||
loadCubeFace(0, 1, 1);
|
||||
loadCubeFace(1, 1, 2);
|
||||
loadCubeFace(2, 1, 3);
|
||||
loadCubeFace(3, 1, 4);
|
||||
loadCubeFace(1, 2, 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
createInfo.vkFormat = VK_FORMAT_R8G8B8A8_SRGB;
|
||||
createInfo.baseWidth = totalWidth;
|
||||
createInfo.baseHeight = totalHeight;
|
||||
createInfo.baseDepth = 1;
|
||||
createInfo.numDimensions = 1 + (totalHeight > 1);
|
||||
createInfo.numLevels = 1;
|
||||
createInfo.numLayers = 1;
|
||||
createInfo.numFaces = 1;
|
||||
createInfo.isArray = false;
|
||||
createInfo.generateMipmaps = true;
|
||||
|
||||
ktxTexture2_Create(&createInfo,
|
||||
KTX_TEXTURE_CREATE_ALLOC_STORAGE,
|
||||
&kTexture);
|
||||
|
||||
ktxTexture_SetImageFromMemory(ktxTexture(kTexture),
|
||||
0, 0, 0, data, totalWidth * totalHeight * 4 * sizeof(unsigned char));
|
||||
}
|
||||
|
||||
stbi_image_free(data);
|
||||
|
||||
ktxTexture_WriteToNamedFile(ktxTexture(kTexture), textureAsset->getFullPath().c_str());
|
||||
ktxTexture_Destroy(ktxTexture(kTexture));
|
||||
|
||||
textureAsset->load();
|
||||
textureAsset->load(graphics);
|
||||
textureAsset->setStatus(Asset::Status::Ready);
|
||||
////co_return;
|
||||
}
|
||||
Reference in New Issue
Block a user