Remove initial width/height arguments.
The ValidateSwapChains function will correctly set up swap chains before any render calls, negating the need to have something done in the constructor. PiperOrigin-RevId: 928529339 Change-Id: Ie584d57f649730adc092f8683f18697892a5a14f
This commit is contained in:
committed by
Copybara-Service
parent
318880126f
commit
116cfe9c70
@@ -64,13 +64,8 @@ FilamentContext::FilamentContext(const mjrFilamentConfig* config)
|
||||
#else
|
||||
if (config_.native_window) {
|
||||
window_swap_chain_ = engine_->createSwapChain(config_.native_window);
|
||||
} else {
|
||||
window_swap_chain_ =
|
||||
engine_->createSwapChain(config_.width, config_.height);
|
||||
}
|
||||
#endif
|
||||
offscreen_swap_chain_ =
|
||||
engine_->createSwapChain(config_.width, config_.height);
|
||||
|
||||
object_manager_ = std::make_unique<ObjectManager>(engine_);
|
||||
material_manager_ = std::make_unique<MaterialManager>(object_manager_.get());
|
||||
@@ -240,13 +235,13 @@ void FilamentContext::ValidateSwapChains(
|
||||
}
|
||||
|
||||
if (max_offscreen_width && max_offscreen_height) {
|
||||
if (max_offscreen_width != config_.width ||
|
||||
max_offscreen_height != config_.height) {
|
||||
if (max_offscreen_width != offscreen_width_ ||
|
||||
max_offscreen_height != offscreen_height_) {
|
||||
engine_->destroy(offscreen_swap_chain_);
|
||||
config_.width = max_offscreen_width;
|
||||
config_.height = max_offscreen_height;
|
||||
offscreen_width_ = max_offscreen_width;
|
||||
offscreen_height_ = max_offscreen_height;
|
||||
offscreen_swap_chain_ =
|
||||
engine_->createSwapChain(config_.width, config_.height);
|
||||
engine_->createSwapChain(offscreen_width_, offscreen_height_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +83,8 @@ class FilamentContext : public mjrfContext {
|
||||
std::unique_ptr<MaterialManager> material_manager_;
|
||||
int window_width_ = 0;
|
||||
int window_height_ = 0;
|
||||
int offscreen_width_ = 0;
|
||||
int offscreen_height_ = 0;
|
||||
std::uint64_t frame_counter_ = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -190,9 +190,7 @@ void mjr_makeContext(const mjModel* m, mjrContext* con, int fontscale) {
|
||||
mjr_freeContext(con);
|
||||
|
||||
mjrFilamentConfig cfg;
|
||||
memset(&cfg, 0, sizeof(mjrFilamentConfig));
|
||||
cfg.width = m->vis.global.offwidth;
|
||||
cfg.height = m->vis.global.offheight;
|
||||
mjrf_defaultFilamentConfig(&cfg);
|
||||
mjr_makeFilamentContext(m, &cfg, con);
|
||||
}
|
||||
|
||||
|
||||
@@ -105,10 +105,6 @@ struct mjrFilamentConfig {
|
||||
// rendering will be done to an offscreen framebuffer.
|
||||
void* native_window;
|
||||
|
||||
// The initial width and height of the offscreen framebuffer.
|
||||
int width;
|
||||
int height;
|
||||
|
||||
// The backend graphics API to use.
|
||||
mjrGraphicsApi graphics_api;
|
||||
|
||||
|
||||
@@ -97,8 +97,6 @@ void Renderer::Init(const mjModel* model) {
|
||||
mjrFilamentConfig cfg;
|
||||
mjrf_defaultFilamentConfig(&cfg);
|
||||
cfg.native_window = native_window_;
|
||||
cfg.width = model->vis.global.offwidth;
|
||||
cfg.height = model->vis.global.offheight;
|
||||
cfg.force_software_rendering = IsSoftware(gfx_);
|
||||
cfg.graphics_api = IsOpenGl(gfx_) || IsWebGl(gfx_)
|
||||
? mjGRAPHICS_API_OPENGL
|
||||
|
||||
Reference in New Issue
Block a user