diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..4b4c1d6 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,10 @@ +[submodule "vendor/glfw"] + path = vendor/glfw + url = https://github.com/glfw/glfw.git +[submodule "vendor/glad"] + path = vendor/glad + url = https://github.com/Dav1dde/glad.git + branch = c +[submodule "vendor/glm"] + path = vendor/glm + url = https://github.com/g-truc/glm.git diff --git a/CMakeLists.txt b/CMakeLists.txt index cd533e1..b1a8968 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,17 @@ project(toddcox-faster) set(CMAKE_CXX_STANDARD 17) -add_library(tc STATIC src/groups.cpp src/solver.cpp src/cosets.cpp) -target_include_directories(tc PUBLIC include) +add_library(glad vendor/glad/src/glad.c) +target_include_directories(glad PUBLIC vendor/glad/include) +option(GLFW_BUILD_DOCS OFF) +option(GLFW_BUILD_EXAMPLES OFF) +option(GLFW_BUILD_TESTS OFF) +add_subdirectory(vendor/glfw) + +option(GLM_TEST_ENABLE OFF) +add_subdirectory(vendor/glm) + +add_subdirectory(tc) +add_subdirectory(vis) add_subdirectory(example) diff --git a/tc/CMakeLists.txt b/tc/CMakeLists.txt new file mode 100644 index 0000000..b7ef511 --- /dev/null +++ b/tc/CMakeLists.txt @@ -0,0 +1,6 @@ +add_library(tc STATIC + src/groups.cpp + src/solver.cpp + src/cosets.cpp) + +target_include_directories(tc PUBLIC include) diff --git a/include/tc/cosets.h b/tc/include/tc/cosets.h similarity index 100% rename from include/tc/cosets.h rename to tc/include/tc/cosets.h diff --git a/include/tc/groups.h b/tc/include/tc/groups.h similarity index 100% rename from include/tc/groups.h rename to tc/include/tc/groups.h diff --git a/include/tc/solver.h b/tc/include/tc/solver.h similarity index 100% rename from include/tc/solver.h rename to tc/include/tc/solver.h diff --git a/src/cosets.cpp b/tc/src/cosets.cpp similarity index 100% rename from src/cosets.cpp rename to tc/src/cosets.cpp diff --git a/src/groups.cpp b/tc/src/groups.cpp similarity index 100% rename from src/groups.cpp rename to tc/src/groups.cpp diff --git a/src/solver.cpp b/tc/src/solver.cpp similarity index 100% rename from src/solver.cpp rename to tc/src/solver.cpp diff --git a/vendor/glad b/vendor/glad new file mode 160000 index 0000000..5bf3eda --- /dev/null +++ b/vendor/glad @@ -0,0 +1 @@ +Subproject commit 5bf3eda6da606324999775b88a90ed572202be93 diff --git a/vendor/glfw b/vendor/glfw new file mode 160000 index 0000000..fe57e3c --- /dev/null +++ b/vendor/glfw @@ -0,0 +1 @@ +Subproject commit fe57e3c2921a1901390534e1e51053df70b5644b diff --git a/vendor/glm b/vendor/glm new file mode 160000 index 0000000..8828c3f --- /dev/null +++ b/vendor/glm @@ -0,0 +1 @@ +Subproject commit 8828c3f1fd05e173d94417ca4565aa634dabb1c1 diff --git a/vis/CMakeLists.txt b/vis/CMakeLists.txt new file mode 100644 index 0000000..f01759d --- /dev/null +++ b/vis/CMakeLists.txt @@ -0,0 +1,4 @@ +add_executable(vis + src/main.cpp) +target_include_directories(vis PRIVATE include) +target_link_libraries(vis PRIVATE tc glad glm glfw) diff --git a/vis/src/main.cpp b/vis/src/main.cpp new file mode 100644 index 0000000..232ccf7 --- /dev/null +++ b/vis/src/main.cpp @@ -0,0 +1,58 @@ +#include +#include +#include + +#include +#include + +#ifdef _WIN32 +extern "C" { +__attribute__((unused)) __declspec(dllexport) int NvOptimusEnablement = 0x00000001; +} +#endif + +int main(int argc, char *argv[]) { + if (!glfwInit()) { + std::cerr << "Failed to initialize GLFW" << std::endl; + return EXIT_FAILURE; + } + + auto window = glfwCreateWindow( + 1920, 1080, + "Coset Visualization", + nullptr, nullptr); + + if (!window) { + std::cerr << "Failed to create window" << std::endl; + glfwTerminate(); + exit(EXIT_FAILURE); + } + + glfwMakeContextCurrent(window); + gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); + glfwSwapInterval(0); + + std::cout + << "Graphics Information:" << std::endl + << " Vendor: " << glGetString(GL_VENDOR) << std::endl + << " Renderer: " << glGetString(GL_RENDERER) << std::endl + << " OpenGL version: " << glGetString(GL_VERSION) << std::endl + << " Shading version: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl; + + auto group = tc::group::A(5); + auto res = tc::solve(group); + std::cout + << "Coset Solution Test:" << std::endl + << " Group: " << group.name << std::endl + << " Order: " << res.len << std::endl; + + while (!glfwWindowShouldClose(window)) { + glClear(GL_COLOR_BUFFER_BIT); + glfwSwapBuffers(window); + + glfwPollEvents(); + } + + glfwTerminate(); + return EXIT_SUCCESS; +} \ No newline at end of file