Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade sfml to 3 and imgui to 1.91 and other to exp #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ Set(FETCHCONTENT_QUIET FALSE)

FetchContent_Declare(SFML
GIT_REPOSITORY https://github.com/SFML/SFML.git
GIT_TAG 2.6.1
GIT_TAG 3.0.0
GIT_PROGRESS TRUE)
FetchContent_MakeAvailable(SFML)

FetchContent_Declare(ImGui
GIT_REPOSITORY https://github.com/ocornut/imgui
GIT_TAG v1.88
GIT_TAG v1.91.1
GIT_PROGRESS TRUE)
FetchContent_MakeAvailable(ImGui)

Expand All @@ -19,13 +19,13 @@ set(IMGUI_SFML_FIND_SFML OFF)
set(IMGUI_SFML_IMGUI_DEMO ON)
FetchContent_Declare(ImGui-SFML
GIT_REPOSITORY https://github.com/eliasdaler/imgui-sfml
GIT_TAG v2.6
GIT_TAG 3eb1ece0fed8351e89e69d4f72cf762ac1c4f4cf
GIT_PROGRESS TRUE)
FetchContent_MakeAvailable(ImGui-SFML)

FetchContent_Declare(ImPlot
GIT_REPOSITORY https://github.com/epezent/implot
GIT_TAG v0.16
GIT_TAG f1b0792cd3e239f615d4f20b9647d37594de8c56
GIT_PROGRESS TRUE)
FetchContent_MakeAvailable(ImPlot)

Expand Down
2 changes: 1 addition & 1 deletion include/Audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Audio
static sf::Sound& sound();
static sf::SoundBuffer& buffer();

inline static sf::Int16 samples[44100];
inline static std::int16_t samples[44100];

public:
inline static bool enabled = true;
Expand Down
2 changes: 1 addition & 1 deletion include/Interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ class Interface
static void shutdown();

static void draw(sf::RenderWindow& window);
static void pollEvent(sf::Event& theEvent);
static void pollEvent(sf::RenderWindow& window, sf::Event& theEvent);
static void update(sf::RenderWindow& window, sf::Time diffTime);
};
2 changes: 1 addition & 1 deletion include/Program.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Program
inline static sf::Time lastTime;

static void draw(sf::RenderWindow& window);
static void pollEvent(sf::Event& theEvent);
static void pollEvent(sf::RenderWindow& window, sf::Event& theEvent);
static void update(sf::RenderWindow& window);

public:
Expand Down
4 changes: 2 additions & 2 deletions src/Audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
constexpr auto TWOPI = 6.283185307f;

sf::Sound& Audio::sound() {
static sf::Sound theSound;
static sf::Sound theSound(Audio::buffer());
return theSound;
}

Expand Down Expand Up @@ -60,7 +60,7 @@ void Audio::play(unsigned value) {
}

sound().stop();
buffer().loadFromSamples(&samples[0], 44100, 1, 44100);
bool might = buffer().loadFromSamples(&samples[0], 44100, 1, 44100, std::vector{sf::SoundChannel::FrontCenter});
sound().setPitch(pitch);
sound().play();
}
8 changes: 4 additions & 4 deletions src/Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void Interface::changedAlgorithm() {
}

void Interface::initialize(sf::RenderWindow& window) {
ImGui::SFML::Init(window);
bool might = ImGui::SFML::Init(window);

ImGui::CreateContext();
ImPlot::CreateContext();
Expand Down Expand Up @@ -364,7 +364,7 @@ void Interface::draw(sf::RenderWindow& window) {
unsigned numbersSize = Settings::NUMBERS_DOWNSAMPLE == Settings::SAMPLING::NONE ? unsigned(sorterNumbers->size()) : unsigned(downsampledNumbers.size());
const unsigned* numbers = Settings::NUMBERS_DOWNSAMPLE == Settings::SAMPLING::NONE ? sorterNumbers->data() : downsampledNumbers.data();

float plotSizeHeight = ImGui::GetWindowContentRegionMax().y - ImGui::GetTextLineHeightWithSpacing() - 40;
float plotSizeHeight = ImGui::GetContentRegionAvail().y - ImGui::GetTextLineHeightWithSpacing() - 40;

ImPlotAxisFlags axisFlags = ImPlotAxisFlags_NoGridLines | ImPlotAxisFlags_NoSideSwitch | ImPlotAxisFlags_NoHighlight;
if(Settings::PLOT_SHOW_SCALE && Settings::PLOT_TYPE == Settings::PLOT_TYPES::HEATMAP) {
Expand Down Expand Up @@ -467,8 +467,8 @@ void Interface::draw(sf::RenderWindow& window) {
ImGui::SFML::Render(window);
}

void Interface::pollEvent(sf::Event& theEvent) {
ImGui::SFML::ProcessEvent(theEvent);
void Interface::pollEvent(sf::RenderWindow& window, sf::Event& theEvent) {
ImGui::SFML::ProcessEvent(window, theEvent);
}

void Interface::update(sf::RenderWindow& window, sf::Time diffTime) {
Expand Down
26 changes: 14 additions & 12 deletions src/Program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ void Program::draw(sf::RenderWindow& window) {
Interface::draw(window);
}

void Program::pollEvent(sf::Event& theEvent) {
Interface::pollEvent(theEvent);
void Program::pollEvent(sf::RenderWindow& window, sf::Event& theEvent) {
Interface::pollEvent(window, theEvent);
}

void Program::update(sf::RenderWindow& window) {
Expand All @@ -26,24 +26,26 @@ void Program::update(sf::RenderWindow& window) {

int Program::start() {
sf::ContextSettings contextSettings;
contextSettings.antialiasingLevel = 16;
sf::RenderWindow window(sf::VideoMode(1290, 720), "ImGui-Visualizer", sf::Style::Default, contextSettings);
contextSettings.antiAliasingLevel = 16;
sf::RenderWindow window(sf::VideoMode(sf::Vector2u(1290, 720)), "ImGui-Visualizer", sf::Style::Default, sf::State::Windowed, contextSettings);
window.setVerticalSyncEnabled(true);

Manager::initialize();
Interface::initialize(window);
Audio::initialize();

while (window.isOpen()) {
sf::Event theEvent;
while (window.pollEvent(theEvent)) {
if (theEvent.type == sf::Event::Closed) {
Interface::shutdown();
window.close();
return 0;
while (const std::optional mightEvent = window.pollEvent()) {
if (mightEvent) {
sf::Event theEvent = mightEvent.value();
if (theEvent.is<sf::Event::Closed>()) {
Interface::shutdown();
window.close();
return 0;
}

Program::pollEvent(window, theEvent);
}

Program::pollEvent(theEvent);
}

Program::update(window);
Expand Down
2 changes: 1 addition & 1 deletion src/SortingAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ SortingAlgorithm::stepState SortingAlgorithm::checkStep() {
//else
stats.sortTimeMs = stats.sortTimeMs + theClock.getElapsedTime().asSeconds() * 1000;

sf::sleep(sf::microseconds(sf::Int64(Manager::delayMs * 1000)));
sf::sleep(sf::microseconds(std::int64_t(Manager::delayMs * 1000)));
theClock.restart();

if (m_doStep) {
Expand Down
Loading