From 21caa8dd7655514e8c2bcbe6f5b5f55d8ec86398 Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Wed, 18 Oct 2023 17:03:13 +0200 Subject: [PATCH] linker hell --- CMakeLists.txt | 1 - src/graphics.cpp | 63 ++++--------------------------------------- src/graphics.hpp | 10 ++++++- src/main.cpp | 70 +++--------------------------------------------- 4 files changed, 18 insertions(+), 126 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f57cb5..f161bb5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,6 @@ add_subdirectory(lib/glfw) include_directories( include/ - lib/glad/include/ lib/glfw/include/ ) file( diff --git a/src/graphics.cpp b/src/graphics.cpp index 303a0aa..ce805c8 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -1,63 +1,10 @@ -#include -// glad must be loaded before GLFW -#include - #include "graphics.hpp" +#include // Include the library header file here -#include -#include - -void processInput(GLFWwindow *window) { - // if user presses ESC, close the window - if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) - glfwSetWindowShouldClose(window, true); +void init() { +// Use GLFW functions here } -void framebuffer_size_callback(GLFWwindow *window, int width, int height) { - glViewport(0, 0, width, height); -} - -int mainWindow() { - /* graphics stuff */ - glfwInit(); - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); - glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); - // glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); - - GLFWwindow *window = glfwCreateWindow(800, 600, "Shader Loader", NULL, NULL); - if (window == NULL) { - printf("Failed to create GLFW window\n"); - glfwTerminate(); - return -1; - } - glfwMakeContextCurrent(window); - - if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) { - printf("Failed to initialize GLAD\n"); - return -1; - } - - glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); - - float vertices[] = {-0.5f, -0.5f, 0.0f, 0.5f, -0.5f, 0.0f, 0.0f, 0.5f, 0.0f}; - - unsigned int VBO; - - glGenBuffers(1, &VBO); - glBindBuffer(GL_ARRAY_BUFFER, VBO); - glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); - - while (!glfwWindowShouldClose(window)) { - processInput(window); - - glClearColor(0.8f, 0.4f, 0.1f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); - - glfwSwapBuffers(window); - glfwPollEvents(); - } - - glfwTerminate(); - return 0; +void draw() { +// Use GLFW functions here } diff --git a/src/graphics.hpp b/src/graphics.hpp index 1975dcf..66dd8e0 100644 --- a/src/graphics.hpp +++ b/src/graphics.hpp @@ -1 +1,9 @@ -int mainWindow(); +#ifndef GRAPHICS_HPP +#define GRAPHICS_HPP + +#include // Include the library header file here + +void init(); +void draw(); + +#endif diff --git a/src/main.cpp b/src/main.cpp index fb420e7..044d344 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,69 +1,7 @@ -#include -#include -#include -#include - -#include -#include - #include "graphics.hpp" -namespace po = boost::program_options; -using namespace std; - -int main(int argc, char **argv); - -void help(char *prog, po::options_description desc); - -int main(int argc, char **argv) { - - /* Parsing CLI Arguments */ - po::options_description desc("Available options"); - desc.add_options() - ("help,h", "show help") - ("verbose,v", "more verbose output") - ("vert", po::value()->required(), "vertex shader file") - ("frag", po::value()->required(), "fragment shader file"); - - /* unused for now */ - po::positional_options_description pdesc; - // NOTE: if you want to add a positional argument, - // you need to create and option for it as it seems. - pdesc.add("vert", 1); - pdesc.add("frag", 1); - - po::variables_map vm; - try { - - po::store(po::command_line_parser(argc, argv) - .options(desc) // load options - .positional(pdesc) // load positionals - .run(), - vm); - po::notify(vm); - if (vm.count("help") || argc < 3) { - help(argv[0], desc); - return 1; - } - } catch (po::error &e) { - cout << e.what() << endl << endl; - help(argv[0], desc); - return 1; - } - - if (vm.count("verbose")) { - printf("verbose!"); - } - - /* Run our main program */ - int result = mainWindow(); - - return result; -} - -void help(char *prog, po::options_description desc) { - cout << "Usage:" << endl - << prog << " [-vh] [--vert] shaders/vertex.glsl [--frag] shaders/fragment.glsl" - << endl << endl - << desc << endl; +int main() { +init(); +draw(); +return 0; }