Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render to external window #757

Open
Levi-Armstrong opened this issue Nov 5, 2022 · 6 comments
Open

Render to external window #757

Levi-Armstrong opened this issue Nov 5, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@Levi-Armstrong
Copy link
Contributor

How to render to external window? I was expecting if I set the winID to the QWidget window id that it would draw the content to this location. This works if I use ogre2 directly so not sure why this does not work here.

  std::map<std::string, std::string> params;
  params["winID"] = std::to_string(winId());
  auto* engine = ignition::rendering::engine("ogre2", params);
@Levi-Armstrong Levi-Armstrong added the bug Something isn't working label Nov 5, 2022
@iche033
Copy link
Contributor

iche033 commented Nov 8, 2022

This works if I use ogre2 directly

Maybe we're passing different params to ogre2 when creating the render window?

the params that are passed to ogre2 when creating the render window can be found here:
https://github.com/gazebosim/gz-rendering/blob/gz-rendering7/ogre2/src/Ogre2RenderEngine.cc#L1022

you can see that we are setting the parentWindowHandle param to winID here:
https://github.com/gazebosim/gz-rendering/blob/gz-rendering7/ogre2/src/Ogre2RenderEngine.cc#L1083

@Levi-Armstrong
Copy link
Contributor Author

I did a simple demo using ogre2 directly with Qt, but setting the parentWindowHandle did not work either. Though if I set the externalWindowHandle to the winID it works. Do you know what the difference is between these two? I see that for different operating system it set the externalWindowHandle instead of the parrentWindowHandle

@iche033
Copy link
Contributor

iche033 commented Nov 8, 2022

Do you know what the difference is between these two?

The diff based on ogre's doc is that externalWindowHandle embeds ogre in existing window and parentWindowHandle embeds ogre in child of external window. I see that in the ogre wiki page on integrating Qt5, both are set.

One thing to try is modify this line in gz-rendering to create a window of proper size and see if it attaches to the external window that you have. Some additional details: In gazebo, we're currently just creating a 1x1 window for initializing ogre. Then we do a trick in gz-gui that tells Qt window to render the texture generated by the user camera we created in ogre.

@Levi-Armstrong
Copy link
Contributor Author

One thing to try is modify this line in gz-rendering to create a window of proper size and see if it attaches to the external window that you have. Some additional details: In gazebo, we're currently just creating a 1x1 window for initializing ogre. Then we do a trick in gz-gui that tells Qt window to render the texture generated by the user camera we created in ogre.

This is ultimately what I want to do, but I am using QWidgets and have been unsuccessful in making this work using QOpenglWidget. Do you have or no of any examples where this has been used with QWidgets?

@Levi-Armstrong
Copy link
Contributor Author

Here is my old post where I have a minimal example I was trying to get working. If I can get things working I would contribute back to this repository as an example similar to the gazebo qml example.

I have it partially working using the drawPixel command but once I add anything to the environment which has transparency it has issues. If the object with transparency is in view of the camera that color takes up the entire screen. If it goes out of view everything is normal. I will create a video and post.

@azeey
Copy link
Contributor

azeey commented May 31, 2024

Is this fixed by #992?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants