Skip to content
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
52 changes: 32 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ project(implot_demos VERSION 0.1.0)
###############################################################################

# FETCH CONTENT LIBS
include(FetchContent)
include(FetchContent)
# set(FETCHCONTENT_FULLY_DISCONNECTED ON)

FetchContent_Declare(fmt GIT_REPOSITORY https://github.com/fmtlib/fmt)
FetchContent_MakeAvailable(fmt)

FetchContent_Declare(glfw GIT_REPOSITORY https://github.com/glfw/glfw)
FetchContent_Declare(glfw GIT_REPOSITORY https://github.com/glfw/glfw)
FetchContent_MakeAvailable(glfw)

FetchContent_Declare(iir GIT_REPOSITORY https://github.com/berndporr/iir1)
FetchContent_Declare(iir GIT_REPOSITORY https://github.com/berndporr/iir1)
FetchContent_MakeAvailable(iir)

if (WIN32)
Expand All @@ -24,7 +24,7 @@ endif()
FetchContent_Declare(curl
URL https://github.com/curl/curl/releases/download/curl-7_75_0/curl-7.75.0.tar.xz
URL_HASH SHA256=fe0c49d8468249000bda75bcfdf9e30ff7e9a86d35f1a21f428d79c389d55675 # the file hash for curl-7.75.0.tar.xz
USES_TERMINAL_DOWNLOAD TRUE)
USES_TERMINAL_DOWNLOAD TRUE)
FetchContent_MakeAvailable(curl)
add_library(curl_int INTERFACE)
target_link_libraries(curl_int INTERFACE libcurl)
Expand All @@ -40,14 +40,17 @@ add_subdirectory(3rdparty/glad)
add_subdirectory(3rdparty/nativefiledialog-extended)

# KISS FFT
set(KISS_SRC "3rdparty/kissfft/kiss_fft.h"
"3rdparty/kissfft/kiss_fftr.h"
"3rdparty/kissfft/kiss_fft.c"
set(KISS_SRC "3rdparty/kissfft/kiss_fft.h"
"3rdparty/kissfft/kiss_fftr.h"
"3rdparty/kissfft/kiss_fft.c"
"3rdparty/kissfft/kiss_fftr.c")

# EVERYTHING ELSE
include_directories("3rdparty" "3rdparty/kissfft")

include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-mavx2" HAS_AVX2)

###############################################################################
# IMGUI
###############################################################################
Expand All @@ -58,7 +61,7 @@ set(IMGUI_HEADERS
../imgui/imgui.h
../imgui/imstb_rectpack.h
../imgui/imstb_textedit.h
../imgui/imstb_truetype.h
../imgui/imstb_truetype.h
../imgui/backends/imgui_impl_glfw.h
../imgui/backends/imgui_impl_opengl3.h
../imgui/backends/imgui_impl_opengl3_loader.h
Expand All @@ -82,8 +85,17 @@ add_library(imgui ${IMGUI_HEADERS} ${IMGUI_SRC})
if(MSVC)
target_compile_options(imgui PRIVATE /W4 /WX /arch:AVX2 /fp:fast)
endif()
target_link_libraries(imgui PUBLIC glfw glad OpenGL::GL imm32)
target_compile_definitions(imgui PRIVATE IMGUI_DLL_EXPORT)
if(HAS_AVX2)
target_compile_options(imgui PUBLIC -mavx2)
endif()

if (WIN32)
target_link_libraries(imgui PUBLIC glfw glad OpenGL::GL imm32)
target_compile_definitions(imgui PRIVATE IMGUI_DLL_EXPORT)
else()
target_link_libraries(imgui PUBLIC glfw glad OpenGL::GL)
endif()


include_directories(../imgui/ ../imgui/examples ../imgui/examples/libs/gl3w ../imgui/backends ../imgui/misc/cpp)

Expand All @@ -97,7 +109,7 @@ include_directories(3rdparty/imnodes)
###############################################################################

set(IMPLOT_HEADERS ../implot/implot.h ../implot/implot_internal.h)
set(IMPLOT_SRC ../implot/implot.cpp ../implot/implot_items.cpp ../implot/implot_demo.cpp)
set(IMPLOT_SRC ../implot/implot.cpp ../implot/implot_items.cpp ../implot/implot_demo.cpp)

if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../implot/backends")
list(APPEND IMPLOT_HEADERS ../implot/backends/implot_backend.h ../implot/backends/implot_impl_opengl3.h)
Expand All @@ -109,7 +121,7 @@ target_link_libraries(implot PUBLIC imgui)
target_compile_definitions(implot PUBLIC IMPLOT_DEBUG IMPLOT_DLL_EXPORT IMPLOT_BACKEND_ENABLE_OPENGL3 IMGUI_IMPL_OPENGL_LOADER_GLAD)
set_property(TARGET implot PROPERTY CXX_STANDARD 11)
if(MSVC)
target_compile_options(implot PRIVATE /W4 /WX /arch:AVX2 /fp:fast /permissive-)
target_compile_options(implot PRIVATE /W4 /WX /arch:AVX2 /fp:fast /permissive-)
else()
target_compile_options(implot PRIVATE -Wall -Wextra -pedantic -Werror -mavx2 -Ofast)
endif()
Expand All @@ -120,7 +132,7 @@ include_directories(../implot/)
# APP FRAMEWORK
###############################################################################

add_library(app
add_library(app
common/App.h
common/App.cpp
common/Shader.h
Expand Down Expand Up @@ -181,8 +193,8 @@ target_compile_features(filter PRIVATE cxx_std_17)
target_compile_definitions(filter PRIVATE kiss_fft_scalar=double NOMINMAX)

# spectrogram demo
add_executable(spectrogram "demos/spectrogram.cpp" ${KISS_SRC})
target_link_libraries(spectrogram app)
add_executable(spectrogram "demos/spectrogram.cpp" ${KISS_SRC})
target_link_libraries(spectrogram app)
target_compile_features(spectrogram PRIVATE cxx_std_17)
add_custom_command(TARGET spectrogram POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/resources/audio/aphex_twin_formula.wav $<TARGET_FILE_DIR:spectrogram>)

Expand All @@ -192,8 +204,8 @@ target_link_libraries(stocks app fmt::fmt CURL::libcurl)
target_compile_features(stocks PRIVATE cxx_std_17)

# voice demo
add_executable(voice "demos/voice.cpp" ${KISS_SRC})
target_link_libraries(voice app)
add_executable(voice "demos/voice.cpp" ${KISS_SRC})
target_link_libraries(voice app)
target_compile_features(voice PRIVATE cxx_std_17)

###############################################################################
Expand All @@ -203,13 +215,13 @@ target_compile_features(voice PRIVATE cxx_std_17)
add_executable(benchmark "tests/benchmark.cpp")
target_link_libraries(benchmark app)
target_compile_features(benchmark PRIVATE cxx_std_17)
add_custom_command(TARGET spectrogram POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
add_custom_command(TARGET spectrogram POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/resources/shaders/
$<TARGET_FILE_DIR:spectrogram>/shaders/)

if (MSVC)
target_compile_options(benchmark PRIVATE /arch:AVX2 /fp:fast)
else()
target_compile_options(benchmark PRIVATE -lstdc++fs -mavx2 -Ofast)
endif()
endif()
14 changes: 8 additions & 6 deletions common/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ App::App(std::string title, int w, int h, int argc, char const *argv[])
("h,height", "Window height override",cxxopts::value<int>())
("g,gpu", "Use discrete GPU on hybrid laptops")
("help","Show Help");


auto result = options.parse(argc,argv);
if (result.count("help"))
Expand All @@ -144,12 +144,14 @@ App::App(std::string title, int w, int h, int argc, char const *argv[])
if (result.count("width"))
w = result["width"].as<int>();
if (result.count("height"))
h = result["height"].as<int>();
h = result["height"].as<int>();

const bool no_vsync = result["vsync"].as<bool>();
const bool use_msaa = result["msaa"].as<bool>();
const bool im_style = result["imgui"].as<bool>();
#ifdef _WIN32
NvOptimusEnablement = AmdPowerXpressRequestHighPerformance = result["gpu"].as<bool>();
#endif
UsingDGPU = result["gpu"].as<bool>();

#ifdef _DEBUG
Expand Down Expand Up @@ -201,10 +203,10 @@ App::App(std::string title, int w, int h, int argc, char const *argv[])
{
fprintf(stderr, "Failed to initialize OpenGL loader!\n");
abort();
}
}

const GLubyte* vendor = glGetString(GL_VENDOR);
const GLubyte* renderer = glGetString(GL_RENDERER);
const GLubyte* vendor = glGetString(GL_VENDOR);
const GLubyte* renderer = glGetString(GL_RENDERER);

title += " - ";
title += reinterpret_cast< char const * >(renderer);
Expand All @@ -218,7 +220,7 @@ App::App(std::string title, int w, int h, int argc, char const *argv[])
ImGui_ImplOpenGL3_Init(glsl_version);

if (use_msaa)
glEnable(GL_MULTISAMPLE);
glEnable(GL_MULTISAMPLE);

if (im_style) {
ImGui::StyleColorsDark();
Expand Down
Loading