extend to support rendering to RenderTarget/OpenGL texture on Linux
This commit is contained in:
@@ -46,7 +46,8 @@ using namespace camutils;
|
||||
namespace polyvox {
|
||||
class FilamentViewer {
|
||||
public:
|
||||
FilamentViewer(void* layer, LoadResource loadResource, FreeResource freeResource);
|
||||
// FilamentViewer(void* layer, LoadResource loadResource, FreeResource freeResource);
|
||||
FilamentViewer(void* context, LoadResource loadResource, FreeResource freeResource);
|
||||
~FilamentViewer();
|
||||
|
||||
void loadSkybox(const char* const skyboxUri);
|
||||
@@ -67,8 +68,11 @@ namespace polyvox {
|
||||
|
||||
bool setFirstCamera(SceneAsset* asset);
|
||||
bool setCamera(SceneAsset* asset, const char* nodeName);
|
||||
|
||||
void createSwapChain(void* surface, uint32_t width, uint32_t height);
|
||||
void destroySwapChain();
|
||||
void createSwapChain(void* surface);
|
||||
|
||||
void createRenderTarget(uint32_t glTextureId, uint32_t width,uint32_t height);
|
||||
|
||||
Renderer* getRenderer();
|
||||
|
||||
@@ -96,8 +100,6 @@ namespace polyvox {
|
||||
void loadResources(std::string relativeResourcePath);
|
||||
void cleanup();
|
||||
|
||||
void* _layer;
|
||||
|
||||
Manipulator<float>* _manipulator = nullptr;
|
||||
math::mat4f _cameraPosition;
|
||||
math::mat4f _cameraRotation;
|
||||
@@ -113,6 +115,9 @@ namespace polyvox {
|
||||
Camera* _mainCamera;
|
||||
|
||||
Renderer* _renderer;
|
||||
RenderTarget* _rt;
|
||||
Texture* _rtColor;
|
||||
Texture* _rtDepth;
|
||||
|
||||
SwapChain* _swapChain = nullptr;
|
||||
|
||||
@@ -124,12 +129,12 @@ namespace polyvox {
|
||||
std::mutex mtx; // mutex to ensure thread safety when removing assets
|
||||
|
||||
vector<Entity> _lights;
|
||||
Texture* _skyboxTexture;
|
||||
Skybox* _skybox;
|
||||
Texture* _iblTexture;
|
||||
IndirectLight* _indirectLight;
|
||||
Texture* _skyboxTexture = nullptr;
|
||||
Skybox* _skybox = nullptr;
|
||||
Texture* _iblTexture = nullptr;
|
||||
IndirectLight* _indirectLight = nullptr;
|
||||
|
||||
MaterialProvider* _materialProvider;
|
||||
MaterialProvider* _materialProvider = nullptr;
|
||||
|
||||
gltfio::ResourceLoader* _resourceLoader = nullptr;
|
||||
gltfio::TextureProvider* _stbDecoder = nullptr;
|
||||
|
||||
@@ -6,8 +6,9 @@
|
||||
typedef struct ResourceBuffer ResourceBuffer;
|
||||
|
||||
//ResourceBuffer create_resource_buffer(const void* data, const uint32_t size, const uint32_t id);
|
||||
void* filament_viewer_new(void* texture, void* loadResource, void* freeResource);
|
||||
void* filament_viewer_new(void* context, ResourceBuffer (*loadResource)(const char*), void (*freeResource)(uint32_t));
|
||||
void* filament_viewer_delete(void* viewer);
|
||||
void create_render_target(void* viewer, uint32_t textureId, uint32_t width, uint32_t height);
|
||||
void set_background_image(void* viewer, const char* path);
|
||||
void set_background_image_position(void* viewer, float x, float y, bool clamp);
|
||||
void load_skybox(void* viewer, const char* skyboxPath);
|
||||
@@ -21,6 +22,7 @@ void* load_glb(void* viewer, const char* assetPath);
|
||||
void* load_gltf(void* viewer, const char* assetPath, const char* relativePath);
|
||||
bool set_camera(void* viewer, void* asset, const char* nodeName);
|
||||
void render(void* viewer, uint64_t frameTimeInNanos);
|
||||
void create_swap_chain(void* viewer, void* surface = nullptr, uint32_t width = 0, uint32_t height = 0);
|
||||
void destroy_swap_chain(void* viewer);
|
||||
void set_frame_interval(void* viewer, float interval);
|
||||
void* get_renderer(void* viewer);
|
||||
|
||||
47
ios/include/material/UnlitMaterialProvider.hpp
Normal file
47
ios/include/material/UnlitMaterialProvider.hpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef UNLIT_MATERIAL_PROVIDER
|
||||
#define UNLIT_MATERIAL_PROVIDER
|
||||
namespace polyvox {
|
||||
class UnlitMaterialProvider : public MaterialProvider {
|
||||
|
||||
const Material* _m;
|
||||
const Material* _ms[1];
|
||||
|
||||
public:
|
||||
UnlitMaterialProvider(Engine* engine) {
|
||||
_m = Material::Builder()
|
||||
.package( UNLITOPAQUE_UNLIT_OPAQUE_DATA, UNLITOPAQUE_UNLIT_OPAQUE_SIZE)
|
||||
.build(*engine);
|
||||
_ms[0] = _m;
|
||||
}
|
||||
|
||||
filament::MaterialInstance* createMaterialInstance(MaterialKey* config, UvMap* uvmap,
|
||||
const char* label = "material", const char* extras = nullptr) {
|
||||
MaterialInstance* d = (MaterialInstance*)_m->getDefaultInstance();
|
||||
return d;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a weak reference to the array of cached materials.
|
||||
*/
|
||||
const filament::Material* const* getMaterials() const noexcept {
|
||||
return _ms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of cached materials.
|
||||
*/
|
||||
size_t getMaterialsCount() const noexcept {
|
||||
return (size_t)1;
|
||||
}
|
||||
|
||||
void destroyMaterials() {
|
||||
|
||||
}
|
||||
|
||||
bool needsDummyData(filament::VertexAttribute attrib) const noexcept {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -8,5 +8,5 @@ IMAGE_MATERIAL_PACKAGE:
|
||||
IMAGE_MATERIAL_IMAGE_OFFSET:
|
||||
.int 0
|
||||
IMAGE_MATERIAL_IMAGE_SIZE:
|
||||
.int 29215
|
||||
.int 14141
|
||||
|
||||
|
||||
@@ -8,5 +8,5 @@ _IMAGE_MATERIAL_PACKAGE:
|
||||
_IMAGE_MATERIAL_IMAGE_OFFSET:
|
||||
.int 0
|
||||
_IMAGE_MATERIAL_IMAGE_SIZE:
|
||||
.int 29215
|
||||
.int 14141
|
||||
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user