-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #625 from Hopobcn/feature/imgui
Add imgui 1.74
- Loading branch information
Showing
7 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
cmake_minimum_required(VERSION 3.4) | ||
project(imgui CXX) | ||
|
||
include(conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
if (WIN32 AND MSVC AND BUILD_SHARED_LIBS) | ||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) | ||
endif(WIN32 AND MSVC AND BUILD_SHARED_LIBS) | ||
|
||
set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder) | ||
set(MISC_DIR ${SOURCE_DIR}/misc) | ||
set(EXTRA_FONTS_DIR ${MISC_DIR}/fonts) | ||
|
||
file(GLOB SOURCE_FILES ${SOURCE_DIR}/*.cpp) | ||
file(GLOB HEADER_FILES ${SOURCE_DIR}/*.h) | ||
file(GLOB EXTRA_FONTS_FILES ${EXTRA_FONTS_DIR}/*.ttf) | ||
if (MSVC) | ||
file(GLOB EXTRA_NATVIS_FILES ${MISC_DIR}/natvis/*.natvis) | ||
endif() | ||
|
||
set(BINARY_TO_COMPRESSED_BIN binary_to_compressed_c) | ||
|
||
add_executable(${BINARY_TO_COMPRESSED_BIN} ${EXTRA_FONTS_DIR}/binary_to_compressed_c.cpp) | ||
|
||
add_library(${PROJECT_NAME} ${SOURCE_FILES}) | ||
target_include_directories(${PROJECT_NAME} PRIVATE ${SOURCE_DIR}) | ||
target_link_libraries(${PROJECT_NAME} PUBLIC ${CONAN_LIBS}) | ||
|
||
include(GNUInstallDirs) | ||
|
||
install(TARGETS ${PROJECT_NAME} | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) | ||
install(TARGETS ${BINARY_TO_COMPRESSED_BIN} | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||
install(FILES ${HEADER_FILES} | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) | ||
install(FILES ${EXTRA_FONTS_FILES} | ||
DESTINATION ${CMAKE_INSTALL_PREFIX}/res/fonts | ||
PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) | ||
if (MSVC) | ||
install(FILES ${EXTRA_NATVIS_FILES} | ||
DESTINATION ${CMAKE_INSTALL_PREFIX}/res/natvis | ||
PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
"1.74": | ||
url: "https://github.com/ocornut/imgui/archive/v1.74.tar.gz" | ||
sha256: "2f5f2b789edb00260aa71f03189da5f21cf4b5617c4fbba709e9fbcfc76a2f1e" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import os | ||
from conans import ConanFile, CMake, tools | ||
|
||
|
||
class IMGUIConan(ConanFile): | ||
name = "imgui" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/ocornut/imgui" | ||
description = "Bloat-free Immediate Mode Graphical User interface for C++ with minimal dependencies" | ||
topics = ("conan", "imgui", "gui", "graphical") | ||
license = "MIT" | ||
|
||
exports_sources = ["CMakeLists.txt"] | ||
generators = "cmake" | ||
|
||
settings = "os", "arch", "compiler", "build_type" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False] | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True | ||
} | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
|
||
def config_options(self): | ||
if self.settings.os == 'Windows': | ||
del self.options.fPIC | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version]) | ||
extracted_dir = self.name + "-" + self.version | ||
os.rename(extracted_dir, self._source_subfolder) | ||
|
||
def _configure_cmake(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
return cmake | ||
|
||
def build(self): | ||
cmake = self._configure_cmake() | ||
cmake.build() | ||
|
||
def package(self): | ||
self.copy(pattern="LICENSE.txt", dst="licenses", src=self._source_subfolder) | ||
self.copy(pattern="examples/imgui_impl_*", dst="res/bindings", src=self._source_subfolder, keep_path=False) | ||
cmake = self._configure_cmake() | ||
cmake.install() | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = tools.collect_libs(self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
project(test_package) | ||
cmake_minimum_required(VERSION 2.8.11) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
file(GLOB SOURCE_FILES *.cpp) | ||
|
||
add_executable(${PROJECT_NAME} ${SOURCE_FILES}) | ||
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from conans import ConanFile, CMake, tools | ||
import os | ||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not tools.cross_building(self.settings): | ||
bin_path = os.path.join("bin", "test_package") | ||
self.run(bin_path, run_environment=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <imgui.h> | ||
#include <stdio.h> | ||
|
||
int main(int, char**) | ||
{ | ||
ImGuiContext* context =ImGui::CreateContext(); | ||
ImGuiIO& io = ImGui::GetIO(); | ||
|
||
// Build atlas | ||
unsigned char* tex_pixels = NULL; | ||
int tex_w, tex_h; | ||
io.Fonts->GetTexDataAsRGBA32(&tex_pixels, &tex_w, &tex_h); | ||
|
||
for (int n = 0; n < 50; n++) | ||
{ | ||
printf("NewFrame() %d\n", n); | ||
io.DisplaySize = ImVec2(1920, 1080); | ||
io.DeltaTime = 1.0f / 60.0f; | ||
ImGui::NewFrame(); | ||
|
||
static float f = 0.0f; | ||
ImGui::Text("Hello, world!"); | ||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); | ||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate); | ||
ImGui::ShowDemoWindow(NULL); | ||
|
||
ImGui::Render(); | ||
} | ||
|
||
printf("DestroyContext()\n"); | ||
ImGui::DestroyContext(context); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"1.74": | ||
folder: all |