Flutter/Android - create local copy of headers

This commit is contained in:
Nick Fisher
2024-06-17 11:30:03 +08:00
parent 5e5e81a107
commit 14c87e7b38
4 changed files with 50 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.10)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../thermion_dart/native/include)
include_directories(src/main/include)
include_directories(src/main/cpp)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
set(ANDROID_STL c++_shared)

View File

@@ -1,9 +1,12 @@
#include <android/native_window_jni.h>
#include <android/native_activity.h>
#include "ThermionDartFFIApi.h"
#include "ResourceBuffer.h"
extern "C" {
typedef void (*FilamentRenderCallback)(void *const owner);
void* get_native_window_from_surface(
jobject surface,
JNIEnv* env

View File

@@ -0,0 +1,44 @@
#ifndef RESOURCE_BUFFER_H
#define RESOURCE_BUFFER_H
#include <stdint.h>
#include <stdlib.h>
//
// A ResourceBuffer is a unified interface for working with
// binary assets across various platforms.
// This is simply:
// 1) a pointer to some data
// 2) the length of the data
// 3) an ID that can be passed back to the native platform to release the underlying asset when needed.
//
typedef struct ResourceBuffer
{
const void *const data;
const int32_t size;
const int32_t id;
#if defined(__cplusplus)
ResourceBuffer(void *const data, int32_t size, int32_t id) : data(data), size(size), id(id) {}
#endif
} ResourceBuffer;
typedef void (*LoadFilamentResourceIntoOutPointer)(const char *uri, ResourceBuffer *out);
typedef ResourceBuffer (*LoadFilamentResource)(const char *uri);
typedef ResourceBuffer (*LoadFilamentResourceFromOwner)(const char *const, void *const owner);
typedef void (*FreeFilamentResource)(ResourceBuffer);
typedef void (*FreeFilamentResourceFromOwner)(ResourceBuffer, void *const owner);
typedef struct ResourceLoaderWrapper
{
LoadFilamentResource loadResource;
FreeFilamentResource freeResource;
LoadFilamentResourceFromOwner loadFromOwner;
FreeFilamentResourceFromOwner freeFromOwner;
void *owner;
LoadFilamentResourceIntoOutPointer loadToOut;
} ResourceLoaderWrapper;
void *make_resource_loader(LoadFilamentResourceFromOwner loadFn, FreeFilamentResourceFromOwner freeFn, void *const owner);
#endif

View File

@@ -1,6 +1,6 @@
name: thermion_flutter
description: Flutter plugin for 3D rendering with the Thermion toolkit.
version: 0.0.2
version: 0.0.3
homepage: https://docs.page/nmfisher/thermion
repository: https://github.com/nmfisher/thermion