Skip to content

Commit

Permalink
Merge pull request #964 from gazebosim/port/8_to_main
Browse files Browse the repository at this point in the history
port: 8 to 9
  • Loading branch information
iche033 authored Jan 23, 2024
2 parents 6cc16a0 + e77e044 commit 9902506
Show file tree
Hide file tree
Showing 31 changed files with 139 additions and 53 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

Build | Status
-- | --
Test coverage | [![codecov](https://codecov.io/gh/gazebosim/gz-rendering/branch/main/graph/badge.svg)](https://codecov.io/gh/gazebosim/gz-rendering/branch/default)
Test coverage | [![codecov](https://codecov.io/gh/gazebosim/gz-rendering/tree/main/graph/badge.svg)](https://codecov.io/gh/gazebosim/gz-rendering/tree/main)
Ubuntu Jammy | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_rendering-ci-main-jammy-amd64)](https://build.osrfoundation.org/job/gz_rendering-ci-main-jammy-amd64)
Homebrew | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=ignition_rendering-ci-main-homebrew-amd64)](https://build.osrfoundation.org/job/ignition_rendering-ci-main-homebrew-amd64)
Windows | [![Build Status](https://build.osrfoundation.org/job/ign_rendering-ci-win/badge/icon)](https://build.osrfoundation.org/job/ign_rendering-ci-win/)
Homebrew | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_rendering-ci-main-homebrew-amd64)](https://build.osrfoundation.org/job/gz_rendering-ci-main-homebrew-amd64)
Windows | [![Build Status](https://build.osrfoundation.org/job/gz_rendering-main-win/badge/icon)](https://build.osrfoundation.org/job/gz_rendering-main-win/)

Gazebo Rendering is a C++ library designed to provide an abstraction
for different rendering engines. It offers unified APIs for creating
Expand Down
2 changes: 1 addition & 1 deletion examples/actor_animation/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ int main(int _argc, char** _argv)
ogreEngineName = _argv[1];
}

GraphicsAPI graphicsApi = GraphicsAPI::OPENGL;
GraphicsAPI graphicsApi = defaultGraphicsAPI();
if (_argc > 2)
{
graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2]));
Expand Down
18 changes: 16 additions & 2 deletions examples/boundingbox_camera/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,11 @@ void buildScene(ScenePtr _scene, BoundingBoxType _type)

//////////////////////////////////////////////////
std::vector<CameraPtr> createCameras(const std::string &_engineName,
const std::map<std::string, std::string>& _params,
BoundingBoxType _type)
{
// create and populate scene
RenderEngine *engine = rendering::engine(_engineName);
RenderEngine *engine = rendering::engine(_engineName, _params);
if (!engine)
{
gzwarn << "Engine '" << _engineName
Expand Down Expand Up @@ -271,6 +272,12 @@ int main(int _argc, char** _argv)
}
}

GraphicsAPI graphicsApi = defaultGraphicsAPI();
if (_argc > 2)
{
graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2]));
}

common::Console::SetVerbosity(4);
std::vector<std::string> engineNames;
std::vector<CameraPtr> cameras;
Expand All @@ -281,7 +288,14 @@ int main(int _argc, char** _argv)
{
try
{
cameras = createCameras(engineName, bboxType);
std::map<std::string, std::string> params;
if (engineName.compare("ogre2") == 0
&& graphicsApi == GraphicsAPI::METAL)
{
params["metal"] = "1";
}

cameras = createCameras(engineName, params, bboxType);
}
catch (...)
{
Expand Down
2 changes: 1 addition & 1 deletion examples/camera_tracking/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ int main(int _argc, char** _argv)
ogreEngineName = _argv[1];
}

GraphicsAPI graphicsApi = GraphicsAPI::OPENGL;
GraphicsAPI graphicsApi = defaultGraphicsAPI();
if (_argc > 2)
{
graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2]));
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_scene_viewer/ManualSceneDemo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ int main(int _argc, char** _argv)
ogreEngineName = _argv[1];
}

GraphicsAPI graphicsApi = GraphicsAPI::OPENGL;
GraphicsAPI graphicsApi = defaultGraphicsAPI();
if (_argc > 2)
{
graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2]));
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_shaders_uniforms/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ int main(int _argc, char** _argv)
ogreEngineName = _argv[1];
}

GraphicsAPI graphicsApi = GraphicsAPI::OPENGL;
GraphicsAPI graphicsApi = defaultGraphicsAPI();
if (_argc > 2)
{
graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2]));
Expand Down
4 changes: 2 additions & 2 deletions examples/depth_camera/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void buildScene(ScenePtr _scene)
camera->SetImageFormat(PixelFormat::PF_FLOAT32_RGBA);
camera->SetNearClipPlane(0.15);
camera->SetFarClipPlane(10.0);
camera->SetAntiAliasing(2);
camera->SetAntiAliasing(2);
camera->CreateDepthTexture();

root->AddChild(camera);
Expand Down Expand Up @@ -154,7 +154,7 @@ int main(int _argc, char** _argv)
engineName = _argv[1];
}

GraphicsAPI graphicsApi = GraphicsAPI::OPENGL;
GraphicsAPI graphicsApi = defaultGraphicsAPI();
if (_argc > 2)
{
graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2]));
Expand Down
2 changes: 1 addition & 1 deletion examples/heightmap/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ int main(int _argc, char** _argv)
ogreEngineName = _argv[1];
}

GraphicsAPI graphicsApi = GraphicsAPI::OPENGL;
GraphicsAPI graphicsApi = defaultGraphicsAPI();
if (_argc > 2 && buildDemScene != 2)
{
graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2]));
Expand Down
2 changes: 1 addition & 1 deletion examples/lidar_visual/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ int main(int _argc, char** _argv)
ogreEngineName = _argv[1];
}

GraphicsAPI graphicsApi = GraphicsAPI::OPENGL;
GraphicsAPI graphicsApi = defaultGraphicsAPI();
if (_argc > 2)
{
graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2]));
Expand Down
2 changes: 1 addition & 1 deletion examples/mesh_viewer/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ int main(int _argc, char** _argv)
ogreEngineName = _argv[1];
}

GraphicsAPI graphicsApi = GraphicsAPI::OPENGL;
GraphicsAPI graphicsApi = defaultGraphicsAPI();
if (_argc > 2)
{
graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2]));
Expand Down
2 changes: 1 addition & 1 deletion examples/mouse_picking/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ int main(int _argc, char** _argv)
ogreEngineName = _argv[1];
}

GraphicsAPI graphicsApi = GraphicsAPI::OPENGL;
GraphicsAPI graphicsApi = defaultGraphicsAPI();
if (_argc > 2)
{
graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2]));
Expand Down
2 changes: 1 addition & 1 deletion examples/ogre2_demo/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ int main(int _argc, char** _argv)
std::vector<std::string> engineNames;
std::vector<CameraPtr> cameras;

GraphicsAPI graphicsApi = GraphicsAPI::OPENGL;
GraphicsAPI graphicsApi = defaultGraphicsAPI();
if (_argc > 2)
{
graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2]));
Expand Down
2 changes: 1 addition & 1 deletion examples/particles_demo/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ int main(int _argc, char** _argv)
ogreEngineName = _argv[1];
}

GraphicsAPI graphicsApi = GraphicsAPI::OPENGL;
GraphicsAPI graphicsApi = defaultGraphicsAPI();
if (_argc > 2)
{
graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2]));
Expand Down
2 changes: 1 addition & 1 deletion examples/projector/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ int main(int _argc, char** _argv)
ogreEngineName = _argv[1];
}

GraphicsAPI graphicsApi = GraphicsAPI::OPENGL;
GraphicsAPI graphicsApi = defaultGraphicsAPI();
if (_argc > 2)
{
graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2]));
Expand Down
2 changes: 1 addition & 1 deletion examples/render_pass/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ int main(int _argc, char** _argv)
ogreEngineName = _argv[1];
}

GraphicsAPI graphicsApi = GraphicsAPI::OPENGL;
GraphicsAPI graphicsApi = defaultGraphicsAPI();
if (_argc > 2)
{
graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2]));
Expand Down
2 changes: 1 addition & 1 deletion examples/segmentation_camera/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ int main(int _argc, char** _argv)
engineName = _argv[1];
}

GraphicsAPI graphicsApi = GraphicsAPI::OPENGL;
GraphicsAPI graphicsApi = defaultGraphicsAPI();
if (_argc > 2)
{
graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2]));
Expand Down
2 changes: 1 addition & 1 deletion examples/simple_demo/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ int main(int _argc, char** _argv)
ogreEngineName = _argv[1];
}

GraphicsAPI graphicsApi = GraphicsAPI::OPENGL;
GraphicsAPI graphicsApi = defaultGraphicsAPI();
if (_argc > 2)
{
graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2]));
Expand Down
46 changes: 39 additions & 7 deletions examples/simple_demo_qml/ThreadRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void RenderThread::Print(const QSurfaceFormat &_format)
return "CompatibilityProfile";
default:
return "Invalid OpenGLContextProfile";
}
}
};

auto renderableTypeToString = [] (QSurfaceFormat::RenderableType _value) -> std::string
Expand All @@ -146,7 +146,7 @@ void RenderThread::Print(const QSurfaceFormat &_format)
return "OpenVG";
default:
return "Invalid RenderableType";
}
}
};

auto swapBehaviorToString = [] (QSurfaceFormat::SwapBehavior _value) -> std::string
Expand All @@ -161,7 +161,7 @@ void RenderThread::Print(const QSurfaceFormat &_format)
return "DoubleBuffer";
default:
return "Invalid SwapBehavior";
}
}
};

// surface format info
Expand Down Expand Up @@ -200,7 +200,7 @@ QSurfaceFormat RenderThread::CreateSurfaceFormat()
format.setProfile(QSurfaceFormat::CoreProfile);
format.setRenderableType(QSurfaceFormat::OpenGL);

return format;
return format;
}

//--------------------------------------------------------------------------
Expand Down Expand Up @@ -272,8 +272,25 @@ TextureNode::TextureNode(QQuickWindow *_window)
, window(_window)
{
// Our texture node must have a texture, so use the default 0 texture.
// createTextureFromNativeObject()
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
# ifndef _WIN32
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
# endif
this->texture = this->window->createTextureFromId(0, QSize(1, 1));
# ifndef _WIN32
# pragma GCC diagnostic pop
# endif
#else
int texId = 0;
this->texture =
this->window->createTextureFromNativeObject(
QQuickWindow::NativeObjectTexture,
static_cast<void *>(&texId),
0,
QSize(1, 1));
#endif

this->setTexture(this->texture);
this->setFiltering(QSGTexture::Linear);
}
Expand Down Expand Up @@ -314,8 +331,23 @@ void TextureNode::PrepareNode()
this->texture = nullptr;
// note: include QQuickWindow::TextureHasAlphaChannel if the rendered content
// has alpha.
// createTextureFromNativeObject
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
# ifndef _WIN32
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
# endif
this->texture = this->window->createTextureFromId(newId, size);
# ifndef _WIN32
# pragma GCC diagnostic pop
# endif
#else
this->texture =
this->window->createTextureFromNativeObject(
QQuickWindow::NativeObjectTexture,
static_cast<void *>(&newId),
0,
size);
#endif
this->setTexture(this->texture);

this->markDirty(DirtyMaterial);
Expand All @@ -342,7 +374,7 @@ void ThreadRenderer::Ready()
this->renderThread->surface->setFormat(this->renderThread->context->format());
this->renderThread->surface->create();

// carry out any initialisation before moving to thread
// carry out any initialisation before moving to thread
this->renderThread->InitialiseOnMainThread();

// Move to Render thread
Expand Down
2 changes: 1 addition & 1 deletion examples/thermal_camera/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ int main(int _argc, char** _argv)
ogreEngineName = _argv[1];
}

GraphicsAPI graphicsApi = GraphicsAPI::OPENGL;
GraphicsAPI graphicsApi = defaultGraphicsAPI();
if (_argc > 2)
{
graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2]));
Expand Down
2 changes: 1 addition & 1 deletion examples/transform_control/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ int main(int _argc, char** _argv)
ogreEngineName = _argv[1];
}

GraphicsAPI graphicsApi = GraphicsAPI::OPENGL;
GraphicsAPI graphicsApi = defaultGraphicsAPI();
if (_argc > 2)
{
graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2]));
Expand Down
2 changes: 1 addition & 1 deletion examples/view_control/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ int main(int _argc, char** _argv)
ogreEngineName = _argv[1];
}

GraphicsAPI graphicsApi = GraphicsAPI::OPENGL;
GraphicsAPI graphicsApi = defaultGraphicsAPI();
if (_argc > 2)
{
graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2]));
Expand Down
2 changes: 1 addition & 1 deletion examples/visualization_demo/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ int main(int _argc, char** _argv)
engine = _argv[1];
}

GraphicsAPI graphicsApi = GraphicsAPI::OPENGL;
GraphicsAPI graphicsApi = defaultGraphicsAPI();
if (_argc > 2)
{
graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2]));
Expand Down
2 changes: 1 addition & 1 deletion examples/waves/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ int main(int _argc, char** _argv)
ogreEngineName = _argv[1];
}

GraphicsAPI graphicsApi = GraphicsAPI::OPENGL;
GraphicsAPI graphicsApi = defaultGraphicsAPI();
if (_argc > 2)
{
graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2]));
Expand Down
20 changes: 17 additions & 3 deletions examples/wide_angle_camera/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,11 @@ void buildScene(ScenePtr _scene)
}

//////////////////////////////////////////////////
CameraPtr createCamera(const std::string &_engineName)
CameraPtr createCamera(const std::string &_engineName,
const std::map<std::string, std::string>& _params)
{
// create and populate scene
RenderEngine *engine = rendering::engine(_engineName);
RenderEngine *engine = rendering::engine(_engineName, _params);
if (!engine)
{
gzwarn << "Engine '" << _engineName
Expand Down Expand Up @@ -168,6 +169,12 @@ int main(int _argc, char** _argv)
ogreEngineName = _argv[1];
}

GraphicsAPI graphicsApi = defaultGraphicsAPI();
if (_argc > 2)
{
graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2]));
}

common::Console::SetVerbosity(4);
std::vector<std::string> engineNames;
std::vector<CameraPtr> cameras;
Expand All @@ -178,7 +185,14 @@ int main(int _argc, char** _argv)
{
try
{
CameraPtr camera = createCamera(engineName);
std::map<std::string, std::string> params;
if (engineName.compare("ogre2") == 0
&& graphicsApi == GraphicsAPI::METAL)
{
params["metal"] = "1";
}

CameraPtr camera = createCamera(engineName, params);
if (camera)
{
cameras.push_back(camera);
Expand Down
Loading

0 comments on commit 9902506

Please sign in to comment.