diff --git a/CMakeLists.txt b/CMakeLists.txt index 524e64c..f2cbe39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,8 @@ project(minecraft-clone C) cmake_minimum_required(VERSION 3.9) set( CMAKE_EXPORT_COMPILE_COMMANDS ON ) -include_directories(lib/include) -file(GLOB SOURCES "src/*.c" "lib/src/*.c") +include_directories(lib/glad/include) +file(GLOB SOURCES "src/*.c" "lib/*/src/*.c") find_program(CCACHE_PROGRAM ccache) add_executable(test.out ${SOURCES}) set_property(TARGET test.out PROPERTY C_STANDARD 11) diff --git a/LICENSE b/LICENSE index e142a52..a9ed424 100644 --- a/LICENSE +++ b/LICENSE @@ -1,3 +1,7 @@ +The license of the libraries are located in the directory lib/ + +License of any other files: + GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 diff --git a/lib/glad/LICENSE b/lib/glad/LICENSE new file mode 100644 index 0000000..90b8a99 --- /dev/null +++ b/lib/glad/LICENSE @@ -0,0 +1,63 @@ +The glad source code: + + The MIT License (MIT) + + Copyright (c) 2013-2020 David Herberth + + Permission is hereby granted, free of charge, to any person obtaining a copy of + this software and associated documentation files (the "Software"), to deal in + the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +The Khronos Specifications: + + Copyright (c) 2013-2020 The Khronos Group Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +The EGL Specification and various headers: + + Copyright (c) 2007-2016 The Khronos Group Inc. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and/or associated documentation files (the + "Materials"), to deal in the Materials without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Materials, and to + permit persons to whom the Materials are furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Materials. + + THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. diff --git a/lib/include/KHR/khrplatform.h b/lib/glad/include/KHR/khrplatform.h similarity index 100% rename from lib/include/KHR/khrplatform.h rename to lib/glad/include/KHR/khrplatform.h diff --git a/lib/include/glad/glad.h b/lib/glad/include/glad/glad.h similarity index 100% rename from lib/include/glad/glad.h rename to lib/glad/include/glad/glad.h diff --git a/lib/src/glad.c b/lib/glad/src/glad.c similarity index 100% rename from lib/src/glad.c rename to lib/glad/src/glad.c diff --git a/src/main.c b/src/main.c index 7f41174..3a1ca66 100644 --- a/src/main.c +++ b/src/main.c @@ -31,6 +31,15 @@ int main() { glViewport(0, 0, 1920, 1080); glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE); + 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)) { glClearColor(0.2f, 0.3f, 0.3f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); @@ -47,3 +56,28 @@ void glfwError(int id, const char* description) { void framebuffer_size_callback(GLFWwindow* window, int width, int height) { glViewport(0, 0, width, height); } +unsigned int parseShader(const char *filePath) { + FILE *fp = fopen(filePath, "rb"); + size_t lSize; + char *buffer; + if(!fp) { + perror(filePath); + } + fseek(fp, 0L, SEEK_END); + lSize = ftell(fp); + rewind(fp); + buffer = malloc(lSize + 1); + if(!buffer) { + fclose(fp); + printf("out of memory"); + exit(1); + } + size_t readReturn = fread(buffer, lSize, 1, fp); + fclose(fp); + if(readReturn != 1) { + printf("Can't read Shader"); + exit(1); + } + printf("%s", buffer); + return 0; +} diff --git a/src/main.h b/src/main.h index a131ab8..ca68b48 100644 --- a/src/main.h +++ b/src/main.h @@ -2,6 +2,7 @@ #define main_h #include #include -void glfwError(int id, const char* description); -void framebuffer_size_callback(GLFWwindow* window, int width, int height); +void glfwError(int id, const char *description); +void framebuffer_size_callback(GLFWwindow *window, int width, int height); +unsigned int parseShader(const char *filePath); #endif