Building a Real-Time Oscilloscope with SDL and ImGui in C++
Real-Time Graph
In this post, I’ll walk you through how I developed a simple yet efficient real-time oscilloscope using SDL3 for rendering and Dear ImGui for the GUI controls. This was part of an experiment to visualize signal waveforms and interactively control signal parameters in a lightweight cross-platform application.
Why SDL and ImGui?
SDL (Simple DirectMedia Layer) provides a fast and cross-platform rendering layer that works well with C++. Dear ImGui, on the other hand, is a powerful immediate-mode GUI library that makes it incredibly easy to create interactive controls without complex state management.
Get Madhawa Polkotuwa’s stories in your inbox
Join Medium for free to get updates from this writer.
Combining both gave me the ability to:
- Render real-time signal data efficiently.
- Build intuitive controls around the main oscilloscope view using ImGui.
- Maintain good performance across platforms.
Project :
The Oscilloscope Class
The core of the app is the Oscilloscope class, responsible for:
- Buffering signal data in real-time.
- Scaling and plotting the waveform using SDL’s rendering functions.
- Clearing and updating the view as new data streams in.
ImGui Controls
I integrated ImGui to add interactive controls around the oscilloscope window. These controls allow you to:
- Toggle between different waveforms (sine, square, etc.)
- Adjust amplitude and frequency in real-time.
- Clear the buffer or pause rendering.
Performance Notes
One interesting observation was the difference in frame rate between MSVC and MinGW GCC builds. The MSVC build delivered significantly smoother rendering. I found that SDL’s software rendering backend (used in some GCC setups) could bottleneck performance. Switching to hardware acceleration and tweaking compiler flags helped close the gap.
Final Thoughts
This project was a fun exploration into real-time rendering and GUI design in C++. SDL and ImGui proved to be a powerful combo for lightweight tools like this oscilloscope. I’m planning to further enhance this app by:
- Adding FFT support to view frequency components.
- Saving waveform data to file.
- Making it cross-platform with Linux and macOS builds.










