Giter VIP home page Giter VIP logo

implot_demos's Introduction

ImPlot Demos

This repository contains toy ImPlot applications that demonstrate some of the library's functionality. The demos here are more sophisticated than those provided in implot_demo.h, and may rely on third-party libraries that would otherwise clutter ImPlot's main repository. Use these examples as a starting point for your application and to familiarize yourself with ImPlot, but do not assume all code (e.g. signal processing algorithms) to be perfectly correct or optimal.

Requirements

  • OpenGL
  • C++17 compiler

Note: Compiled and tested with MSVC. Minor changes to CMakeLists.txt may be required to support other compilers. If you make a fix, please submit a PR.

Build Instructions

  1. Clone this repository, ImPlot, and ImGui into a parent directory (name doesn't matter):
mkdir root
cd root
git clone https://github.com/epezent/implot_demos
git clone https://github.com/epezent/implot
git clone https://github.com/ocornut/imgui
  • root/
    • imgui/
    • implot/
    • implot_demos/
  1. Build with CMake, e.g.:
cd implot_demos
mkdir build
cd build
cmake ..
cmake --build . --config Release

Demos

Demo Description Image
demo.cpp Main demo. Displays the ImPlot (and ImGui) library supplied demo windows.
filter.cpp Simple filter toy for educational purposes. Displays time domain input/output signals, and the frequency domain transfer function, amplitude spectrum, etc. filter
spectrogram.cpp Realtime audio spectrogram and visualizer with device playback. Pass in an audio file at the command line: ./spectrogram.exe ./aphex_twin_formula.wav (see resources/audio folder). Recommend compiling with ImPlot backends branch. spectrogram
maps.cpp OpenStreetMap world map viewer. Downloads and displays zoomable tile maps in a plot. maps
mandel.cpp Realtime Mandelbrot viewer using AVX2 and OpenMP acceleration. Recommend compiling with ImPlot backends branch. mandel
perlin.cpp Renders perlin noise in a heatmap. perlin
graph.cpp Simple graphing calculator using exprtk expression evaluator. perlin
stocks.cpp Downloads and displays historical stock data from Yahoo Finance. perlin

Contributing

Have you created something awesome with ImPlot? If so, please consider submitting a PR with a minimal working example of your application as a demo. Use the following guidelines:

  • Modify your ImPlot/ImGui code so that it subclasses common/App.h (see any existing demos).
  • Try to contain your demo to a single file located in demos/.
  • Indicate your authorship and any helpful documentation at the top of your demo source file.
  • Add dependencies with CMake FetchContent (preferred), git submodules, or manually to the 3rdparty/ folder (include the license).
  • If your demo requires resources (audio, images, etc.), add them to the resources/ folder. Keep it simple!
  • Screenshots and/or GIFs with your PR are helpful.

implot_demos's People

Contributors

epezent avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

implot_demos's Issues

NvOptimusEnablement build error

Just tried to build with today's git head of imgui/implot/implot_demos with gcc 10.3.0 and see:

[ 92%] Building CXX object CMakeFiles/app.dir/common/Fonts/RobotoItalic.cpp.o
/usr/src/local/implot_demos/common/App.cpp: In constructor ‘App::App(std::string, int, int, int, const char**)’:
/usr/src/local/implot_demos/common/App.cpp:152:5: error: ‘NvOptimusEnablement’ was not declared in this scope
  152 |     NvOptimusEnablement = AmdPowerXpressRequestHighPerformance = result["gpu"].as<bool>();
      |     ^~~~~~~~~~~~~~~~~~~
/usr/src/local/implot_demos/common/App.cpp:152:27: error: ‘AmdPowerXpressRequestHighPerformance’ was not declared in this scope
  152 |     NvOptimusEnablement = AmdPowerXpressRequestHighPerformance = result["gpu"].as<bool>();
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reference for future: fix Missing X11... and OPENSSL

  • ERROR
CMake Error at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find X11 (missing: X11_X11_INCLUDE_PATH X11_X11_LIB)
Can be fixed by the following:

apt install libx11-dev
apt install libx11-dev

  • Error: SSL
 Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
  system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY
  OPENSSL_INCLUDE_DIR)

sudo apt-get install libssl-dev

ImGui Version

Hello,

Which version of ImGui was it used in this project?

I am following the steps, provide in the README, to compile the project and I am getting some errors compiling ImGui.

COMPILATION STEPS

mkdir root
cd root
git clone https://github.com/epezent/implot_demos
git clone https://github.com/epezent/implot
git clone https://github.com/ocornut/imgui

ERRORS:
image

Maybe we can update the compile steps forcing the clone of ImGui with the correct version.

clang-cl error in 'json.hpp'

While compiling tests/benchmark.cpp using clang-cl (ver. 16.0.1), I'm facing this issue: ocornut/imgui#6386
Errors from clang-cl:

In file included from tests/benchmark.cpp:9:
./3rdparty\json.hpp(16773,25): error: variable 'end' with type 'auto *const' has incompatible initializer of type
      'std::_Array_iterator<char, 64>'
            auto* const end = std::remove(number_buffer.begin(),
                        ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./3rdparty\json.hpp(16783,25): error: variable 'dec_pos' with type 'auto *const' has incompatible initializer of type
      'std::_Array_iterator<char, 64>'
            auto* const dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
                        ^         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This has been fixed in: https://github.com/nlohmann/json/pull/3082/files. The gist of it was simply:

--- a/3rdparty/json.hpp 2022-08-12 10:02:19
+++ b/3rdparty/json.hpp 2023-05-22 08:42:20
@@ -16770,7 +16770,7 @@
         // erase thousands separator
         if (thousands_sep != '\0')
         {
-            auto* const end = std::remove(number_buffer.begin(),
+            const auto end = std::remove(number_buffer.begin(),
                                           number_buffer.begin() + len, thousands_sep);
             std::fill(end, number_buffer.end(), '\0');
             JSON_ASSERT((end - number_buffer.begin()) <= len);
@@ -16780,7 +16780,7 @@
         // convert decimal point to '.'
         if (decimal_point != '\0' && decimal_point != '.')
         {
-            auto* const dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
+            const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
             if (dec_pos != number_buffer.end())
             {
                 *dec_pos = '.';

So can 3rdparty/json.hpp please be updated for this error?

glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE) compile error

implot_demos/common/App.cpp

Lines 171 to 186 in 86a565f

#if __APPLE__
// GL 3.2 + GLSL 150
const char* glsl_version = "#version 150";
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // 3.2+ only
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // Required on Mac
#else
// GL 3.0 + GLSL 130
const char* glsl_version = "#version 130";
glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
//glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // 3.2+ only
//glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // 3.0+ only
#endif

For line 177, error message: no known conversion from 'const gl::GLboolean' (aka 'const glbinding::Boolean8') to 'int' for 2nd argument

Replacing GL_TRUE with GLFW_TRUE will make it compile.

Track Particular Plot

Hi,
Is there a way to keep track of specific plots, so if I have stocks going on, and I'd like to keep latest candle in middle of screen (tracked) how can I do something like ImPlotTrack and passone the plot name maybe so it keeps focus on it? Not sure how something similar can be achieved. Thanks

How to plot scrolling spectrogram efficiently ?

I am using ImPlot to plot the spectrogram of audio recorded from microphone in real-time and it works fine. It is based on the demo in this repo.

What would be the most efficient way to have the plot scroll in real-time with new data entering from the right ?

I tried using ImPlotHeatmapFlags_ColMajor so as to have the spectrogram bins in consecutive memory in C/C++ with the idea of doing some movement of elements in the array. But I was unable to get ImPlotHeatmapFlags_ColMajor to work correctly. I only changed the order of data in the array and enabled the flag with no other change.

BTW thanks for developing the awesome ImPlot library

compile error in ubuntu23.04

/home/yun/Documents/cpp_img_demos/implot_demos/common/App.cpp: In constructor ‘App::App(std::string, int, int, int, const char**)’:
/home/yun/Documents/cpp_img_demos/implot_demos/common/App.cpp:152:5: error: ‘NvOptimusEnablement’ was not declared in this scope
  152 |     NvOptimusEnablement = AmdPowerXpressRequestHighPerformance = result["gpu"].as<bool>();
      |     ^~~~~~~~~~~~~~~~~~~
/home/yun/Documents/cpp_img_demos/implot_demos/common/App.cpp:152:27: error: ‘AmdPowerXpressRequestHighPerformance’ was not declared in this scope
  152 |     NvOptimusEnablement = AmdPowerXpressRequestHighPerformance = result["gpu"].as<bool>();
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gmake[2]: *** [CMakeFiles/app.dir/build.make:76:CMakeFiles/app.dir/common/App.cpp.o] 错误 1
gmake[1]: *** [CMakeFiles/Makefile2:690:CMakeFiles/app.dir/all] 错误 2
gmake: *** [Makefile:136:all] 错误 2

Real-time stocks example

Hi!

I would like to make an example "stocks" running in real time. Do you have any idea how this could be done? I'm interested in top down ideas.

As far as I understand we can get data from yahoo finance all the time if we access it every few seconds. We also need to think about how to redraw the candlesticks each time. Also we need some kind of storage, otherwise all data might not fit in.

In general, I would be glad to get any ideas for an example and articles, based on which I could make the example realtime.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.