Browse Source
Update CMake to a more modern module management system and create simple test based on imgui null example
master
Leonardo Mariscal
4 years ago
No known key found for this signature in database
GPG Key ID: 7C2FCB7B62623F44
8 changed files with
93 additions and
47 deletions
-
.gitignore
-
.travis.yml
-
CMakeLists.txt
-
test/CMakeLists.txt
-
test/main.c
-
testbuildc/build.bat
-
testbuildc/cimguitest.c
-
testbuildc/testcl.bat
|
|
@ -32,7 +32,10 @@ cimgui/cimgui.sdf |
|
|
|
cimgui/cimgui.v12.suo |
|
|
|
cimgui/Release/ |
|
|
|
.idea |
|
|
|
CMakeLists.txt |
|
|
|
cimgui/.vs/ |
|
|
|
cimgui/cimgui.vcxproj.user |
|
|
|
cimgui/x64/ |
|
|
|
|
|
|
|
# Test / Build |
|
|
|
bld/ |
|
|
|
build/ |
|
|
|
|
|
@ -1,11 +1,17 @@ |
|
|
|
language: cpp |
|
|
|
dist: trusty |
|
|
|
|
|
|
|
os: |
|
|
|
- linux |
|
|
|
- osx |
|
|
|
|
|
|
|
compiler: |
|
|
|
- gcc |
|
|
|
- clang |
|
|
|
|
|
|
|
script: |
|
|
|
make |
|
|
|
- mkdir bld |
|
|
|
- cd bld |
|
|
|
- cmake -D CIMGUI_TEST=1 .. |
|
|
|
- make |
|
|
|
- ./cimgui_test |
|
|
|
|
|
@ -1,20 +1,15 @@ |
|
|
|
Project(cimgui) |
|
|
|
cmake_minimum_required(VERSION 2.8) |
|
|
|
cmake_minimum_required(VERSION 3.1) |
|
|
|
|
|
|
|
#general settings |
|
|
|
include_directories(imgui) |
|
|
|
add_definitions("-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1") |
|
|
|
|
|
|
|
include_directories(.) |
|
|
|
set(IMGUI_SOURCES ./cimgui.cpp ./imgui/imgui.cpp ./imgui/imgui_draw.cpp ./imgui/imgui_demo.cpp ./imgui/imgui_widgets.cpp) |
|
|
|
|
|
|
|
set(IMGUI_LIBRARIES ) |
|
|
|
project(cimgui) |
|
|
|
|
|
|
|
if (WIN32) |
|
|
|
add_definitions("-DIMGUI_IMPL_API=extern \"C\" __declspec\(dllexport\)") |
|
|
|
else(WIN32) |
|
|
|
add_definitions("-DIMGUI_IMPL_API=extern \"C\" ") |
|
|
|
endif(WIN32) |
|
|
|
#general settings |
|
|
|
file(GLOB IMGUI_SOURCES |
|
|
|
cimgui.cpp |
|
|
|
imgui/imgui.cpp |
|
|
|
imgui/imgui_draw.cpp |
|
|
|
imgui/imgui_demo.cpp |
|
|
|
imgui/imgui_widgets.cpp |
|
|
|
) |
|
|
|
|
|
|
|
set(IMGUI_STATIC "no" CACHE STRING "Build as a static library") |
|
|
|
|
|
|
@ -25,12 +20,27 @@ else (IMGUI_STATIC) |
|
|
|
add_library(cimgui SHARED ${IMGUI_SOURCES}) |
|
|
|
endif (IMGUI_STATIC) |
|
|
|
|
|
|
|
target_link_libraries(cimgui ${IMGUI_LIBRARIES}) |
|
|
|
target_compile_definitions(cimgui PUBLIC IMGUI_DISABLE_OBSOLETE_FUNCTIONS=1) |
|
|
|
if (WIN32) |
|
|
|
target_compile_definitions(cimgui PUBLIC IMGUI_IMPL_API="extern \"C\" __declspec\(dllexport\)") |
|
|
|
else (WIN32) |
|
|
|
target_compile_definitions(cimgui PUBLIC IMGUI_IMPL_API="extern \"C\" ") |
|
|
|
endif (WIN32) |
|
|
|
|
|
|
|
target_include_directories(cimgui PUBLIC ${CMAKE_SOURCE_DIR}) |
|
|
|
target_include_directories(cimgui PUBLIC ${CMAKE_SOURCE_DIR}/imgui) |
|
|
|
set_target_properties(cimgui PROPERTIES PREFIX "") |
|
|
|
|
|
|
|
#install |
|
|
|
install(TARGETS cimgui |
|
|
|
RUNTIME DESTINATION . |
|
|
|
LIBRARY DESTINATION . |
|
|
|
ARCHIVE DESTINATION . |
|
|
|
) |
|
|
|
RUNTIME DESTINATION . |
|
|
|
LIBRARY DESTINATION . |
|
|
|
ARCHIVE DESTINATION . |
|
|
|
) |
|
|
|
|
|
|
|
#test |
|
|
|
set(CIMGUI_TEST "no" CACHE STRING "Enable compilation of a test unit based on imgui null") |
|
|
|
|
|
|
|
if (CIMGUI_TEST) |
|
|
|
add_subdirectory(test) |
|
|
|
endif () |
|
|
|
|
|
@ -0,0 +1,11 @@ |
|
|
|
file(GLOB CIMGUI_TEST_SOURCES |
|
|
|
main.c |
|
|
|
) |
|
|
|
|
|
|
|
add_executable(cimgui_test ${CIMGUI_TEST_SOURCES}) |
|
|
|
|
|
|
|
set_target_properties(cimgui_test PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) |
|
|
|
set_property(TARGET cimgui_test PROPERTY C_STANDARD 99) |
|
|
|
|
|
|
|
target_compile_definitions(cimgui_test PRIVATE CIMGUI_DEFINE_ENUMS_AND_STRUCTS=1) |
|
|
|
target_link_libraries(cimgui_test PRIVATE cimgui) |
|
|
@ -0,0 +1,41 @@ |
|
|
|
#include <stdio.h> |
|
|
|
#include <assert.h> |
|
|
|
#include <cimgui.h> |
|
|
|
|
|
|
|
int main(void) |
|
|
|
{ |
|
|
|
assert(igDebugCheckVersionAndDataLayout(igGetVersion(), sizeof(ImGuiIO), sizeof(ImGuiStyle), |
|
|
|
sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), |
|
|
|
sizeof(ImDrawIdx))); |
|
|
|
printf("CreateContext() - v%s\n", igGetVersion()); |
|
|
|
igCreateContext(NULL); |
|
|
|
ImGuiIO *io = igGetIO(); |
|
|
|
|
|
|
|
unsigned char *text_pixels = NULL; |
|
|
|
int text_w, text_h; |
|
|
|
ImFontAtlas_GetTexDataAsRGBA32(io->Fonts, &text_pixels, &text_w, &text_h, NULL); |
|
|
|
|
|
|
|
for (int n = 0; n < 20; n++) { |
|
|
|
printf("NewFrame() %d\n", n); |
|
|
|
|
|
|
|
ImVec2 display_size; |
|
|
|
display_size.x = 1920; |
|
|
|
display_size.y = 1080; |
|
|
|
io->DisplaySize = display_size; |
|
|
|
io->DeltaTime = 1.0f / 60.0f; |
|
|
|
igNewFrame(); |
|
|
|
|
|
|
|
static float f = 0.0f; |
|
|
|
igText("Hello World!"); |
|
|
|
igSliderFloat("float", &f, 0.0f, 1.0f, "%.3f", 1.0f); |
|
|
|
igText("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io->Framerate, io->Framerate); |
|
|
|
igShowDemoWindow(NULL); |
|
|
|
|
|
|
|
igRender(); |
|
|
|
} |
|
|
|
|
|
|
|
printf("DestroyContext()\n"); |
|
|
|
igDestroyContext(NULL); |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
@ -1,6 +0,0 @@ |
|
|
|
:: set PATH=%PATH%;C:\mingw32\bin; |
|
|
|
set PATH=%PATH%;C:\i686-7.2.0-release-posix-dwarf-rt_v5-rev1\mingw32\bin; |
|
|
|
::gcc -std=c99 -DCIMGUI_DEFINE_ENUMS_AND_STRUCTS cimgui.h |
|
|
|
::gcc -DCIMGUI_DEFINE_ENUMS_AND_STRUCTS cimgui.h |
|
|
|
gcc -std=c99 -Wall -Wpedantic -DCIMGUI_DEFINE_ENUMS_AND_STRUCTS cimguitest.c |
|
|
|
cmd /k |
|
|
@ -1,6 +0,0 @@ |
|
|
|
#include "../cimgui.h" |
|
|
|
|
|
|
|
int main(void) |
|
|
|
{ |
|
|
|
return 0; |
|
|
|
} |
|
|
@ -1,13 +0,0 @@ |
|
|
|
::set PATH=%PATH%;C:\luaGL;C:\mingw32\bin; |
|
|
|
::gcc -E -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS -DIMGUI_API="" -DIMGUI_IMPL_API="" ../imgui/imgui.h > 11.txt |
|
|
|
|
|
|
|
::set PATH=%PATH%;C:\luaGL; |
|
|
|
::set PATH=%PATH%;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\bin\Hostx64\x64; |
|
|
|
|
|
|
|
::ejecutar en cmd esto |
|
|
|
::"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat" |
|
|
|
|
|
|
|
::cl /P /DIMGUI_DISABLE_OBSOLETE_FUNCTIONS /DIMGUI_API="" /DIMGUI_IMPL_API="" ../imgui/imgui.h |
|
|
|
:: > clout.txt |
|
|
|
cl /P /DCIMGUI_DEFINE_ENUMS_AND_STRUCTS cimguitest.c |
|
|
|
cmd /k |