Turn off reflection and shadow in simulate when a GPU is not present.
Note that The GLFW adapter currently assumes that a GPU is always present, so this new code path is never reached at the moment. PiperOrigin-RevId: 504617048 Change-Id: I04a323c33d9cff73686d39e4a6676ca6a4484c98
This commit is contained in:
committed by
Copybara-Service
parent
cd99fbd59d
commit
4b4ee27f64
@@ -129,6 +129,10 @@ std::pair<int, int> GlfwAdapter::GetWindowSize() const {
|
|||||||
return {width, height};
|
return {width, height};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GlfwAdapter::IsGPUAccelerated() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void GlfwAdapter::PollEvents() {
|
void GlfwAdapter::PollEvents() {
|
||||||
Glfw().glfwPollEvents();
|
Glfw().glfwPollEvents();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ class GlfwAdapter : public PlatformUIAdapter {
|
|||||||
double GetDisplayPixelsPerInch() const override;
|
double GetDisplayPixelsPerInch() const override;
|
||||||
std::pair<int, int> GetFramebufferSize() const override;
|
std::pair<int, int> GetFramebufferSize() const override;
|
||||||
std::pair<int, int> GetWindowSize() const override;
|
std::pair<int, int> GetWindowSize() const override;
|
||||||
|
bool IsGPUAccelerated() const override;
|
||||||
void PollEvents() override;
|
void PollEvents() override;
|
||||||
void SetClipboardString(const char* text) override;
|
void SetClipboardString(const char* text) override;
|
||||||
void SetVSync(bool enabled) override;
|
void SetVSync(bool enabled) override;
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ class PlatformUIAdapter {
|
|||||||
virtual double GetDisplayPixelsPerInch() const = 0;
|
virtual double GetDisplayPixelsPerInch() const = 0;
|
||||||
virtual std::pair<int, int> GetFramebufferSize() const = 0;
|
virtual std::pair<int, int> GetFramebufferSize() const = 0;
|
||||||
virtual std::pair<int, int> GetWindowSize() const = 0;
|
virtual std::pair<int, int> GetWindowSize() const = 0;
|
||||||
|
virtual bool IsGPUAccelerated() const = 0;
|
||||||
virtual void PollEvents() = 0;
|
virtual void PollEvents() = 0;
|
||||||
virtual void SetClipboardString(const char* text) = 0;
|
virtual void SetClipboardString(const char* text) = 0;
|
||||||
virtual void SetVSync(bool enabled) = 0;
|
virtual void SetVSync(bool enabled) = 0;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "lodepng.h"
|
#include "lodepng.h"
|
||||||
|
#include <mujoco/mjvisualize.h>
|
||||||
#include <mujoco/mjxmacro.h>
|
#include <mujoco/mjxmacro.h>
|
||||||
#include <mujoco/mujoco.h>
|
#include <mujoco/mujoco.h>
|
||||||
#include "platform_ui_adapter.h"
|
#include "platform_ui_adapter.h"
|
||||||
@@ -1606,6 +1607,11 @@ void Simulate::loadmodel() {
|
|||||||
mjv_makeScene(this->m, &this->scn, maxgeom);
|
mjv_makeScene(this->m, &this->scn, maxgeom);
|
||||||
this->platform_ui->RefreshMjrContext(this->m, 50*(this->font+1));
|
this->platform_ui->RefreshMjrContext(this->m, 50*(this->font+1));
|
||||||
|
|
||||||
|
if (!this->platform_ui->IsGPUAccelerated()) {
|
||||||
|
this->scn.flags[mjRND_SHADOW] = 0;
|
||||||
|
this->scn.flags[mjRND_REFLECTION] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// clear perturbation state
|
// clear perturbation state
|
||||||
this->pert.active = 0;
|
this->pert.active = 0;
|
||||||
this->pert.select = 0;
|
this->pert.select = 0;
|
||||||
@@ -1896,6 +1902,10 @@ void Simulate::renderloop() {
|
|||||||
// make empty scene
|
// make empty scene
|
||||||
mjv_defaultScene(&this->scn);
|
mjv_defaultScene(&this->scn);
|
||||||
mjv_makeScene(nullptr, &this->scn, maxgeom);
|
mjv_makeScene(nullptr, &this->scn, maxgeom);
|
||||||
|
if (!this->platform_ui->IsGPUAccelerated()) {
|
||||||
|
this->scn.flags[mjRND_SHADOW] = 0;
|
||||||
|
this->scn.flags[mjRND_REFLECTION] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// select default font
|
// select default font
|
||||||
int fontscale = ComputeFontScale(*this->platform_ui);
|
int fontscale = ComputeFontScale(*this->platform_ui);
|
||||||
|
|||||||
Reference in New Issue
Block a user