diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index dab2f43..7678b0f 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -1,16 +1,17 @@ { - "configurations": [ - { - "name": "linux-gcc-x64", - "includePath": [ - "${workspaceFolder}/**" - ], - "compilerPath": "/usr/bin/gcc", - "cStandard": "${default}", - "cppStandard": "${default}", - "intelliSenseMode": "linux-gcc-x64", - "compilerArgs": [] - } - ], - "version": 4 + "configurations": [ + { + "name": "linux-gcc-x64", + "includePath": [ + "${workspaceFolder}/**", + "${workspaceFolder}/dependencies/include" + ], + "compilerPath": "/usr/bin/gcc", + "cStandard": "${default}", + "cppStandard": "${default}", + "intelliSenseMode": "linux-gcc-x64", + "compilerArgs": [] + } + ], + "version": 4 } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 1d435f0..1c58fb6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -25,5 +25,53 @@ "**/.*/**", "**/.vscode", "**/.vscode/**" - ] + ], + "files.associations": { + "array": "cpp", + "atomic": "cpp", + "bit": "cpp", + "*.tcc": "cpp", + "cctype": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "unordered_map": "cpp", + "vector": "cpp", + "exception": "cpp", + "algorithm": "cpp", + "functional": "cpp", + "iterator": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", + "optional": "cpp", + "random": "cpp", + "string": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "fstream": "cpp", + "initializer_list": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "limits": "cpp", + "new": "cpp", + "ostream": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "cinttypes": "cpp", + "typeinfo": "cpp" + } } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 98ef0f0..35e55ca 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -6,8 +6,11 @@ "command": "/usr/bin/g++", "args": [ "-Wall", "${workspaceFolder}/Engine/engine/*.cpp", + "${workspaceFolder}/Engine/engine/glad.c", "-o", - "${workspaceFolder}/Engine/engine/match", "-lglfw", "-lGLU", "-lGL", "-lm", + "${workspaceFolder}/Engine/engine/match", "-lglut", "-lglfw", "-lGLU", "-lGL", "-lm", + "-I${workspaceFolder}/dependencies/include", + ], "options": { diff --git a/Engine/engine/match b/Engine/engine/match deleted file mode 100755 index d63ddbb..0000000 Binary files a/Engine/engine/match and /dev/null differ diff --git a/Engine/engine/match.cpp b/Engine/engine/match.cpp index a7b3a3a..f3691f6 100644 --- a/Engine/engine/match.cpp +++ b/Engine/engine/match.cpp @@ -1,38 +1,59 @@ + +#include #include -int main(void) +#include + + +void e() { std::cout << "breakpoint" << std::endl; }; + +void instantiateGLFWWindow() { - GLFWwindow* window; + glfwInit(); // we initialize glfw + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + // we configure glfw , + // first argument is what option we want to configure, // the second sets the value of the option + // see: https://www.glfw.org/docs/latest/window.html#window_hints + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + // We tell glfw we want to use smaller subset of OGL features without backwards-compatible one + //glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); + // We would use this one if we worked on macOs +} - /* Initialize the library */ - if (!glfwInit()) - { - return -1; - } - - /* Create a windowed mode window and its OpenGL context */ - window = glfwCreateWindow(640, 480, "xD", NULL, NULL); - if (!window) +int createWindowObject() +{ + GLFWwindow* window = glfwCreateWindow(800, 600, "LearnOpenGL", NULL, NULL); + // we provide width and height of window + // then name of the window + // we ignore last 2 parameters + // function returns GLFW window object that we will use for other glfw operations + if (window == NULL) { + std::cout << "Failed to create GLFW window" << std::endl; glfwTerminate(); return -1; } - - /* Make the window's context current */ + // context of our window becomes the main context of current thread glfwMakeContextCurrent(window); - - /* Loop until the user closes the window */ - while (!glfwWindowShouldClose(window)) - { - /* Render here */ - glClear(GL_COLOR_BUFFER_BIT); - - /* Swap front and back buffers */ - glfwSwapBuffers(window); - - /* Poll for and process events */ - glfwPollEvents(); - } - - glfwTerminate(); return 0; +} + +int initializeGLAD() +{ + if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) + { + std::cout << "Failed to initialize GLAD" << std::endl; + return -1; + } + return 0; +} + +int main() +{ + if(initializeGLAD() == -1) return -1; + instantiateGLFWWindow(); + if(createWindowObject() == -1) return -1; + e(); + return 0; + } \ No newline at end of file