update web api for dart
This commit is contained in:
@@ -51,8 +51,6 @@ using emscripten::val;
|
|||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
|
|
||||||
extern void loadFlutterAsset(const char* path, void* context);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Since are using -sMAIN_MODULE with -sPTHREAD_POOL_SIZE=1, main will be called when the first worker is spawned
|
// Since are using -sMAIN_MODULE with -sPTHREAD_POOL_SIZE=1, main will be called when the first worker is spawned
|
||||||
//
|
//
|
||||||
@@ -124,11 +122,11 @@ extern "C"
|
|||||||
attr.depth = EM_TRUE;
|
attr.depth = EM_TRUE;
|
||||||
attr.stencil = EM_FALSE;
|
attr.stencil = EM_FALSE;
|
||||||
attr.antialias = EM_FALSE;
|
attr.antialias = EM_FALSE;
|
||||||
attr.explicitSwapControl = EM_FALSE;
|
attr.explicitSwapControl = EM_TRUE;
|
||||||
attr.preserveDrawingBuffer = EM_FALSE;
|
attr.preserveDrawingBuffer = EM_FALSE;
|
||||||
attr.proxyContextToMainThread = EMSCRIPTEN_WEBGL_CONTEXT_PROXY_ALWAYS;
|
attr.proxyContextToMainThread = EMSCRIPTEN_WEBGL_CONTEXT_PROXY_ALWAYS;
|
||||||
attr.enableExtensionsByDefault = EM_TRUE;
|
attr.enableExtensionsByDefault = EM_TRUE;
|
||||||
attr.renderViaOffscreenBackBuffer = EM_TRUE;
|
attr.renderViaOffscreenBackBuffer = EM_FALSE;
|
||||||
attr.majorVersion = 2;
|
attr.majorVersion = 2;
|
||||||
|
|
||||||
auto context = emscripten_webgl_create_context("#canvas", &attr);
|
auto context = emscripten_webgl_create_context("#canvas", &attr);
|
||||||
@@ -137,6 +135,11 @@ extern "C"
|
|||||||
auto success = emscripten_webgl_make_context_current((EMSCRIPTEN_WEBGL_CONTEXT_HANDLE)context);
|
auto success = emscripten_webgl_make_context_current((EMSCRIPTEN_WEBGL_CONTEXT_HANDLE)context);
|
||||||
if(success != EMSCRIPTEN_RESULT_SUCCESS) {
|
if(success != EMSCRIPTEN_RESULT_SUCCESS) {
|
||||||
std::cout << "Failed to make WebGL context current"<< std::endl;
|
std::cout << "Failed to make WebGL context current"<< std::endl;
|
||||||
|
} else {
|
||||||
|
std::cout << "Made WebGL context current"<< std::endl;
|
||||||
|
glClearColor(1.0, 0.0, 0.0, 1.0);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
emscripten_webgl_commit_frame();
|
||||||
}
|
}
|
||||||
emscripten_webgl_make_context_current((EMSCRIPTEN_WEBGL_CONTEXT_HANDLE)NULL);
|
emscripten_webgl_make_context_current((EMSCRIPTEN_WEBGL_CONTEXT_HANDLE)NULL);
|
||||||
return context;
|
return context;
|
||||||
@@ -174,11 +177,11 @@ extern "C"
|
|||||||
// attr.attributes = EMSCRIPTEN_FETCH_LOAD_TO_MEMORY | EMSCRIPTEN_FETCH_SYNCHRONOUS | EMSCRIPTEN_FETCH_PERSIST_FILE;
|
// attr.attributes = EMSCRIPTEN_FETCH_LOAD_TO_MEMORY | EMSCRIPTEN_FETCH_SYNCHRONOUS | EMSCRIPTEN_FETCH_PERSIST_FILE;
|
||||||
|
|
||||||
auto pathString = std::string(path);
|
auto pathString = std::string(path);
|
||||||
if(pathString.rfind("https://",0) != 0) {
|
// if(pathString.rfind("https://",0) != 0) {
|
||||||
pathString = std::string("../../") + pathString;
|
// pathString = std::string("../../") + pathString;
|
||||||
}
|
// }
|
||||||
|
|
||||||
std::cout << "Fetching from path " << pathString.c_str() << std::endl;
|
// std::cout << "Fetching from path " << pathString.c_str() << std::endl;
|
||||||
|
|
||||||
// auto request = emscripten_fetch(&attr, pathString.c_str());
|
// auto request = emscripten_fetch(&attr, pathString.c_str());
|
||||||
// if(!request) {
|
// if(!request) {
|
||||||
@@ -200,7 +203,6 @@ extern "C"
|
|||||||
free(pBuffer);
|
free(pBuffer);
|
||||||
free(pNum);
|
free(pNum);
|
||||||
free(pError);
|
free(pError);
|
||||||
|
|
||||||
return ResourceBuffer { data, numBytes, _lastResourceId } ;
|
return ResourceBuffer { data, numBytes, _lastResourceId } ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,7 +217,10 @@ extern "C"
|
|||||||
EMSCRIPTEN_KEEPALIVE void* flutter_filament_web_get_resource_loader_wrapper() {
|
EMSCRIPTEN_KEEPALIVE void* flutter_filament_web_get_resource_loader_wrapper() {
|
||||||
ResourceLoaderWrapper *rlw = (ResourceLoaderWrapper *)malloc(sizeof(ResourceLoaderWrapper));
|
ResourceLoaderWrapper *rlw = (ResourceLoaderWrapper *)malloc(sizeof(ResourceLoaderWrapper));
|
||||||
rlw->loadResource = flutter_filament_web_load_resource;
|
rlw->loadResource = flutter_filament_web_load_resource;
|
||||||
|
rlw->loadFromOwner = nullptr;
|
||||||
rlw->freeResource = flutter_filament_web_free_resource;
|
rlw->freeResource = flutter_filament_web_free_resource;
|
||||||
|
rlw->freeFromOwner = nullptr;
|
||||||
|
rlw->loadToOut = nullptr;
|
||||||
rlw->owner = nullptr;
|
rlw->owner = nullptr;
|
||||||
return rlw;
|
return rlw;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user