Abstract out GLFW calls from Simulate.

PiperOrigin-RevId: 500129478
Change-Id: I7ba998e20439575ad9a3fe1a866c3db4c36b9328
This commit is contained in:
Saran Tunyasuvunakool
2023-01-06 02:36:01 -08:00
committed by Copybara-Service
parent 048bd43724
commit e40775fab3
15 changed files with 847 additions and 624 deletions
+8 -2
View File
@@ -14,8 +14,11 @@
#include <cstdint>
#include <cstring>
#include <memory>
#include <string>
#include <glfw_adapter.h>
#include <glfw_dispatch.h>
#include <simulate.h>
#include "structs.h"
#include <pybind11/pybind11.h>
@@ -38,7 +41,10 @@ PYBIND11_MODULE(_simulate, pymodule) {
py::call_guard<py::gil_scoped_release>());
py::class_<mujoco::Simulate>(pymodule, "Simulate")
.def(py::init<>())
.def(py::init([]() {
return std::make_unique<mujoco::Simulate>(
std::make_unique<mujoco::GlfwAdapter>());
}))
.def(
"renderloop",
[](mujoco::Simulate& simulate) { simulate.renderloop(); },
@@ -134,7 +140,7 @@ PYBIND11_MODULE(_simulate, pymodule) {
});
pymodule.def("setglfwdlhandle", [](std::uintptr_t dlhandle) {
mujoco::setglfwdlhandle(reinterpret_cast<void*>(dlhandle));
mujoco::Glfw(reinterpret_cast<void*>(dlhandle));
});
}