diff --git a/README.md b/README.md new file mode 100644 index 0000000..912991c --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# GLSL-Basics + +This projects contains a loader for GLSL Shaders. It can be used to generate +fancy images and videos from your shader files. + +## Requirements +For Fedora Systems, you can the dependencies like this: +```bash +sudo dnf install wayland-devel libxkbcommon-devel wayland-protocols-devel extra-cmake-modules \ + libXrandr-devel libXinerama-devel libXcursor-devel libXi-devel +``` diff --git a/build.sh b/build.sh index ded4558..e1c71e2 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,6 @@ #!/bin/bash set -e -cmake . +flags="-DGLFW_USE_WAYLAND=ON" # compile glfw for wayland instead of X11 +cmake $flags . cmake --build . ./bin/loader/loader diff --git a/data/shader/vert/basic.glsl b/data/shader/vert/basic.glsl new file mode 100644 index 0000000..c74ea10 --- /dev/null +++ b/data/shader/vert/basic.glsl @@ -0,0 +1,7 @@ +#version 330 core +layout (location = 0) in vec3 aPos; + +void main() +{ + gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0); +} diff --git a/src/main.cpp b/src/main.cpp index 5db5787..3553eb7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,6 +2,7 @@ #include #include +#include void framebuffer_size_callback(GLFWwindow *window, int width, int height); void processInput(GLFWwindow *window); @@ -15,23 +16,31 @@ int main(int argc, char **argv) { GLFWwindow *window = glfwCreateWindow(800, 600, "Shader Loader", NULL, NULL); if (window == NULL) { - std::cout << "Failed to create GLFW window" << std::endl; + printf("Failed to create GLFW window\n"); glfwTerminate(); return -1; } glfwMakeContextCurrent(window); if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) { - std::cout << "Failed to initialize GLAD" << std::endl; + 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.2f, 0.3f, 0.3f, 1.0f); + glClearColor(0.8f, 0.4f, 0.1f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); glfwSwapBuffers(window);