iOS fixes
This commit is contained in:
@@ -8,8 +8,11 @@
|
|||||||
#import "polyvox_filament-Swift.h"
|
#import "polyvox_filament-Swift.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "PolyvoxFilamentApi.h"
|
||||||
|
|
||||||
@implementation PolyvoxFilamentPlugin
|
@implementation PolyvoxFilamentPlugin
|
||||||
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
|
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
|
||||||
[SwiftPolyvoxFilamentPlugin registerWithRegistrar:registrar];
|
[SwiftPolyvoxFilamentPlugin registerWithRegistrar:registrar];
|
||||||
|
ios_dummy();
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -5,11 +5,13 @@ import GLKit
|
|||||||
public class SwiftPolyvoxFilamentPlugin: NSObject, FlutterPlugin, FlutterTexture {
|
public class SwiftPolyvoxFilamentPlugin: NSObject, FlutterPlugin, FlutterTexture {
|
||||||
|
|
||||||
var registrar : FlutterPluginRegistrar
|
var registrar : FlutterPluginRegistrar
|
||||||
var textureId: Int64?
|
var flutterTextureId: Int64?
|
||||||
var registry: FlutterTextureRegistry
|
var registry: FlutterTextureRegistry
|
||||||
|
|
||||||
var pixelBuffer: CVPixelBuffer?;
|
var pixelBuffer: CVPixelBuffer?;
|
||||||
|
|
||||||
|
var createdAt = Date()
|
||||||
|
|
||||||
var pixelBufferAttrs = [
|
var pixelBufferAttrs = [
|
||||||
kCVPixelBufferPixelFormatTypeKey: NSNumber(value: kCVPixelFormatType_32BGRA),
|
kCVPixelBufferPixelFormatTypeKey: NSNumber(value: kCVPixelFormatType_32BGRA),
|
||||||
kCVPixelBufferOpenGLCompatibilityKey: kCFBooleanTrue,
|
kCVPixelBufferOpenGLCompatibilityKey: kCFBooleanTrue,
|
||||||
@@ -27,11 +29,11 @@ public class SwiftPolyvoxFilamentPlugin: NSObject, FlutterPlugin, FlutterTexture
|
|||||||
var freeResourcePtr: UnsafeMutableRawPointer? = nil
|
var freeResourcePtr: UnsafeMutableRawPointer? = nil
|
||||||
|
|
||||||
|
|
||||||
var loadResource : @convention(c) (UnsafeRawPointer, UnsafeMutableRawPointer) -> ResourceBuffer = { uri, resourcesPtr in
|
var loadResource : @convention(c) (UnsafePointer<Int8>?, UnsafeMutableRawPointer?) -> ResourceBuffer = { uri, resourcesPtr in
|
||||||
|
|
||||||
let instance:SwiftPolyvoxFilamentPlugin = Unmanaged<SwiftPolyvoxFilamentPlugin>.fromOpaque(resourcesPtr).takeUnretainedValue()
|
let instance:SwiftPolyvoxFilamentPlugin = Unmanaged<SwiftPolyvoxFilamentPlugin>.fromOpaque(resourcesPtr!).takeUnretainedValue()
|
||||||
|
|
||||||
let uriString = String(cString:uri.assumingMemoryBound(to: UInt8.self))
|
let uriString = String(cString:uri!)
|
||||||
|
|
||||||
var path:String? = nil
|
var path:String? = nil
|
||||||
|
|
||||||
@@ -99,7 +101,13 @@ public class SwiftPolyvoxFilamentPlugin: NSObject, FlutterPlugin, FlutterTexture
|
|||||||
return ResourceBuffer()
|
return ResourceBuffer()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// TODO
|
let key = instance.registrar.lookupKey(forAsset:uriString)
|
||||||
|
path = Bundle.main.path(forResource: key, ofType:nil)
|
||||||
|
print("Found path \(path) for uri \(uriString)")
|
||||||
|
guard path != nil else {
|
||||||
|
print("File not present in bundle : \(uri)")
|
||||||
|
return ResourceBuffer()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
@@ -116,9 +124,13 @@ public class SwiftPolyvoxFilamentPlugin: NSObject, FlutterPlugin, FlutterTexture
|
|||||||
return ResourceBuffer()
|
return ResourceBuffer()
|
||||||
}
|
}
|
||||||
|
|
||||||
var freeResource : @convention(c) (UInt32,UnsafeMutableRawPointer) -> () = { rid, resourcesPtr in
|
var freeResource : @convention(c) (ResourceBuffer,UnsafeMutableRawPointer?) -> () = { rbuf, resourcesPtr in
|
||||||
let instance:SwiftPolyvoxFilamentPlugin = Unmanaged<SwiftPolyvoxFilamentPlugin>.fromOpaque(resourcesPtr).takeUnretainedValue()
|
let instance:SwiftPolyvoxFilamentPlugin = Unmanaged<SwiftPolyvoxFilamentPlugin>.fromOpaque(resourcesPtr!).takeUnretainedValue()
|
||||||
instance.resources.removeObject(forKey:rid)
|
instance.resources.removeObject(forKey:rbuf.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func doRender() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func createDisplayLink() {
|
func createDisplayLink() {
|
||||||
@@ -135,7 +147,7 @@ public class SwiftPolyvoxFilamentPlugin: NSObject, FlutterPlugin, FlutterTexture
|
|||||||
return Unmanaged.passRetained(pixelBuffer!);
|
return Unmanaged.passRetained(pixelBuffer!);
|
||||||
}
|
}
|
||||||
|
|
||||||
public func onTextureUnregistered(texture:FlutterTexture) {
|
public func onTextureUnregistered(_ texture:FlutterTexture) {
|
||||||
print("Texture unregistered")
|
print("Texture unregistered")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,37 +169,45 @@ public class SwiftPolyvoxFilamentPlugin: NSObject, FlutterPlugin, FlutterTexture
|
|||||||
kCVPixelFormatType_32BGRA, pixelBufferAttrs, &pixelBuffer) != kCVReturnSuccess) {
|
kCVPixelFormatType_32BGRA, pixelBufferAttrs, &pixelBuffer) != kCVReturnSuccess) {
|
||||||
print("Error allocating pixel buffer")
|
print("Error allocating pixel buffer")
|
||||||
}
|
}
|
||||||
self.textureId = self.registry.register(self)
|
self.flutterTextureId = self.registry.register(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func resize(width:Int32, height:Int32) {
|
private func resize(width:Int32, height:Int32) {
|
||||||
if(self.textureId != nil) {
|
if(self.flutterTextureId != nil) {
|
||||||
self.registry.unregisterTexture(self.textureId!)
|
self.registry.unregisterTexture(self.flutterTextureId!)
|
||||||
}
|
}
|
||||||
createPixelBuffer(width: Int(width), height:Int(height))
|
createPixelBuffer(width: Int(width), height:Int(height))
|
||||||
}
|
}
|
||||||
|
|
||||||
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||||
let methodName = call.method;
|
let methodName = call.method;
|
||||||
|
print(methodName)
|
||||||
switch methodName {
|
switch methodName {
|
||||||
case "createTexture":
|
case "createTexture":
|
||||||
let args = call.arguments as! Array<Int32>
|
let args = call.arguments as! Array<Int32>
|
||||||
createPixelBuffer(width:args[0], height:args[1])
|
createPixelBuffer(width:Int(args[0]), height:Int(args[1]))
|
||||||
createDisplayLink()
|
createDisplayLink()
|
||||||
result(unsafeBitCast(pixelBuffer!, to: UnsafeMutableRawPointer.self))
|
result(self.flutterTextureId)
|
||||||
case "getLoadResourceFn":
|
// print("texture id \(pixelBufferflutterTextureId)")
|
||||||
result(unsafeBitCast(loadResource, to: UnsafeMutableRawPointer.self))
|
case "getLoadResourceFn":
|
||||||
|
|
||||||
|
let callback = make_resource_loader(loadResource, freeResource, Unmanaged.passUnretained(self).toOpaque())
|
||||||
|
|
||||||
|
result(unsafeBitCast(callback, to:Int64.self))
|
||||||
case "getFreeResourceFn":
|
case "getFreeResourceFn":
|
||||||
result(unsafeBitCast(freeResource, to: UnsafeMutableRawPointer.self))
|
result(unsafeBitCast(freeResource, to:Int64.self))
|
||||||
case "getGlTextureId":
|
case "getGlTextureId":
|
||||||
result(Unmanaged.passUnretained(self).toOpaque())
|
result(FlutterMethodNotImplemented)
|
||||||
|
case "getSurface":
|
||||||
|
var pixelBufferTextureId = Int64(Int(bitPattern:unsafeBitCast(pixelBuffer!, to: UnsafeMutableRawPointer.self)))
|
||||||
|
result(pixelBufferTextureId)
|
||||||
|
|
||||||
case "getContext":
|
case "getContext":
|
||||||
result(nil)
|
result(0) //nullptr
|
||||||
case "resize":
|
case "resize":
|
||||||
result(self.textureId);
|
result(self.flutterTextureId);
|
||||||
case "tick":
|
case "tick":
|
||||||
self.registry.textureFrameAvailable(textureId)
|
self.registry.textureFrameAvailable(flutterTextureId!)
|
||||||
result(true)
|
result(true)
|
||||||
default:
|
default:
|
||||||
result(FlutterMethodNotImplemented)
|
result(FlutterMethodNotImplemented)
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
#include <gltfio/FilamentAsset.h>
|
#include <gltfio/FilamentAsset.h>
|
||||||
#include <gltfio/ResourceLoader.h>
|
#include <gltfio/ResourceLoader.h>
|
||||||
|
|
||||||
#include "ResourceManagement.hpp"
|
|
||||||
#include "SceneAsset.hpp"
|
#include "SceneAsset.hpp"
|
||||||
#include "ResourceBuffer.hpp"
|
#include "ResourceBuffer.hpp"
|
||||||
|
|
||||||
@@ -18,8 +17,7 @@ namespace polyvox {
|
|||||||
|
|
||||||
class AssetManager {
|
class AssetManager {
|
||||||
public:
|
public:
|
||||||
AssetManager(LoadResource loadResource,
|
AssetManager(ResourceLoaderWrapper* loader,
|
||||||
FreeResource freeResource,
|
|
||||||
NameComponentManager *ncm,
|
NameComponentManager *ncm,
|
||||||
Engine *engine,
|
Engine *engine,
|
||||||
Scene *scene);
|
Scene *scene);
|
||||||
@@ -64,10 +62,8 @@ namespace polyvox {
|
|||||||
void setAnimationFrame(EntityId entity, int animationIndex, int animationFrame);
|
void setAnimationFrame(EntityId entity, int animationIndex, int animationFrame);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LoadResource _loadResource;
|
|
||||||
FreeResource _freeResource;
|
|
||||||
AssetLoader* _assetLoader = nullptr;
|
AssetLoader* _assetLoader = nullptr;
|
||||||
ResourceLoader* _resourceLoader = nullptr;
|
ResourceLoaderWrapper* _resourceLoaderWrapper;
|
||||||
NameComponentManager* _ncm = nullptr;
|
NameComponentManager* _ncm = nullptr;
|
||||||
Engine* _engine;
|
Engine* _engine;
|
||||||
Scene* _scene;
|
Scene* _scene;
|
||||||
|
|||||||
@@ -32,7 +32,6 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
#include "AssetManager.hpp"
|
#include "AssetManager.hpp"
|
||||||
#include "ResourceManagement.hpp"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace filament;
|
using namespace filament;
|
||||||
@@ -46,7 +45,7 @@ namespace polyvox {
|
|||||||
class FilamentViewer {
|
class FilamentViewer {
|
||||||
public:
|
public:
|
||||||
// FilamentViewer(void* layer, LoadResource loadResource, FreeResource freeResource);
|
// FilamentViewer(void* layer, LoadResource loadResource, FreeResource freeResource);
|
||||||
FilamentViewer(void* context, LoadResource loadResource, FreeResource freeResource);
|
FilamentViewer(void* context, ResourceLoaderWrapper* resourceLoaderWrapper);
|
||||||
~FilamentViewer();
|
~FilamentViewer();
|
||||||
|
|
||||||
void loadSkybox(const char* const skyboxUri);
|
void loadSkybox(const char* const skyboxUri);
|
||||||
@@ -107,8 +106,7 @@ namespace polyvox {
|
|||||||
math::mat4f _cameraPosition;
|
math::mat4f _cameraPosition;
|
||||||
math::mat4f _cameraRotation;
|
math::mat4f _cameraRotation;
|
||||||
|
|
||||||
LoadResource _loadResource;
|
ResourceLoaderWrapper* _resourceLoaderWrapper;
|
||||||
FreeResource _freeResource;
|
|
||||||
|
|
||||||
Scene* _scene;
|
Scene* _scene;
|
||||||
View* _view;
|
View* _view;
|
||||||
|
|||||||
@@ -5,12 +5,10 @@
|
|||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
typedef struct ResourceBuffer ResourceBuffer;
|
|
||||||
|
|
||||||
typedef int32_t EntityId;
|
typedef int32_t EntityId;
|
||||||
|
|
||||||
intptr_t init_dart_api_dl(void* data);
|
void* create_filament_viewer(void *context, ResourceLoaderWrapper* loader);
|
||||||
void* create_filament_viewer(void *context, ResourceBuffer (*loadResource)(const char *), void (*freeResource)(uint32_t));
|
ResourceLoaderWrapper* make_resource_loader(LoadResourceFromOwner loadFn, FreeResourceFromOwner freeFn, void* owner);
|
||||||
void delete_filament_viewer(void *viewer);
|
void delete_filament_viewer(void *viewer);
|
||||||
void* get_asset_manager(void* viewer);
|
void* get_asset_manager(void* viewer);
|
||||||
void create_render_target(void *viewer, uint32_t textureId, uint32_t width, uint32_t height);
|
void create_render_target(void *viewer, uint32_t textureId, uint32_t width, uint32_t height);
|
||||||
@@ -103,5 +101,6 @@ void set_camera_rotation(void *viewer, float rads, float x, float y, float z);
|
|||||||
void set_camera_model_matrix(void *viewer, const float *const matrix);
|
void set_camera_model_matrix(void *viewer, const float *const matrix);
|
||||||
void set_camera_focal_length(void *viewer, float focalLength);
|
void set_camera_focal_length(void *viewer, float focalLength);
|
||||||
void set_camera_focus_distance(void *viewer, float focusDistance);
|
void set_camera_focus_distance(void *viewer, float focusDistance);
|
||||||
|
void ios_dummy();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
void* create_filament_viewer_ios(void* texture, void* loadResource, void* freeResource, void* resources);
|
|
||||||
|
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
|
#include "Log.hpp"
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
//
|
//
|
||||||
@@ -38,6 +39,43 @@ extern "C" {
|
|||||||
uint32_t size;
|
uint32_t size;
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct ResourceBuffer ResourceBuffer;
|
||||||
|
typedef ResourceBuffer (*LoadResource)(const char* uri);
|
||||||
|
typedef ResourceBuffer (*LoadResourceFromOwner)(const char* const, void* const owner);
|
||||||
|
typedef void (*FreeResource)(ResourceBuffer);
|
||||||
|
typedef void (*FreeResourceFromOwner)(ResourceBuffer, void* const owner);
|
||||||
|
|
||||||
|
struct ResourceLoaderWrapper {
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
ResourceLoaderWrapper(LoadResource loader, FreeResource freeResource) : mLoadResource(loader), mFreeResource(freeResource) {};
|
||||||
|
ResourceLoaderWrapper(LoadResourceFromOwner loader, FreeResourceFromOwner freeResource, void* const owner) : mLoadResourceFromOwner(loader), mFreeResourceFromOwner(freeResource), mOwner(owner) {};
|
||||||
|
|
||||||
|
ResourceBuffer load(const char* uri) {
|
||||||
|
Log("LOADING %s", uri);
|
||||||
|
if(mLoadResourceFromOwner) {
|
||||||
|
return mLoadResourceFromOwner(uri, mOwner);
|
||||||
|
}
|
||||||
|
return mLoadResource(uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
void free(ResourceBuffer rb) {
|
||||||
|
if(mFreeResourceFromOwner) {
|
||||||
|
mFreeResourceFromOwner(rb, mOwner);
|
||||||
|
} else {
|
||||||
|
mFreeResource(rb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
void* mOwner;
|
||||||
|
LoadResource mLoadResource;
|
||||||
|
FreeResource mFreeResource;
|
||||||
|
LoadResourceFromOwner mLoadResourceFromOwner;
|
||||||
|
FreeResourceFromOwner mFreeResourceFromOwner;
|
||||||
|
};
|
||||||
|
typedef struct ResourceLoaderWrapper ResourceLoaderWrapper;
|
||||||
|
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include <memory>
|
|
||||||
#include <chrono>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "ResourceBuffer.hpp"
|
|
||||||
|
|
||||||
namespace polyvox {
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Typedef for a function that loads a resource into a ResourceBuffer from an asset URI.
|
|
||||||
//
|
|
||||||
using LoadResource = function<ResourceBuffer(const char* uri)>;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Typedef for a function that frees an ID associated with a ResourceBuffer.
|
|
||||||
//
|
|
||||||
using FreeResource = function<void (uint32_t)>;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -18,8 +18,6 @@
|
|||||||
#include <gltfio/ResourceLoader.h>
|
#include <gltfio/ResourceLoader.h>
|
||||||
#include <utils/NameComponentManager.h>
|
#include <utils/NameComponentManager.h>
|
||||||
|
|
||||||
#include "ResourceManagement.hpp"
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "PolyvoxFilamentApi.h"
|
#include "PolyvoxFilamentApi.h"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#ifndef SwiftPolyvoxFilamentPlugin_Bridging_Header_h
|
#ifndef SwiftPolyvoxFilamentPlugin_Bridging_Header_h
|
||||||
#define SwiftPolyvoxFilamentPlugin_Bridging_Header_h
|
#define SwiftPolyvoxFilamentPlugin_Bridging_Header_h
|
||||||
|
|
||||||
#import "PolyvoxFilamentIOSApi.h"
|
|
||||||
#import "PolyvoxFilamentApi.h"
|
#import "PolyvoxFilamentApi.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
3
ios/lib/libimageio.a
Normal file
3
ios/lib/libimageio.a
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:08902f0dbd7ec01e30d31243a58f9707b31c69b8e7b658a3a3c160e4fe2a1f69
|
||||||
|
size 372376
|
||||||
3
ios/lib/libpng.a
Normal file
3
ios/lib/libpng.a
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:6f40a337ca4ae110bbfee332e03ee496b0f3706b6b9d264a44f3c248733f4f23
|
||||||
|
size 376488
|
||||||
3
ios/lib/libtinyexr.a
Normal file
3
ios/lib/libtinyexr.a
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:60e5e22f31b84e116475a8232310b3a452134587e81a2d0f9bf5c1a0af834f06
|
||||||
|
size 511480
|
||||||
@@ -14,7 +14,7 @@ A new flutter plugin project.
|
|||||||
s.author = { 'Your Company' => 'email@example.com' }
|
s.author = { 'Your Company' => 'email@example.com' }
|
||||||
s.source = { :path => '.' }
|
s.source = { :path => '.' }
|
||||||
s.source_files = 'Classes/*', 'src/*', 'src/ios/*', 'src/shaders/*.c', 'src/shaders/*.h', 'include/filament/*', 'include/*', 'include/material/*.c'
|
s.source_files = 'Classes/*', 'src/*', 'src/ios/*', 'src/shaders/*.c', 'src/shaders/*.h', 'include/filament/*', 'include/*', 'include/material/*.c'
|
||||||
s.public_header_files = 'include/SwiftPolyvoxFilamentPlugin-Bridging-Header.h', 'include/PolyvoxFilamentIOSApi.h', 'include/PolyvoxFilamentApi.h', 'include/ResourceBuffer.hpp' #, 'include/filament/*'
|
s.public_header_files = 'include/SwiftPolyvoxFilamentPlugin-Bridging-Header.h', 'include/PolyvoxFilamentApi.h', 'include/ResourceBuffer.hpp' #, 'include/filament/*'
|
||||||
# s.header_mappings_dir = 'include'
|
# s.header_mappings_dir = 'include'
|
||||||
s.dependency 'Flutter'
|
s.dependency 'Flutter'
|
||||||
s.platform = :ios, '12.1'
|
s.platform = :ios, '12.1'
|
||||||
@@ -28,7 +28,7 @@ A new flutter plugin project.
|
|||||||
'OTHER_CFLAGS' => '"-fvisibility=default" "$(inherited)"',
|
'OTHER_CFLAGS' => '"-fvisibility=default" "$(inherited)"',
|
||||||
'USER_HEADER_SEARCH_PATHS' => '"${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/include" "${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/src" "${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/src/image" "${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/src/shaders" "$(inherited)"',
|
'USER_HEADER_SEARCH_PATHS' => '"${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/include" "${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/src" "${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/src/image" "${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/src/shaders" "$(inherited)"',
|
||||||
'ALWAYS_SEARCH_USER_PATHS' => 'YES',
|
'ALWAYS_SEARCH_USER_PATHS' => 'YES',
|
||||||
"OTHER_LDFLAGS" => '-lfilament -lbackend -lfilameshio -lviewer -lfilamat -lgeometry -lutils -lfilabridge -lgltfio_core -lfilament-iblprefilter -limage -lcamutils -lgltfio_core -lfilaflat -ldracodec -libl -lktxreader -limageio -lpng -lpng16 -ltinyexr -lz -lstb -luberzlib -lsmol-v -luberarchive -lzstd -lstdc++',
|
"OTHER_LDFLAGS" => '-lfilament -lbackend -lfilameshio -lviewer -lfilamat -lgeometry -lutils -lfilabridge -lgltfio_core -lfilament-iblprefilter -limage -limageio -ltinyexr -lcamutils -lgltfio_core -lfilaflat -ldracodec -libl -lktxreader -lpng -lpng16 -lz -lstb -luberzlib -lsmol-v -luberarchive -lzstd -lstdc++',
|
||||||
'LIBRARY_SEARCH_PATHS' => '"${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/lib" "$(inherited)"',
|
'LIBRARY_SEARCH_PATHS' => '"${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/lib" "$(inherited)"',
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ A new flutter plugin project.
|
|||||||
'OTHER_CFLAGS' => '"-fvisibility=default" "$(inherited)"',
|
'OTHER_CFLAGS' => '"-fvisibility=default" "$(inherited)"',
|
||||||
'USER_HEADER_SEARCH_PATHS' => '"${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/include" "${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/src" "${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/src/image" "${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/src/shaders" "$(inherited)"',
|
'USER_HEADER_SEARCH_PATHS' => '"${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/include" "${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/src" "${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/src/image" "${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/src/shaders" "$(inherited)"',
|
||||||
'ALWAYS_SEARCH_USER_PATHS' => 'YES',
|
'ALWAYS_SEARCH_USER_PATHS' => 'YES',
|
||||||
"OTHER_LDFLAGS" => '-lfilament -lbackend -lfilameshio -lviewer -lfilamat -lgeometry -lutils -lfilabridge -lgltfio_core -lfilament-iblprefilter -limage -lcamutils -lgltfio_core -lfilaflat -ldracodec -libl -lktxreader -limageio -lpng -lpng16 -ltinyexr -lz -lstb -luberzlib -lsmol-v -luberarchive -lzstd -lstdc++',
|
"OTHER_LDFLAGS" => '-lfilament -lbackend -lfilameshio -lviewer -lfilamat -lgeometry -lutils -lfilabridge -lgltfio_core -lfilament-iblprefilter -limage -limageio -ltinyexr -lcamutils -lgltfio_core -lfilaflat -ldracodec -libl -lktxreader -lpng -lpng16 -lz -lstb -luberzlib -lsmol-v -luberarchive -lzstd -lstdc++',
|
||||||
'LIBRARY_SEARCH_PATHS' => '"${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/lib" "$(inherited)"',
|
'LIBRARY_SEARCH_PATHS' => '"${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/lib" "$(inherited)"',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
#include "StreamBufferAdapter.hpp"
|
#include "StreamBufferAdapter.hpp"
|
||||||
#include "SceneAsset.hpp"
|
#include "SceneAsset.hpp"
|
||||||
#include "Log.hpp"
|
#include "Log.hpp"
|
||||||
#include "ResourceManagement.hpp"
|
|
||||||
#include "material/UnlitMaterialProvider.hpp"
|
#include "material/UnlitMaterialProvider.hpp"
|
||||||
#include "material/FileMaterialProvider.hpp"
|
#include "material/FileMaterialProvider.hpp"
|
||||||
#include "gltfio/materials/uberarchive.h"
|
#include "gltfio/materials/uberarchive.h"
|
||||||
@@ -36,13 +36,11 @@ using namespace utils;
|
|||||||
using namespace filament;
|
using namespace filament;
|
||||||
using namespace filament::gltfio;
|
using namespace filament::gltfio;
|
||||||
|
|
||||||
AssetManager::AssetManager(LoadResource loadResource,
|
AssetManager::AssetManager(ResourceLoaderWrapper* resourceLoaderWrapper,
|
||||||
FreeResource freeResource,
|
|
||||||
NameComponentManager *ncm,
|
NameComponentManager *ncm,
|
||||||
Engine *engine,
|
Engine *engine,
|
||||||
Scene *scene)
|
Scene *scene)
|
||||||
: _loadResource(loadResource),
|
: _resourceLoaderWrapper(resourceLoaderWrapper),
|
||||||
_freeResource(freeResource),
|
|
||||||
_ncm(ncm),
|
_ncm(ncm),
|
||||||
_engine(engine),
|
_engine(engine),
|
||||||
_scene(scene) {
|
_scene(scene) {
|
||||||
@@ -72,7 +70,7 @@ AssetManager::~AssetManager() {
|
|||||||
|
|
||||||
EntityId AssetManager::loadGltf(const char *uri,
|
EntityId AssetManager::loadGltf(const char *uri,
|
||||||
const char *relativeResourcePath) {
|
const char *relativeResourcePath) {
|
||||||
ResourceBuffer rbuf = _loadResource(uri);
|
ResourceBuffer rbuf = _resourceLoaderWrapper->load(uri);
|
||||||
|
|
||||||
// Parse the glTF file and create Filament entities.
|
// Parse the glTF file and create Filament entities.
|
||||||
FilamentAsset *asset =
|
FilamentAsset *asset =
|
||||||
@@ -89,11 +87,11 @@ EntityId AssetManager::loadGltf(const char *uri,
|
|||||||
for (size_t i = 0; i < resourceUriCount; i++) {
|
for (size_t i = 0; i < resourceUriCount; i++) {
|
||||||
string uri =
|
string uri =
|
||||||
string(relativeResourcePath) + string("/") + string(resourceUris[i]);
|
string(relativeResourcePath) + string("/") + string(resourceUris[i]);
|
||||||
ResourceBuffer buf = _loadResource(uri.c_str());
|
ResourceBuffer buf = _resourceLoaderWrapper->load(uri.c_str());
|
||||||
|
|
||||||
ResourceLoader::BufferDescriptor b(buf.data, buf.size);
|
ResourceLoader::BufferDescriptor b(buf.data, buf.size);
|
||||||
_gltfResourceLoader->addResourceData(resourceUris[i], std::move(b));
|
_gltfResourceLoader->addResourceData(resourceUris[i], std::move(b));
|
||||||
_freeResource(buf.id);
|
_resourceLoaderWrapper->free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
_gltfResourceLoader->loadResources(asset);
|
_gltfResourceLoader->loadResources(asset);
|
||||||
@@ -130,7 +128,7 @@ EntityId AssetManager::loadGlb(const char *uri, bool unlit) {
|
|||||||
|
|
||||||
Log("Loading GLB at URI %s", uri);
|
Log("Loading GLB at URI %s", uri);
|
||||||
|
|
||||||
ResourceBuffer rbuf = _loadResource(uri);
|
ResourceBuffer rbuf = _resourceLoaderWrapper->load(uri);
|
||||||
|
|
||||||
FilamentAsset *asset = _assetLoader->createAsset(
|
FilamentAsset *asset = _assetLoader->createAsset(
|
||||||
(const uint8_t *)rbuf.data, rbuf.size);
|
(const uint8_t *)rbuf.data, rbuf.size);
|
||||||
@@ -172,7 +170,7 @@ EntityId AssetManager::loadGlb(const char *uri, bool unlit) {
|
|||||||
|
|
||||||
asset->releaseSourceData();
|
asset->releaseSourceData();
|
||||||
|
|
||||||
_freeResource(rbuf.id);
|
_resourceLoaderWrapper->free(rbuf);
|
||||||
|
|
||||||
SceneAsset sceneAsset(asset);
|
SceneAsset sceneAsset(asset);
|
||||||
|
|
||||||
@@ -567,7 +565,7 @@ void AssetManager::loadTexture(EntityId entity, const char* resourcePath, int re
|
|||||||
asset.mTexture = nullptr;
|
asset.mTexture = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceBuffer imageResource = _loadResource(rp.c_str());
|
ResourceBuffer imageResource = _resourceLoaderWrapper->load(rp.c_str());
|
||||||
|
|
||||||
StreamBufferAdapter sb((char *)imageResource.data, (char *)imageResource.data + imageResource.size);
|
StreamBufferAdapter sb((char *)imageResource.data, (char *)imageResource.data + imageResource.size);
|
||||||
|
|
||||||
@@ -579,7 +577,7 @@ void AssetManager::loadTexture(EntityId entity, const char* resourcePath, int re
|
|||||||
if (!image->isValid()) {
|
if (!image->isValid()) {
|
||||||
Log("Invalid image : %s", rp.c_str());
|
Log("Invalid image : %s", rp.c_str());
|
||||||
delete inputStream;
|
delete inputStream;
|
||||||
_freeResource(imageResource.id);
|
_resourceLoaderWrapper->free(imageResource);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -615,7 +613,7 @@ void AssetManager::loadTexture(EntityId entity, const char* resourcePath, int re
|
|||||||
inst[0]->setParameter("baseColorMap",asset.mTexture,sampler);
|
inst[0]->setParameter("baseColorMap",asset.mTexture,sampler);
|
||||||
delete inputStream;
|
delete inputStream;
|
||||||
|
|
||||||
_freeResource(imageResource.id);
|
_resourceLoaderWrapper->free(imageResource);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -107,9 +107,8 @@ static constexpr float4 sFullScreenTriangleVertices[3] = {
|
|||||||
|
|
||||||
static const uint16_t sFullScreenTriangleIndices[3] = {0, 1, 2};
|
static const uint16_t sFullScreenTriangleIndices[3] = {0, 1, 2};
|
||||||
|
|
||||||
FilamentViewer::FilamentViewer(void* context, LoadResource loadResource,
|
FilamentViewer::FilamentViewer(void* context, ResourceLoaderWrapper* resourceLoaderWrapper)
|
||||||
FreeResource freeResource)
|
: _resourceLoaderWrapper(resourceLoaderWrapper) {
|
||||||
: _loadResource(loadResource), _freeResource(freeResource) {
|
|
||||||
|
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
_engine = Engine::create(Engine::Backend::METAL);
|
_engine = Engine::create(Engine::Backend::METAL);
|
||||||
@@ -179,7 +178,7 @@ FilamentViewer::FilamentViewer(void* context, LoadResource loadResource,
|
|||||||
|
|
||||||
_view->setAntiAliasing(AntiAliasing::NONE);
|
_view->setAntiAliasing(AntiAliasing::NONE);
|
||||||
|
|
||||||
// auto materialRb = _loadResource("file:///mnt/hdd_2tb/home/hydroxide/projects/filament/unlit.filamat");
|
// auto materialRb = _resourceLoader->load("file:///mnt/hdd_2tb/home/hydroxide/projects/filament/unlit.filamat");
|
||||||
// Log("Loaded resource of size %d", materialRb.size);
|
// Log("Loaded resource of size %d", materialRb.size);
|
||||||
// _materialProvider = new FileMaterialProvider(_engine, (void*) materialRb.data, (size_t)materialRb.size);
|
// _materialProvider = new FileMaterialProvider(_engine, (void*) materialRb.data, (size_t)materialRb.size);
|
||||||
|
|
||||||
@@ -188,8 +187,7 @@ FilamentViewer::FilamentViewer(void* context, LoadResource loadResource,
|
|||||||
_ncm = new NameComponentManager(em);
|
_ncm = new NameComponentManager(em);
|
||||||
|
|
||||||
_assetManager = new AssetManager(
|
_assetManager = new AssetManager(
|
||||||
_loadResource,
|
_resourceLoaderWrapper,
|
||||||
_freeResource,
|
|
||||||
_ncm,
|
_ncm,
|
||||||
_engine,
|
_engine,
|
||||||
_scene);
|
_scene);
|
||||||
@@ -371,7 +369,7 @@ void FilamentViewer::loadTextureFromPath(string path) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceBuffer rb = _loadResource(path.c_str());
|
ResourceBuffer rb = _resourceLoaderWrapper->load(path.c_str());
|
||||||
|
|
||||||
if(endsWith(path, ktxExt)) {
|
if(endsWith(path, ktxExt)) {
|
||||||
loadKtxTexture(path, rb);
|
loadKtxTexture(path, rb);
|
||||||
@@ -381,7 +379,7 @@ void FilamentViewer::loadTextureFromPath(string path) {
|
|||||||
loadPngTexture(path, rb);
|
loadPngTexture(path, rb);
|
||||||
}
|
}
|
||||||
|
|
||||||
_freeResource(rb.id);
|
_resourceLoaderWrapper->free(rb);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -697,7 +695,7 @@ void FilamentViewer::loadSkybox(const char *const skyboxPath) {
|
|||||||
removeSkybox();
|
removeSkybox();
|
||||||
|
|
||||||
if (skyboxPath) {
|
if (skyboxPath) {
|
||||||
ResourceBuffer skyboxBuffer = _loadResource(skyboxPath);
|
ResourceBuffer skyboxBuffer = _resourceLoaderWrapper->load(skyboxPath);
|
||||||
|
|
||||||
if(skyboxBuffer.size <= 0) {
|
if(skyboxBuffer.size <= 0) {
|
||||||
Log("Could not load skybox resource.");
|
Log("Could not load skybox resource.");
|
||||||
@@ -717,7 +715,7 @@ void FilamentViewer::loadSkybox(const char *const skyboxPath) {
|
|||||||
filament::Skybox::Builder().environment(_skyboxTexture).build(*_engine);
|
filament::Skybox::Builder().environment(_skyboxTexture).build(*_engine);
|
||||||
|
|
||||||
_scene->setSkybox(_skybox);
|
_scene->setSkybox(_skybox);
|
||||||
_freeResource(skyboxBuffer.id);
|
_resourceLoaderWrapper->free(skyboxBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -749,7 +747,7 @@ void FilamentViewer::loadIbl(const char *const iblPath, float intensity) {
|
|||||||
Log("Loading IBL from %s", iblPath);
|
Log("Loading IBL from %s", iblPath);
|
||||||
|
|
||||||
// Load IBL.
|
// Load IBL.
|
||||||
ResourceBuffer iblBuffer = _loadResource(iblPath);
|
ResourceBuffer iblBuffer = _resourceLoaderWrapper->load(iblPath);
|
||||||
|
|
||||||
if(iblBuffer.size == 0) {
|
if(iblBuffer.size == 0) {
|
||||||
Log("Error loading IBL, resource could not be loaded.");
|
Log("Error loading IBL, resource could not be loaded.");
|
||||||
@@ -773,7 +771,7 @@ void FilamentViewer::loadIbl(const char *const iblPath, float intensity) {
|
|||||||
.build(*_engine);
|
.build(*_engine);
|
||||||
_scene->setIndirectLight(_indirectLight);
|
_scene->setIndirectLight(_indirectLight);
|
||||||
|
|
||||||
_freeResource(iblBuffer.id);
|
_resourceLoaderWrapper->free(iblBuffer);
|
||||||
|
|
||||||
Log("Skybox/IBL load complete.");
|
Log("Skybox/IBL load complete.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,30 +4,40 @@
|
|||||||
#include "filament/LightManager.h"
|
#include "filament/LightManager.h"
|
||||||
#include "Log.hpp"
|
#include "Log.hpp"
|
||||||
#include "ThreadPool.hpp"
|
#include "ThreadPool.hpp"
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
using namespace polyvox;
|
using namespace polyvox;
|
||||||
|
|
||||||
#define FLUTTER_PLUGIN_EXPORT __attribute__((visibility("default")))
|
#define FLUTTER_PLUGIN_EXPORT __attribute__((visibility("default")))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// static ThreadPool* _tp;
|
// static ThreadPool* _tp;
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
#include "PolyvoxFilamentApi.h"
|
#include "PolyvoxFilamentApi.h"
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void* create_filament_viewer(void* context, ResourceBuffer (*loadResource)(char const*), void (*freeResource)(unsigned int)) {
|
FLUTTER_PLUGIN_EXPORT void* create_filament_viewer(void* context, ResourceLoaderWrapper* loader) {
|
||||||
// if(!_tp) {
|
// if(!_tp) {
|
||||||
// _tp = new ThreadPool();
|
// _tp = new ThreadPool();
|
||||||
// }
|
// }
|
||||||
// //std::packaged_task<void*()> lambda([=]() mutable {
|
// //std::packaged_task<void*()> lambda([=]() mutable {
|
||||||
return (void*) new FilamentViewer(context, loadResource, freeResource);
|
return (void*) new FilamentViewer(context, loader);
|
||||||
// });
|
// });
|
||||||
// auto fut = _tp->add_task(lambda);
|
// auto fut = _tp->add_task(lambda);
|
||||||
// fut.wait();
|
// fut.wait();
|
||||||
// //return fut.get();
|
// //return fut.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FLUTTER_PLUGIN_EXPORT ResourceLoaderWrapper* make_resource_loader(LoadResourceFromOwner loadFn, FreeResourceFromOwner freeFn, void* const owner) {
|
||||||
|
return new ResourceLoaderWrapper(loadFn, freeFn, owner);
|
||||||
|
// ResourceLoaderWrapper* lod(loadFn, freeFn, owner);
|
||||||
|
// return &lod;
|
||||||
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void create_render_target(void* viewer, uint32_t textureId, uint32_t width, uint32_t height) {
|
FLUTTER_PLUGIN_EXPORT void create_render_target(void* viewer, uint32_t textureId, uint32_t width, uint32_t height) {
|
||||||
// //std::packaged_task<void()> lambda([=]() mutable {
|
// //std::packaged_task<void()> lambda([=]() mutable {
|
||||||
((FilamentViewer*)viewer)->createRenderTarget(textureId, width, height);
|
((FilamentViewer*)viewer)->createRenderTarget(textureId, width, height);
|
||||||
@@ -535,5 +545,8 @@ extern "C" {
|
|||||||
// auto fut = _tp->add_task(lambda);
|
// auto fut = _tp->add_task(lambda);
|
||||||
// fut.wait();
|
// fut.wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FLUTTER_PLUGIN_EXPORT void ios_dummy() {
|
||||||
|
Log("Dummy called");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
#include "PolyvoxFilamentApi.h"
|
|
||||||
#include "FilamentViewer.hpp"
|
|
||||||
#include "ResourceBuffer.hpp"
|
|
||||||
#include "ResourceManagement.hpp"
|
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
using namespace polyvox;
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
using RawLoadType = ResourceBuffer(const char*, void* resource);
|
|
||||||
using RawFreeType = void(uint32_t, void*);
|
|
||||||
|
|
||||||
void* create_filament_viewer_ios(void* pb, void* loadResource, void* freeResource, void* resources) {
|
|
||||||
|
|
||||||
FreeResource _freeResource = [=](uint32_t rid) {
|
|
||||||
reinterpret_cast<RawFreeType*>(freeResource)(rid, resources);
|
|
||||||
};
|
|
||||||
|
|
||||||
function<ResourceBuffer(const char*)> _loadResource = [=](const char* uri){
|
|
||||||
auto cast = reinterpret_cast<RawLoadType*>(loadResource);
|
|
||||||
return cast(uri, resources);
|
|
||||||
};
|
|
||||||
|
|
||||||
auto viewer = new FilamentViewer(pb,_loadResource, _freeResource);
|
|
||||||
|
|
||||||
return (void*)viewer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -71,7 +71,6 @@ class FilamentController {
|
|||||||
|
|
||||||
Future setRendering(bool render) async {
|
Future setRendering(bool render) async {
|
||||||
_rendering = render;
|
_rendering = render;
|
||||||
_channel.invokeMethod("setRendering", render);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void render() {
|
void render() {
|
||||||
@@ -91,6 +90,7 @@ class FilamentController {
|
|||||||
_textureId =
|
_textureId =
|
||||||
await _channel.invokeMethod("createTexture", [size.width, size.height]);
|
await _channel.invokeMethod("createTexture", [size.width, size.height]);
|
||||||
_textureIdController.add(_textureId);
|
_textureIdController.add(_textureId);
|
||||||
|
print("Got texture id $_textureId");
|
||||||
|
|
||||||
var glContext =
|
var glContext =
|
||||||
Pointer<Void>.fromAddress(await _channel.invokeMethod("getContext"));
|
Pointer<Void>.fromAddress(await _channel.invokeMethod("getContext"));
|
||||||
@@ -103,25 +103,30 @@ class FilamentController {
|
|||||||
await _channel.invokeMethod("getFreeResourceFn"));
|
await _channel.invokeMethod("getFreeResourceFn"));
|
||||||
_viewer = _nativeLibrary.create_filament_viewer(
|
_viewer = _nativeLibrary.create_filament_viewer(
|
||||||
glContext, loadResource, freeResource);
|
glContext, loadResource, freeResource);
|
||||||
// don't pass a surface to the SwapChain as we are effectively creating a headless SwapChain that will render into a RenderTarget associated with a texture
|
if (Platform.isLinux) {
|
||||||
_nativeLibrary.create_swap_chain(
|
// don't pass a surface to the SwapChain as we are effectively creating a headless SwapChain that will render into a RenderTarget associated with a texture
|
||||||
_viewer, nullptr, size.width.toInt(), size.height.toInt());
|
_nativeLibrary.create_swap_chain(
|
||||||
|
_viewer, nullptr, size.width.toInt(), size.height.toInt());
|
||||||
|
|
||||||
var glTextureId = await _channel.invokeMethod("getGlTextureId");
|
var glTextureId = await _channel.invokeMethod("getGlTextureId");
|
||||||
|
|
||||||
|
_nativeLibrary.create_render_target(
|
||||||
|
_viewer, glTextureId, size.width.toInt(), size.height.toInt());
|
||||||
|
} else {
|
||||||
|
var surface =
|
||||||
|
Pointer<Void>.fromAddress(await _channel.invokeMethod("getSurface"));
|
||||||
|
_nativeLibrary.create_swap_chain(
|
||||||
|
_viewer, surface, size.width.toInt(), size.height.toInt());
|
||||||
|
}
|
||||||
|
|
||||||
_nativeLibrary.create_render_target(
|
|
||||||
_viewer, glTextureId, size.width.toInt(), size.height.toInt());
|
|
||||||
_nativeLibrary.update_viewport_and_camera_projection(
|
_nativeLibrary.update_viewport_and_camera_projection(
|
||||||
_viewer, size.width.toInt(), size.height.toInt(), 1.0);
|
_viewer, size.width.toInt(), size.height.toInt(), 1.0);
|
||||||
|
|
||||||
_initialized.complete(true);
|
_initialized.complete(true);
|
||||||
_assetManager = _nativeLibrary.get_asset_manager(_viewer);
|
_assetManager = _nativeLibrary.get_asset_manager(_viewer);
|
||||||
|
|
||||||
// await _channel.invokeMethod("setRenderTicker", _viewer.address);
|
|
||||||
|
|
||||||
_ticker = _tickerProvider.createTicker((elapsed) async {
|
_ticker = _tickerProvider.createTicker((elapsed) async {
|
||||||
_nativeLibrary.render(_viewer, 0);
|
_nativeLibrary.render(_viewer, 0);
|
||||||
await _channel.invokeMethod("tick");
|
|
||||||
});
|
});
|
||||||
_ticker!.start();
|
_ticker!.start();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user