Skip to content

Commit

Permalink
add implot
Browse files Browse the repository at this point in the history
  • Loading branch information
HerrNamenlos123 committed Jul 14, 2024
1 parent b49d643 commit 07dd124
Show file tree
Hide file tree
Showing 18 changed files with 14,548 additions and 3 deletions.
9 changes: 9 additions & 0 deletions deps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ b_add_library(imgui STATIC ALIAS imgui::imgui
target_include_directories(imgui PUBLIC "imgui")
target_include_directories(imgui PRIVATE "SDL/include")

# implot
b_add_library(implot STATIC ALIAS implot::implot
implot/implot.cpp
implot/implot_demo.cpp
implot/implot_items.cpp
)
target_include_directories(implot PUBLIC "implot")
target_link_libraries(implot PRIVATE imgui::imgui)

# Lua
add_subdirectory(Lua)

Expand Down
4 changes: 2 additions & 2 deletions deps/embed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ namespace b {
return converter.from_bytes(str);
}

#endif // _WIN32

#ifdef __clang__
#pragma GCC diagnostic pop
#endif

#endif // _WIN32

static std::optional<std::string> embed_read_file(const std::string_view& filename) {
#ifdef _WIN32
std::ifstream file(embed_widen(std::string(filename)).c_str(), std::ios::binary);
Expand Down
95 changes: 95 additions & 0 deletions deps/implot/.github/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# This build script is not meant for general use, it is for CI use only!
cmake_minimum_required(VERSION 3.0)
project(implot)

#
# Global options
#

# Same as Dear ImGui
set(CMAKE_CXX_STANDARD 11)

# Arch option for linux
if (NOT APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU" AND DEFINED GCC_ARCH)
if ("${GCC_ARCH}" MATCHES "Win32|x86|32")
add_compile_options(-m32)
add_link_options(-m32)
elseif ("${GCC_ARCH}" MATCHES "Win64|x64|64")
add_compile_options(-m64)
add_link_options(-m64)
endif ()
endif ()

# Arch option for Mac: arm64 for M1 or x86_64 for intel (32 bits build are deprecated on Mac)
if(APPLE AND DEFINED OSX_ARCH)
if ("${OSX_ARCH}" MATCHES "x86_64")
set(CMAKE_OSX_ARCHITECTURES "x86_64")
elseif ("${OSX_ARCH}" MATCHES "arm64")
set(CMAKE_OSX_ARCHITECTURES "arm64")
else()
message(FATAL_ERROR "Unhandled OSX_ARCH=${OSX_ARCH}")
endif()
endif()

#
# Dear ImGui library with no backend
#

set(imgui_sources
../imgui/imconfig.h
../imgui/imgui.cpp
../imgui/imgui.h
../imgui/imgui_demo.cpp
../imgui/imgui_draw.cpp
../imgui/imgui_internal.h
../imgui/imgui_tables.cpp
../imgui/imgui_widgets.cpp
../imgui/imstb_rectpack.h
../imgui/imstb_textedit.h
../imgui/imstb_truetype.h
)
add_library(imgui ${imgui_sources})
target_include_directories(imgui PUBLIC ../imgui)

#
# ImPlot library
#

file(GLOB SOURCE_CODE ../implot*.*)
add_library(implot STATIC ${SOURCE_CODE})

if(MSVC)
target_compile_options(implot PRIVATE /W4 /WX)
else()
target_compile_options(implot PRIVATE -Wall -Werror -pedantic)
endif()

target_include_directories(implot PUBLIC ${CMAKE_CURRENT_LIST_DIR}/..)
target_link_libraries(implot PUBLIC imgui)

if (UNIX)
target_link_libraries(implot PUBLIC m stdc++)
endif()

# Define supported types via command line:
# - With no choice all types are supported (so that the CI provides support for all known types)
# - with -DIMPLOT_CUSTOM_NUMERIC_TYPES="default" the default set defined in implot_items.cpp is used
# - with -DIMPLOT_CUSTOM_NUMERIC_TYPES="(int)(float)(double)" only int, float and double are supported
if (NOT DEFINED IMPLOT_CUSTOM_NUMERIC_TYPES)
set(IMPLOT_CUSTOM_NUMERIC_TYPES "all")
endif()
if ("${IMPLOT_CUSTOM_NUMERIC_TYPES}" STREQUAL "default")
message("==== Compiling for default types ====")
elseif("${IMPLOT_CUSTOM_NUMERIC_TYPES}" STREQUAL "all")
message("==== Compiling for all types ====")
target_compile_definitions(implot PRIVATE "IMPLOT_CUSTOM_NUMERIC_TYPES=(signed char)(unsigned char)(signed short)(unsigned short)(signed int)(unsigned int)(signed long)(unsigned long)(signed long long)(unsigned long long)(float)(double)(long double)")
else()
message("==== Compiling for custom types: ${IMPLOT_CUSTOM_NUMERIC_TYPES} ====")
target_compile_definitions(implot PRIVATE "IMPLOT_CUSTOM_NUMERIC_TYPES=${IMPLOT_CUSTOM_NUMERIC_TYPES}")
endif()

#
# implot example binary application (with no backend)
#
add_executable(example_implot example_implot.cpp)
target_link_libraries(example_implot PRIVATE implot)
55 changes: 55 additions & 0 deletions deps/implot/.github/example_implot.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Sample app built with Dear ImGui and ImPlot
// This app uses implot and imgui, but does not output to any backend! It only serves as a proof that an app can be built, linked, and run.

#include "imgui.h"
#include "implot.h"
#include "stdio.h"

int main(int, char**)
{
printf("sample_implot: start\n");

IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImPlot::CreateContext();

// Additional imgui initialization needed when no backend is present
ImGui::GetIO().DisplaySize = ImVec2(400.f, 400.f);
ImGui::GetIO().Fonts->Build();

// Render 500 frames
for(int counter = 0; counter < 500; ++counter)
{
ImGui::NewFrame();

if (ImGui::Begin("Hello, world!"))
{
ImGui::Text("Hello again");

if (ImPlot::BeginPlot("My Plot"))
{
static double values[] = {1., 3., 5.};
ImPlot::PlotLine("Values", values, 3);
ImPlot::EndPlot();
}

#ifdef IMPLOT_INSTANTIATE_ALL_NUMERIC_TYPES
if (ImPlot::BeginPlot("My Plot (long double)"))
{
static long double values[] = {1., 3., 5.};
ImPlot::PlotLine("Values", values, 3);
ImPlot::EndPlot();
}
#endif

ImGui::End();
}

ImGui::Render();
}

ImPlot::DestroyContext();
ImGui::DestroyContext();
printf("sample_implot: end\n");
return 0;
}
144 changes: 144 additions & 0 deletions deps/implot/.github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
name: build

on:
push:
pull_request:

jobs:
Linux:
runs-on: ubuntu-22.04

strategy:
fail-fast: false
matrix:
build_type:
- debug
- release
compiler:
- gcc
- clang
arch:
- x86
- x64

steps:
- uses: actions/checkout@v3

- uses: actions/checkout@v3
with:
repository: ocornut/imgui
path: imgui

- name: Dependencies
run: sudo apt-get install g++-multilib

- name: Configure
run: cmake -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} -DCMAKE_C_COMPILER=${{ matrix.compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DGCC_ARCH=${{ matrix.arch }} -B cmake-build -S .github

- name: Build
run: cmake --build cmake-build --parallel $(nproc)

- name: Run
run: |
file cmake-build/example_implot
cmake-build/example_implot
MacOS:
runs-on: macos-11

strategy:
fail-fast: false
matrix:
build_type:
- debug
- release
arch:
- x86_64
- arm64

steps:
- uses: actions/checkout@v3

- uses: actions/checkout@v3
with:
repository: ocornut/imgui
path: imgui

- name: Configure
shell: bash
run: cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DOSX_ARCH=${{ matrix.arch }} -B cmake-build -S .github

- name: Build
shell: bash
run: cmake --build cmake-build --parallel $(sysctl -n hw.ncpu)

- name: Run
if: matrix.arch == 'x86_64' # github's CI hosts seem to be running intel and can not run ARM
run: |
file cmake-build/example_implot
cmake-build/example_implot
Windows_MSVC:
runs-on: windows-2022

strategy:
fail-fast: false
matrix:
build_type:
- debug
- release
arch:
- Win32
- x64

steps:
- uses: actions/checkout@v3

- uses: actions/checkout@v3
with:
repository: ocornut/imgui
path: imgui

- name: Configure
shell: bash
run: cmake -G 'Visual Studio 17 2022' -A ${{ matrix.arch }} -B cmake-build -S .github

- name: Build
shell: bash
run: cmake --build cmake-build -- -p:Configuration=${{ matrix.build_type }} -maxcpucount:$NUMBER_OF_PROCESSORS

- name: Run
run: .\cmake-build\${{matrix.build_type}}\example_implot.exe

Windows_MingW: # MingW on Github CI does not fully support 32 bits: link fails when it tries to link 64 bits system libraries.
runs-on: windows-2022

strategy:
fail-fast: false
matrix:
build_type:
- debug
- release
arch:
- x64
# - Win32

steps:
- uses: actions/checkout@v3

- uses: actions/checkout@v3
with:
repository: ocornut/imgui
path: imgui

- name: Configure
shell: bash
run: cmake -G 'MinGW Makefiles' -DGCC_ARCH=${{ matrix.arch }} -B cmake-build -S .github

- name: Build
shell: bash
run: cmake --build cmake-build --parallel $NUMBER_OF_PROCESSORS

- name: Run (MingW)
run: .\cmake-build\example_implot.exe

21 changes: 21 additions & 0 deletions deps/implot/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Evan Pezent

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit 07dd124

Please sign in to comment.