-
Notifications
You must be signed in to change notification settings - Fork 174
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
viewport support #72
Comments
Sure! I knew about this for a while, but I didn't want to work on it, because it's not in a release yet, so I'd have to constantly keep up to date and fix every breaking change, which is a bit difficult. If you want, I can try to make it work in the state that viewports are now in ImGui in experimental branch, but if you can wait until it's in one of ImGui's releases + some additional time it will take me to implement (PRs are welcome, if you really need it :D), I'l try to implement it later. |
I tried that a few weeks ago and it wasn't that difficult. The biggest problem was to get the position of the render area relative to the desktop (main window only) without the window decoration. |
@gotocoffee1 Do you have the code publicly available? I'd be interested in using this feature |
@eric556 Not right now but I will look into this again and maybe do a pull request. |
So I looked into the sample ports again and it seems that the platform has to be able to handle multiple monitors (right @ocornut ?), which is not supported by SFML. |
You need to be able to create multiple windows and share the graphics context. |
Hi, does anyone have an implementation of this publicly available? |
In my project I'm using imgui from docking branch with sfml. |
Something new about implementing the viewports? |
I'm still not sure if I need to do anything on ImGui-SFML's side since you can have multiple ImGui contexts now and ImGui-SFML supports it. |
I tried but it doesnt work, thats why i dropped a comment here, can you give it a go? |
Can you please describe what doesn't work? |
Sorry for not leaving an example straight up, here it is: So I'm just taking the simple example from here and modifying it for multi viewports (as said here (at #include "imgui.h" // necessary for ImGui::*, imgui-SFML.h doesn't include imgui.h
#include "imgui-SFML.h" // for ImGui::SFML::* functions and SFML-specific overloads
#include <SFML/Graphics/CircleShape.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/System/Clock.hpp>
#include <SFML/Window/Event.hpp>
#include <iostream>
int main() {
sf::RenderWindow window(sf::VideoMode(640, 480), "ImGui + SFML = <3");
window.setFramerateLimit(60);
ImGui::SFML::Init(window);
ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; //added this! ---
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
sf::Clock deltaClock;
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
ImGui::SFML::ProcessEvent(window, event);
if (event.type == sf::Event::Closed) {
window.close();
}
}
ImGui::SFML::Update(window, deltaClock.restart());
ImGui::ShowDemoWindow();
ImGui::Begin("Hello, world!");
ImGui::Button("Look at this pretty button");
ImGui::End();
window.clear();
window.draw(shape);
ImGui::SFML::Render(window);
std::cout << (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable) << std::endl;
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable) //added this! ---
{
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
}
window.display();
}
ImGui::SFML::Shutdown();
return 0;
} And i would be able to get the imgui windows outside of the main sfml window but i cant. Also, |
Yeah, now I see that it requires some additional coding which seems not very trivial... At best I could be able to start researching this next month... so if someone has more time and wants to implement this, I'd be more than happy to accept the PR. :) |
|
@eliasdaler were you able to start it? |
Hey is this feature going to be released?, I would be a huge addition to the library, supporting viewports. |
5 years and nothing... Crazy. |
consider adding support for the upcoming
viewports
feature of ImGuiThe text was updated successfully, but these errors were encountered: