add gltfio FFI methods and expose texture/render target creation directly

This commit is contained in:
Nick Fisher
2025-03-17 18:53:36 +08:00
parent 2244359edd
commit bff76f184e
15 changed files with 622 additions and 202 deletions

View File

@@ -0,0 +1,41 @@
#include "c_api/TScene.h"
#include <filament/Engine.h>
#include <filament/Fence.h>
#include <filament/RenderTarget.h>
#include <filament/Texture.h>
#include <filament/TextureSampler.h>
#include "Log.hpp"
#ifdef __cplusplus
namespace thermion
{
extern "C"
{
using namespace filament;
#endif
EMSCRIPTEN_KEEPALIVE TRenderTarget *RenderTarget_create(
TEngine *tEngine,
uint32_t width,
uint32_t height,
TTexture *tColor,
TTexture *tDepth)
{
auto engine = reinterpret_cast<filament::Engine *>(tEngine);
auto color = reinterpret_cast<filament::Texture *>(tColor);
auto depth = reinterpret_cast<filament::Texture *>(tDepth);
auto rt = filament::RenderTarget::Builder()
.texture(RenderTarget::AttachmentPoint::COLOR, color)
.texture(RenderTarget::AttachmentPoint::DEPTH, depth)
.build(*engine);
return reinterpret_cast<TRenderTarget *>(rt);
}
#ifdef __cplusplus
}
}
#endif