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

Viewports #213

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Ignore folders named build
build/**
Build/**

Ignore Visual Studio folder
.vs/**
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ endif()
option(IMGUI_SFML_BUILD_EXAMPLES "Build ImGui_SFML examples" OFF)
option(IMGUI_SFML_FIND_SFML "Use find_package to find SFML" ON)
option(IMGUI_SFML_IMGUI_DEMO "Build imgui_demo.cpp" OFF)

option(IMGUI_SFML_ENABLE_VIEWPORTS "Enable ImGui viewport support" OFF)
# If you want to use your own user config when compiling ImGui, please set the following variables
# For example, if you have your config in /path/to/dir/with/config/myconfig.h, set the variables as follows:
#
Expand Down Expand Up @@ -126,6 +126,10 @@ if(NOT IMGUI_SFML_USE_DEFAULT_CONFIG)
endif()
endif()

if(IMGUI_SFML_ENABLE_VIEWPORTS)
target_compile_definitions(ImGui-SFML PUBLIC IMGUI_SFML_VIEWPORTS_ENABLE)
endif()

target_compile_definitions(ImGui-SFML
PUBLIC
IMGUI_USER_CONFIG="${IMGUI_SFML_CONFIG_NAME}"
Expand Down
14 changes: 13 additions & 1 deletion examples/minimal/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@
#include <SFML/System/Clock.hpp>
#include <SFML/Window/Event.hpp>

#include <iostream>

int main() {
sf::RenderWindow window(sf::VideoMode(640, 480), "ImGui + SFML = <3");
sf::RenderWindow window(sf::VideoMode(1280, 720), "ImGui + SFML = <3");
window.setFramerateLimit(60);
ImGui::SFML::Init(window);
// Comment/uncomment this to disable/enable viewports
// Must be using docking branch of ImGui
//ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_ViewportsEnable
// | ImGuiConfigFlags_DockingEnable;

sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
Expand All @@ -37,6 +43,12 @@ int main() {
window.clear();
window.draw(shape);
ImGui::SFML::Render(window);
// Comment/uncomment this to disable/enable viewports
// Must be using docking branch of ImGui
//if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable) {
// ImGui::UpdatePlatformWindows();
// ImGui::RenderPlatformWindowsDefault();
//}
window.display();
}

Expand Down
Loading