Restore "Add single-threaded config to Filament. (#130)"
This reverts commit 24022010f9.
This commit is contained in:
@@ -74,29 +74,27 @@ FilamentApp::~FilamentApp() {
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
void FilamentApp::run(const Config& config,SetupCallback setupCallback,
|
||||
void FilamentApp::run(const Config& config, SetupCallback setupCallback,
|
||||
CleanupCallback cleanupCallback, ImGuiCallback imguiCallback,
|
||||
PreRenderCallback preRender, PostRenderCallback postRender,
|
||||
size_t width, size_t height) {
|
||||
mEngine = Engine::create(config.backend);
|
||||
|
||||
mDepthMaterial = Material::Builder()
|
||||
.package((void*) DEPTH_VISUALIZER_PACKAGE, sizeof(DEPTH_VISUALIZER_PACKAGE))
|
||||
.build(*mEngine);
|
||||
|
||||
mDepthMI = mDepthMaterial->createInstance();
|
||||
|
||||
mTransparentMaterial = Material::Builder()
|
||||
.package((void*) TRANSPARENT_COLOR_PACKAGE, sizeof(TRANSPARENT_COLOR_PACKAGE))
|
||||
.build(*mEngine);
|
||||
|
||||
mDefaultMaterial = Material::Builder()
|
||||
.package((void*) AI_DEFAULT_MAT_PACKAGE, sizeof(AI_DEFAULT_MAT_PACKAGE))
|
||||
.build(*mEngine);
|
||||
|
||||
std::unique_ptr<FilamentApp::Window> window(
|
||||
new FilamentApp::Window(this, config, config.title, width, height));
|
||||
|
||||
mDepthMaterial = Material::Builder()
|
||||
.package((void*) DEPTH_VISUALIZER_PACKAGE, sizeof(DEPTH_VISUALIZER_PACKAGE))
|
||||
.build(*mEngine);
|
||||
|
||||
mDepthMI = mDepthMaterial->createInstance();
|
||||
|
||||
mDefaultMaterial = Material::Builder()
|
||||
.package((void*) AI_DEFAULT_MAT_PACKAGE, sizeof(AI_DEFAULT_MAT_PACKAGE))
|
||||
.build(*mEngine);
|
||||
|
||||
mTransparentMaterial = Material::Builder()
|
||||
.package((void*) TRANSPARENT_COLOR_PACKAGE, sizeof(TRANSPARENT_COLOR_PACKAGE))
|
||||
.build(*mEngine);
|
||||
|
||||
std::unique_ptr<Cube> cameraCube(new Cube(*mEngine, mTransparentMaterial, {1,0,0}));
|
||||
// we can't cull the light-frustum because it's not applied a rigid transform
|
||||
// and currently, filament assumes that for culling
|
||||
@@ -206,6 +204,10 @@ void FilamentApp::run(const Config& config,SetupCallback setupCallback,
|
||||
|
||||
while (!mClosed) {
|
||||
|
||||
if (!UTILS_HAS_THREADING) {
|
||||
mEngine->execute();
|
||||
}
|
||||
|
||||
// Allow the app to animate the scene if desired.
|
||||
if (mAnimation) {
|
||||
double now = (double) SDL_GetPerformanceCounter() / SDL_GetPerformanceFrequency();
|
||||
@@ -423,10 +425,14 @@ FilamentApp::Window::Window(FilamentApp* filamentApp,
|
||||
: mFilamentApp(filamentApp) {
|
||||
const int x = SDL_WINDOWPOS_CENTERED;
|
||||
const int y = SDL_WINDOWPOS_CENTERED;
|
||||
const uint32_t windowFlags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE
|
||||
| SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_OPENGL;
|
||||
const uint32_t windowFlags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI;
|
||||
mWindow = SDL_CreateWindow(title.c_str(), x, y, (int) w, (int) h, windowFlags);
|
||||
|
||||
// Create the Engine after the window in case this happens to be a single-threaded platform.
|
||||
// For single-threaded platforms, we need to ensure that Filament's OpenGL context is current,
|
||||
// rather than the one created by SDL.
|
||||
mFilamentApp->mEngine = Engine::create(config.backend);
|
||||
|
||||
// HACK: We don't use SDL's 2D rendering functionality, but by invoking it we cause
|
||||
// SDL to create a Metal backing layer, which allows us to run Vulkan apps via MoltenVK.
|
||||
#if defined(FILAMENT_DRIVER_SUPPORTS_VULKAN) && defined(__APPLE__)
|
||||
|
||||
Reference in New Issue
Block a user