add create_swap_chain/new viewer creation API bindings to iOS
This commit is contained in:
@@ -119,11 +119,6 @@ public class SwiftPolyvoxFilamentPlugin: NSObject, FlutterPlugin, FlutterTexture
|
|||||||
kCVPixelFormatType_32BGRA, pixelBufferAttrs, &targetPixelBuffer) != kCVReturnSuccess) {
|
kCVPixelFormatType_32BGRA, pixelBufferAttrs, &targetPixelBuffer) != kCVReturnSuccess) {
|
||||||
print("Error allocating pixel buffer")
|
print("Error allocating pixel buffer")
|
||||||
}
|
}
|
||||||
if(self.viewer != nil) {
|
|
||||||
create_swap_chain(self.viewer, unsafeBitCast(targetPixelBuffer!, to: UnsafeMutableRawPointer.self))
|
|
||||||
update_viewport_and_camera_projection(self.viewer!, Int32(width), Int32(height), 1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
print("Pixel buffer created")
|
print("Pixel buffer created")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,12 +131,17 @@ public class SwiftPolyvoxFilamentPlugin: NSObject, FlutterPlugin, FlutterTexture
|
|||||||
freeResourcePtr = unsafeBitCast(freeResource, to: UnsafeMutableRawPointer.self)
|
freeResourcePtr = unsafeBitCast(freeResource, to: UnsafeMutableRawPointer.self)
|
||||||
|
|
||||||
viewer = filament_viewer_new_ios(
|
viewer = filament_viewer_new_ios(
|
||||||
unsafeBitCast(targetPixelBuffer!, to: UnsafeMutableRawPointer.self),
|
nil,
|
||||||
loadResourcePtr!,
|
loadResourcePtr!,
|
||||||
freeResourcePtr!,
|
freeResourcePtr!,
|
||||||
Unmanaged.passUnretained(self).toOpaque()
|
Unmanaged.passUnretained(self).toOpaque()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
create_swap_chain(
|
||||||
|
self.viewer,
|
||||||
|
unsafeBitCast(targetPixelBuffer!, to: UnsafeMutableRawPointer.self),
|
||||||
|
UInt32(width), UInt32(height))
|
||||||
|
|
||||||
update_viewport_and_camera_projection(self.viewer!, Int32(width), Int32(height), 1.0);
|
update_viewport_and_camera_projection(self.viewer!, Int32(width), Int32(height), 1.0);
|
||||||
|
|
||||||
createDisplayLink()
|
createDisplayLink()
|
||||||
@@ -285,6 +285,10 @@ public class SwiftPolyvoxFilamentPlugin: NSObject, FlutterPlugin, FlutterTexture
|
|||||||
let width = Int(args[0])
|
let width = Int(args[0])
|
||||||
let height = Int(args[1])
|
let height = Int(args[1])
|
||||||
createPixelBuffer(width: width, height:height)
|
createPixelBuffer(width: width, height:height)
|
||||||
|
create_swap_chain(
|
||||||
|
self.viewer,
|
||||||
|
unsafeBitCast(targetPixelBuffer!, to: UnsafeMutableRawPointer.self),
|
||||||
|
UInt32(width), UInt32(height))
|
||||||
result("OK")
|
result("OK")
|
||||||
case "rotateStart":
|
case "rotateStart":
|
||||||
let args = call.arguments as! Array<Any>
|
let args = call.arguments as! Array<Any>
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ void* load_glb(void* viewer, const char* assetPath);
|
|||||||
void* load_gltf(void* viewer, const char* assetPath, const char* relativePath);
|
void* load_gltf(void* viewer, const char* assetPath, const char* relativePath);
|
||||||
bool set_camera(void* viewer, void* asset, const char* nodeName);
|
bool set_camera(void* viewer, void* asset, const char* nodeName);
|
||||||
void render(void* viewer, uint64_t frameTimeInNanos);
|
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 create_swap_chain(void* viewer, void* surface, uint32_t width, uint32_t height);
|
||||||
void destroy_swap_chain(void* viewer);
|
void destroy_swap_chain(void* viewer);
|
||||||
void set_frame_interval(void* viewer, float interval);
|
void set_frame_interval(void* viewer, float interval);
|
||||||
void* get_renderer(void* viewer);
|
void* get_renderer(void* viewer);
|
||||||
|
|||||||
@@ -1,3 +1,2 @@
|
|||||||
void* filament_viewer_new_ios(void* texture, void* loadResource, void* freeResource, void* resources);
|
void* filament_viewer_new_ios(void* texture, void* loadResource, void* freeResource, void* resources);
|
||||||
void create_swap_chain(void* viewer, void* texture);
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef SwiftPolyvoxFilamentPlugin_Bridging_Header_h
|
#ifndef SwiftPolyvoxFilamentPlugin_Bridging_Header_h
|
||||||
#define SwiftPolyvoxFilamentPlugin_Bridging_Header_h
|
#define SwiftPolyvoxFilamentPlugin_Bridging_Header_h
|
||||||
|
|
||||||
void* filament_viewer_new_ios(void* texture, void* loadResource, void* freeResource, void* resources);
|
// void* filament_viewer_new_ios(void* texture, void* loadResource, void* freeResource, void* resources);
|
||||||
|
|
||||||
#import "PolyvoxFilamentIOSApi.h"
|
#import "PolyvoxFilamentIOSApi.h"
|
||||||
#import "PolyvoxFilamentApi.h"
|
#import "PolyvoxFilamentApi.h"
|
||||||
|
|||||||
@@ -26,7 +26,4 @@ extern "C" {
|
|||||||
|
|
||||||
return (void*)viewer;
|
return (void*)viewer;
|
||||||
}
|
}
|
||||||
void create_swap_chain(void* viewer, void* texture) {
|
|
||||||
((FilamentViewer*)viewer)->createSwapChain(texture);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user