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
19 changes: 15 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
cmake_minimum_required(VERSION 3.14)
project(SubChat LANGUAGES C CXX)
if (APPLE)
enable_language(OBJC)
endif ()

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # does not produce the json file
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "") # works


if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build (Debug or Release)" FORCE)
Expand Down Expand Up @@ -40,7 +46,9 @@ target_include_directories(subtitles_generator
${UTFCPP_DIR}/source
${MAGICENUM_DIR}/include/magic_enum
)
target_link_options(subtitles_generator PRIVATE -static)
if (NOT APPLE)
target_link_options(subtitles_generator PRIVATE -static)
endif ()
target_link_libraries(subtitles_generator
PRIVATE
CLI11::CLI11
Expand All @@ -52,7 +60,10 @@ target_link_libraries(subtitles_generator
if (BUILD_GUI)
# Find GUI dependencies
find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)

# glad configuration
set(GLAD_DIR "${CMAKE_SOURCE_DIR}/submodules/glad")
include_directories(${GLAD_DIR}/include)

# GLFW configuration
set(GLFW_DIR "${CMAKE_SOURCE_DIR}/submodules/glfw")
Expand All @@ -73,6 +84,7 @@ if (BUILD_GUI)

# Add GUI executable
add_executable(config_generator_gui
${GLAD_DIR}/src/glad.c
${IMGUI_DIR}/backends/imgui_impl_glfw.cpp
${IMGUI_DIR}/backends/imgui_impl_opengl3.cpp
${IMGUI_DIR}/imgui.cpp
Expand All @@ -90,7 +102,6 @@ if (BUILD_GUI)
PRIVATE
glfw
OpenGL::GL
GLEW::GLEW
nfd
)
endif ()
endif ()
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
build:
cmake -B build .
cmake --build build

.PHONY: clean
clean:
mkdir build
rm -rf build

7 changes: 7 additions & 0 deletions cli_main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#if defined(_WIN32)
// Do not include most things and no min/max defines (std::min/std::max).
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <Windows.h>
#endif

#include "ytt_generator.h"
#include <CLI/CLI.hpp>
#include <iostream>
Expand Down
26 changes: 20 additions & 6 deletions gui_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@
#define IMGUI_DEFINE_MATH_OPERATORS
#endif // IMGUI_DEFINE_MATH_OPERATORS

#if defined(_WIN32)
// Do not include most things and no min/max defines (std::min/std::max).
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <Windows.h>
#endif

#include "imgui.h"
#include "imgui_impl_glfw.h"
#include "imgui_impl_opengl3.h"
#include <GL/glew.h>
#include <glad/glad.h>
#include <cstdio>

#define GL_SILENCE_DEPRECATION
Expand Down Expand Up @@ -106,10 +113,8 @@ void ApplyDPI(float dpi_scale) {
ImGui::GetStyle() = default_style;
ImGuiStyle &style = ImGui::GetStyle();
style.ScaleAllSizes(dpi_scale);

}


void ShowDockSpace() {
ImGuiViewport *vp = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(vp->Pos);
Expand Down Expand Up @@ -168,15 +173,24 @@ int main(int, char **) {
glfwSetErrorCallback(glfw_error_callback);
if (!glfwInit())
return 1;
const char *glsl_version = "#version 130";
const char* glsl_version = "#version 330 core";
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
GLFWwindow *window = glfwCreateWindow(1280, 720, "SubChat Config Generator", nullptr, nullptr);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// https://stackoverflow.com/a/68879218/14915825
#ifdef __APPLE__
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
#endif

GLFWwindow* window = glfwCreateWindow(1280, 720, "SubChat Config Generator", nullptr, nullptr);
if (window == nullptr)
return 1;
glfwMakeContextCurrent(window);
glfwSwapInterval(1);

if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
return 1;

if (NFD_Init() != NFD_OKAY) {
printf("Error: %s\n", NFD_GetError());
return 1;
Expand Down
Loading