diff --git a/.gitignore b/.gitignore index 15a508a0..07e59ec4 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,8 @@ CMakeFiles/ **.a **.dll **.so -**.exe \ No newline at end of file +**.exe + +.idea +.cmake +Testing diff --git a/INSTALLATION.md b/docs/docs/INSTALLATION.md similarity index 88% rename from INSTALLATION.md rename to docs/docs/INSTALLATION.md index a1f9b858..8366bd26 100644 --- a/INSTALLATION.md +++ b/docs/docs/INSTALLATION.md @@ -1,6 +1,14 @@ -# Linux -You have to have X11, OpenGL, CMake and a C compiler installed. -## X11 +--- +hide: + - navigation +--- + +# Installation + +## Linux +You have to have X11-dev-packages, CMake and a C compiler installed. + +### X11 On Debian and derivates like Ubuntu and Linux Mint the xorg-dev meta-package pulls in the development packages for all of X11. ```bash sudo apt install xorg-dev @@ -18,17 +26,17 @@ pkg install xorgproto On Cygwin the libXcursor-devel, libXi-devel, libXinerama-devel, libXrandr-devel and libXrender-devel packages in the Libs section of the GUI installer will install all the headers and other development related files GLFW requires for X11. -# Mac +## Mac You have to have Xcode command line tools and CMake inatalled. ## Xcode ```bash xcode-select --install ``` -# Windows +## Windows You have to have CMake and a C compiler installed. You can also use WSL, if so follow the Linux instructions. -# Building Vuelto +## Building Vuelto Clone the repository ```bash git clone --recurse-submodules https://github.com/dimkauzh/vuelto.git diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 00000000..30e3c830 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,49 @@ +--- +hide: + - navigation + - toc +--- + + +

+

+banner + +

A Game Engine build with GLFW and OpenGL with support for C/C++.

+ +

+ GitHub last commit + GitHub license + Lines of code +

+ + + +## Welcome +Welcome to Vuelto's website! Here you can find more about the engine, or you can find some docs about the engine. If you want to contribute to the engine, you can find the source code on [GitHub](https://github.com/dimkauzh/vuelto). + +## Table of Contents + - [Installation](docs/INSTALLATION.md) + - [Todo/Changelog](todo/index.md) + - [Usage](#usage) + - [Contributing](#contributing) + - [License](#license) + - [About](#about) + + +## Usage +There are a couple ways to use vuelto with your project, but I recommend using it as a submodule. +Use the following things to achieve good usage with vuelto: + + - [CMake](https://cmake.org/) + - [Git](https://git-scm.com/) + - [Git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules) + +## Contributing +We are fully open to contributions, but I will check and test your code before merging it into the dev branch. All your code thats accepted will only be merged into the dev branch, and will be later released with the next release to the master branch. + +## License +Vuelto is licensed under the [GPLv3 Licence](https://github.com/dimkauzh/vuelto/blob/master/LICENSE). + +## About +Vuelto is a game engine built with GLFW and OpenGL using C. My goal is to achieve a good and easy to use game engine for everyone. I am currently working on the engine, and I am not planning to releasing Vuelto (its not ready). I am planning to release a website for the engine that contains a documentation for the engine and a roadmap/changelog. I am also planning to release a couple of tutorials on how to use vuelto. I hope you will enjoy using vuelto. Have fun! diff --git a/logo/banner.png b/docs/logo/banner.png similarity index 100% rename from logo/banner.png rename to docs/logo/banner.png diff --git a/docs/logo/icon-no-bg.png b/docs/logo/icon-no-bg.png new file mode 100644 index 00000000..b90d52cf Binary files /dev/null and b/docs/logo/icon-no-bg.png differ diff --git a/logo/icon.png b/docs/logo/icon.png similarity index 100% rename from logo/icon.png rename to docs/logo/icon.png diff --git a/docs/todo/index.md b/docs/todo/index.md new file mode 100644 index 00000000..c757b03e --- /dev/null +++ b/docs/todo/index.md @@ -0,0 +1,46 @@ +--- +hide: + - navigation + - toc +--- + +## V1 + - [x] Application + - [x] Window + - [x] Input + - [ ] Renderer + - [x] OpenGL + - [x] Rects + - [x] Images + - [ ] Animations + - [ ] Physics Engine + - [ ] Collision + - [ ] Gravity + - [ ] Forces + - [ ] Audio + - [ ] Sound + - [ ] Music + - [ ] Math + - [ ] Vectors + - [ ] Docs + - [x] Website + - [ ] Tutorials + - [ ] Docs + +## V2 + - [ ] GUI + - [ ] Buttons + - [ ] Text + - [ ] Images + - [ ] Networking + - [ ] TCP + - [ ] UDP + + - [ ] Vuelto Editor + - [ ] Full blown editor + - [ ] Scripting + - [ ] Plugins + - [ ] Customization + - [ ] Exporting + - [ ] Importing + - [ ] Project management diff --git a/include/vuelto/vuelto/core/app.h b/include/vuelto/vuelto/core/app.h index 8c5c83fd..c47a47b3 100644 --- a/include/vuelto/vuelto/core/app.h +++ b/include/vuelto/vuelto/core/app.h @@ -1,4 +1,5 @@ #include "../tools/definitions.h" +#include "structs.h" void vueltoInit(); void vueltoInitMultipleWindows(); diff --git a/include/vuelto/vuelto/core/renderer.h b/include/vuelto/vuelto/core/renderer.h index 7ee26136..77637bb1 100644 --- a/include/vuelto/vuelto/core/renderer.h +++ b/include/vuelto/vuelto/core/renderer.h @@ -1,4 +1,5 @@ #include "../tools/definitions.h" +#include "structs.h" void vueltoDrawRect(float x, float y, float width, float height, float r, float g, float b); void vueltoSetBackgroundColor(float color1, float color2, float color3); diff --git a/include/vuelto/vuelto/core/structs.h b/include/vuelto/vuelto/core/structs.h new file mode 100644 index 00000000..a01055ea --- /dev/null +++ b/include/vuelto/vuelto/core/structs.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +typedef struct { + GLFWwindow *window; + int width; + int height; + const char *title; +} Vuelto_Window; + +typedef struct { + float width, height, x, y; + GLuint texture; +} Vuelto_Image; diff --git a/include/vuelto/vuelto/event/event.h b/include/vuelto/vuelto/event/event.h index 847f87b3..0dbbecf8 100644 --- a/include/vuelto/vuelto/event/event.h +++ b/include/vuelto/vuelto/event/event.h @@ -1,6 +1,6 @@ #pragma once -#include "../core/app.h" +#include "../core/structs.h" #include "../tools/definitions.h" void vueltoPollEvents(); diff --git a/include/vuelto/vuelto/tools/definitions.h b/include/vuelto/vuelto/tools/definitions.h index 26cfe85e..3d8c8538 100644 --- a/include/vuelto/vuelto/tools/definitions.h +++ b/include/vuelto/vuelto/tools/definitions.h @@ -21,15 +21,3 @@ #include #include #include - -typedef struct { - GLFWwindow *window; - int width; - int height; - const char *title; -} Vuelto_Window; - -typedef struct { - float width, height, x, y; - GLuint texture; -} Vuelto_Image; diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 00000000..68d65d7b --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,37 @@ +site_name: Vuelto +site_description: A Game Engine build with GLFW and OpenGL with support for C/C++! + +repo_name: dimkauzh/vuelto +repo_url: https://github.com/dimkauzh/vuelto + +nav: + - Home: "index.md" + # - Wiki: "wiki/index.md" + # - Tutorial: "tutorials/index.md" + +theme: + name: material + + logo: logo/icon-no-bg.png + favicon: logo/icon-no-bg.png + + features: + - navigation.path + - navigation.tabs + - navigation.tabs.sticky + - navigation.top + - toc.follow + - navigation.expand + + palette: + - media: "(prefers-color-scheme: light)" + scheme: default + toggle: + icon: material/brightness-7 + name: Switch to dark mode + + - media: "(prefers-color-scheme: dark)" + scheme: slate + toggle: + icon: material/brightness-4 + name: Switch to light mode diff --git a/src/vuelto/core/app.c b/src/vuelto/core/app.c index 4900ed92..71031930 100644 --- a/src/vuelto/core/app.c +++ b/src/vuelto/core/app.c @@ -1,6 +1,5 @@ #include "app.h" -#include "../tools/definitions.h" #include "renderer.h" bool MultipleWindowsEnabled = false; @@ -60,6 +59,10 @@ bool vueltoWindowShouldClose(Vuelto_Window win) { return true; } +void vueltoWindowSetRezisable(Vuelto_Window win, bool resizable) { + glfwSetWindowAttrib(win.window, GLFW_RESIZABLE, resizable); +} + void vueltoMakeContextCurrent(Vuelto_Window win) { glfwMakeContextCurrent(win.window); } void vueltoRefresh(Vuelto_Window win) { diff --git a/src/vuelto/core/app.h b/src/vuelto/core/app.h index 8c5c83fd..6d59dc8e 100644 --- a/src/vuelto/core/app.h +++ b/src/vuelto/core/app.h @@ -1,4 +1,5 @@ #include "../tools/definitions.h" +#include "structs.h" void vueltoInit(); void vueltoInitMultipleWindows(); @@ -9,3 +10,4 @@ void vueltoTerminate(); bool vueltoWindowShouldClose(Vuelto_Window win); void vueltoRefresh(Vuelto_Window win); void vueltoMakeContextCurrent(Vuelto_Window win); +void vueltoWindowSetRezisable(Vuelto_Window win, bool resizable); diff --git a/src/vuelto/core/renderer.h b/src/vuelto/core/renderer.h index 7ee26136..77637bb1 100644 --- a/src/vuelto/core/renderer.h +++ b/src/vuelto/core/renderer.h @@ -1,4 +1,5 @@ #include "../tools/definitions.h" +#include "structs.h" void vueltoDrawRect(float x, float y, float width, float height, float r, float g, float b); void vueltoSetBackgroundColor(float color1, float color2, float color3); diff --git a/src/vuelto/core/structs.h b/src/vuelto/core/structs.h new file mode 100644 index 00000000..a01055ea --- /dev/null +++ b/src/vuelto/core/structs.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +typedef struct { + GLFWwindow *window; + int width; + int height; + const char *title; +} Vuelto_Window; + +typedef struct { + float width, height, x, y; + GLuint texture; +} Vuelto_Image; diff --git a/src/vuelto/event/event.c b/src/vuelto/event/event.c index 03f14eee..4ee2ffc0 100644 --- a/src/vuelto/event/event.c +++ b/src/vuelto/event/event.c @@ -1,7 +1,5 @@ #include "event.h" -#include "../tools/definitions.h" - void vueltoPollEvents() { glfwPollEvents(); } bool vueltoKeyPressed(Vuelto_Window window, int keyCode) { return (glfwGetKey(window.window, keyCode) == GLFW_PRESS); } diff --git a/src/vuelto/event/event.h b/src/vuelto/event/event.h index 847f87b3..0dbbecf8 100644 --- a/src/vuelto/event/event.h +++ b/src/vuelto/event/event.h @@ -1,6 +1,6 @@ #pragma once -#include "../core/app.h" +#include "../core/structs.h" #include "../tools/definitions.h" void vueltoPollEvents(); diff --git a/src/vuelto/tools/definitions.h b/src/vuelto/tools/definitions.h index 26cfe85e..3d8c8538 100644 --- a/src/vuelto/tools/definitions.h +++ b/src/vuelto/tools/definitions.h @@ -21,15 +21,3 @@ #include #include #include - -typedef struct { - GLFWwindow *window; - int width; - int height; - const char *title; -} Vuelto_Window; - -typedef struct { - float width, height, x, y; - GLuint texture; -} Vuelto_Image; diff --git a/test/opengl.cpp b/test/opengl.cpp deleted file mode 100644 index d2b95505..00000000 --- a/test/opengl.cpp +++ /dev/null @@ -1,115 +0,0 @@ - -#include -#include - -#include - -const char* vertexShaderSource = - "#version 330 core\n" - "layout (location = 0) in vec3 aPos;\n" - "void main()\n" - "{\n" - " gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);\n" - "}\0"; - -const char* fragmentShaderSource = - "#version 330 core\n" - "uniform vec3 color;\n" // Added color uniform - "out vec4 FragColor;\n" - "void main()\n" - "{\n" - " FragColor = vec4(color, 1.0f);\n" - "}\n\0"; - -void framebuffer_size_callback(GLFWwindow* window, int width, int height) { glViewport(0, 0, width, height); } - -void processInput(GLFWwindow* window) { - if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) glfwSetWindowShouldClose(window, true); -} - -void DrawRect(float x, float y, float width, float height, float r, float g, float b) { - float vertices[] = {x, y, 0.0f, x + width, y, 0.0f, x + width, y + height, 0.0f, x, y + height, 0.0f}; - - unsigned int VBO, VAO; - glGenBuffers(1, &VBO); - glGenVertexArrays(1, &VAO); - - glBindVertexArray(VAO); - glBindBuffer(GL_ARRAY_BUFFER, VBO); - glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); - - glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0); - glEnableVertexAttribArray(0); - - unsigned int vertexShader, fragmentShader, shaderProgram; - vertexShader = glCreateShader(GL_VERTEX_SHADER); - glShaderSource(vertexShader, 1, &vertexShaderSource, NULL); - glCompileShader(vertexShader); - - fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); - glShaderSource(fragmentShader, 1, &fragmentShaderSource, NULL); - glCompileShader(fragmentShader); - - shaderProgram = glCreateProgram(); - glAttachShader(shaderProgram, vertexShader); - glAttachShader(shaderProgram, fragmentShader); - glLinkProgram(shaderProgram); - glUseProgram(shaderProgram); - - glDeleteShader(vertexShader); - glDeleteShader(fragmentShader); - - int colorLocation = glGetUniformLocation(shaderProgram, "color"); - glUniform3f(colorLocation, r, g, b); - - // Draw the rectangle - glBindVertexArray(VAO); - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - - // Cleanup - glDeleteVertexArrays(1, &VAO); - glDeleteBuffers(1, &VBO); - glDeleteProgram(shaderProgram); -} - -int main() { - if (!glfwInit()) { - std::cerr << "Failed to initialize GLFW" << std::endl; - return -1; - } - - 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, "OpenGL on macOS", NULL, NULL); - if (!window) { - std::cerr << "Failed to create GLFW window" << std::endl; - glfwTerminate(); - return -1; - } - - glfwMakeContextCurrent(window); - - int framebufferWidth, framebufferHeight; - glfwGetFramebufferSize(window, &framebufferWidth, &framebufferHeight); - glViewport(0, 0, framebufferWidth, framebufferHeight); - glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); - - while (!glfwWindowShouldClose(window)) { - processInput(window); - - glClearColor(0.2f, 0.3f, 0.3f, 1.0f); - - // Draw a rectangle at position (0.2, 0.2) with width 0.4, height 0.3, and color (0.0, 1.0, 0.0) - DrawRect(0.2f, 0.2f, 0.4f, 0.3f, 0.0f, 1.0f, 0.0f); - - glfwSwapBuffers(window); - glfwPollEvents(); - glClear(GL_COLOR_BUFFER_BIT); - } - - glfwTerminate(); - return 0; -} diff --git a/test/test.bat b/test/test.bat index b82810e2..7b134512 100644 --- a/test/test.bat +++ b/test/test.bat @@ -1,5 +1,5 @@ @echo off -cmake . -make +cmake . -G "Unix Makefiles" +make -j8 .\bin\test\test_program.exe del .\bin\test\test_program.exe diff --git a/test/test.sh b/test/test.sh index 0803d65e..f4a1f90a 100755 --- a/test/test.sh +++ b/test/test.sh @@ -1,4 +1,4 @@ cmake . -make +make -j8 ./bin/test/test_program rm bin/test/test_program