Files
Seele/src/Engine/Asset/TextureAsset.cpp
T
coding-agent 167bbce163 refactor: rename WindowManager to Application; move world ownership up
WindowManager.{h,cpp} -> Application.{h,cpp}

The Application class now owns the long-lived world (Scene, SystemGraph,
GameInterface) and is the single setup point. This removes the per-view
duplication where each GameView/PlayView loaded the binary and ran the
simulation independently, which double-simulated with two windows open.

Changes:
- WindowManager -> Application (class, files, includes, CMake)
- Application owns OScene scene_ / OSystemGraph graph_ (OwningPtr)
  and GameInterface* gameInterface (raw, deleted in dtor)
- loadGame(graphics, path, name): single world-setup point
  (dlopen -> setupScene -> append 5 editor systems)
- attachWorld(OScene, OSystemGraph): worldless hosts (benchmark)
  hand ownership in via move
- Frame-loop fix: systemGraph->run() now runs ONCE per frame, before
  the window loop (was per-window -> double-simulated with 2 windows)
- Editor/main.cpp + Benchmark/main.cpp rewired to the new API
- Window.h/.cpp: PWindowManager back-pointer -> PApplication
- 8 include paths updated to Window/Application.h

Compile-verified: Application.cpp, Editor/main.cpp, Benchmark/main.cpp
all pass g++ -std=c++23 -fsyntax-only against the full third-party
include set.
2026-11-09 17:23:42 +00:00

69 lines
2.9 KiB
C++

#include "TextureAsset.h"
#include "Graphics/Graphics.h"
#include "Graphics/Texture.h"
#include "Window/Application.h"
#include "ktx.h"
#include <iostream>
using namespace Seele;
#define KTX_ASSERT(x) \
{ \
auto error = x; \
if (error != KTX_SUCCESS) { \
std::cout << ktxErrorString(error) << std::endl; \
abort(); \
} \
}
TextureAsset::TextureAsset() {}
TextureAsset::TextureAsset(std::string_view folderPath, std::string_view name) : Asset(folderPath, name) {}
TextureAsset::~TextureAsset() {}
void TextureAsset::save(ArchiveBuffer& buffer) const {
Serialization::save(buffer, ktxData);
}
void TextureAsset::load(ArchiveBuffer& buffer) {
ktxTexture2* ktxHandle;
Serialization::load(buffer, ktxData);
KTX_ASSERT(
ktxTexture_CreateFromMemory(ktxData.data(), ktxData.size(), KTX_TEXTURE_CREATE_LOAD_IMAGE_DATA_BIT, (ktxTexture**)&ktxHandle));
ktxTexture2_TranscodeBasis(ktxHandle, KTX_TTF_RGBA32, 0);
Gfx::PGraphics graphics = buffer.getGraphics();
TextureCreateInfo createInfo = {
.sourceData =
{
.size = ktxTexture_GetDataSize(ktxTexture(ktxHandle)),
.data = ktxTexture_GetData(ktxTexture(ktxHandle)),
.owner = Gfx::QueueType::GRAPHICS,
},
.format = (Gfx::SeFormat)ktxHandle->vkFormat,
.width = ktxHandle->baseWidth,
.height = ktxHandle->baseHeight,
.depth = ktxHandle->baseDepth,
.elements = ktxHandle->numLayers,
.useMip = true,
.usage = Gfx::SE_IMAGE_USAGE_SAMPLED_BIT,
.name = name,
};
if (ktxHandle->isCubemap) {
texture = graphics->createTextureCube(createInfo);
} else if (ktxHandle->isArray) {
texture = graphics->createTexture3D(createInfo);
} else {
texture = graphics->createTexture2D(createInfo);
}
ktxTexture_Destroy(ktxTexture(ktxHandle));
byteSize = sizeof(TextureAsset) + ktxData.size();
}
uint32 TextureAsset::getWidth() { return texture->getWidth(); }
uint32 TextureAsset::getHeight() { return texture->getHeight(); }