create material for texture baking
textures can now be created manually and are no longer tracked by SceneManager (and therefore require manual tracking/disposal)
This commit is contained in:
@@ -244,6 +244,12 @@ namespace thermion
|
||||
return reinterpret_cast<TTexture *>(texture);
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE void Engine_destroyTexture(TEngine *tEngine, TTexture *tTexture) {
|
||||
auto *engine = reinterpret_cast<Engine *>(tEngine);
|
||||
auto *texture = reinterpret_cast<Texture *>(tTexture);
|
||||
engine->destroy(texture);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <filament/Engine.h>
|
||||
#include <filament/Material.h>
|
||||
#include <filament/RenderTarget.h>
|
||||
#include <filament/Scene.h>
|
||||
#include <filament/Texture.h>
|
||||
#include <filament/TextureSampler.h>
|
||||
@@ -36,6 +37,12 @@ namespace thermion
|
||||
return reinterpret_cast<TLinearImage *>(linearImage);
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE float *Image_getBytes(TLinearImage *tLinearImage)
|
||||
{
|
||||
auto *linearImage = reinterpret_cast<::image::LinearImage *>(tLinearImage);
|
||||
return linearImage->getPixelRef();
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE uint32_t Image_getWidth(TLinearImage *tLinearImage)
|
||||
{
|
||||
auto *linearImage = reinterpret_cast<::image::LinearImage *>(tLinearImage);
|
||||
@@ -98,6 +105,13 @@ namespace thermion
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE TLinearImage *Image_createEmpty(uint32_t width,uint32_t height,uint32_t channel) {
|
||||
auto *image = new ::image::LinearImage(width, height, channel);
|
||||
return reinterpret_cast<TLinearImage*>(image);
|
||||
}
|
||||
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE TTextureSampler *TextureSampler_create()
|
||||
{
|
||||
auto *sampler = new filament::TextureSampler();
|
||||
@@ -217,6 +231,12 @@ namespace thermion
|
||||
delete textureSampler;
|
||||
}
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE TTexture *RenderTarget_getColorTexture(TRenderTarget *tRenderTarget) {
|
||||
auto renderTarget = reinterpret_cast<filament::RenderTarget*>(tRenderTarget);
|
||||
auto texture = renderTarget->getTexture(filament::RenderTarget::AttachmentPoint::COLOR0);
|
||||
return reinterpret_cast<TTexture*>(texture);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -413,20 +413,5 @@ extern "C"
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE void unproject_texture(TViewer *viewer, EntityId entity, uint8_t *input, uint32_t inputWidth, uint32_t inputHeight, uint8_t *out, uint32_t outWidth, uint32_t outHeight)
|
||||
{
|
||||
// ((FilamentViewer *)viewer)->unprojectTexture(entity, input, inputWidth, inputHeight, out, outWidth, outHeight);
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE void apply_texture_to_material(TSceneManager *sceneManager, EntityId entity, void *const texture, const char *parameterName, int materialIndex)
|
||||
{
|
||||
((SceneManager *)sceneManager)->applyTexture(entity, reinterpret_cast<Texture *>(texture), parameterName, materialIndex);
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE void destroy_texture(TSceneManager *sceneManager, void *const texture)
|
||||
{
|
||||
((SceneManager *)sceneManager)->destroyTexture(reinterpret_cast<Texture *>(texture));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -722,17 +722,6 @@ std::packaged_task<void()> lambda(
|
||||
auto fut = _rl->add_task(lambda);
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE void unproject_texture_render_thread(TViewer *viewer, EntityId entity, uint8_t *input, uint32_t inputWidth, uint32_t inputHeight, uint8_t *out, uint32_t outWidth, uint32_t outHeight, void (*callback)())
|
||||
{
|
||||
std::packaged_task<void()> lambda(
|
||||
[=]
|
||||
{
|
||||
unproject_texture(viewer, entity, input, inputWidth, inputHeight, out, outWidth, outHeight);
|
||||
callback();
|
||||
});
|
||||
auto fut = _rl->add_task(lambda);
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE void AnimationManager_updateBoneMatricesRenderThread(
|
||||
TAnimationManager *tAnimationManager,
|
||||
TSceneAsset *sceneAsset,
|
||||
|
||||
Reference in New Issue
Block a user