compile for wayland

This commit is contained in:
Christoph J. Scherr 2023-10-18 10:12:05 +02:00
parent a4256460b9
commit 74192889b1
4 changed files with 32 additions and 4 deletions

11
README.md Normal file
View File

@ -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
```

View File

@ -1,5 +1,6 @@
#!/bin/bash #!/bin/bash
set -e set -e
cmake . flags="-DGLFW_USE_WAYLAND=ON" # compile glfw for wayland instead of X11
cmake $flags .
cmake --build . cmake --build .
./bin/loader/loader ./bin/loader/loader

View File

@ -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);
}

View File

@ -2,6 +2,7 @@
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <iostream> #include <iostream>
#include <unistd.h>
void framebuffer_size_callback(GLFWwindow *window, int width, int height); void framebuffer_size_callback(GLFWwindow *window, int width, int height);
void processInput(GLFWwindow *window); void processInput(GLFWwindow *window);
@ -15,23 +16,31 @@ int main(int argc, char **argv) {
GLFWwindow *window = glfwCreateWindow(800, 600, "Shader Loader", NULL, NULL); GLFWwindow *window = glfwCreateWindow(800, 600, "Shader Loader", NULL, NULL);
if (window == NULL) { if (window == NULL) {
std::cout << "Failed to create GLFW window" << std::endl; printf("Failed to create GLFW window\n");
glfwTerminate(); glfwTerminate();
return -1; return -1;
} }
glfwMakeContextCurrent(window); glfwMakeContextCurrent(window);
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) { if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
std::cout << "Failed to initialize GLAD" << std::endl; printf("Failed to initialize GLAD\n");
return -1; return -1;
} }
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); 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)) { while (!glfwWindowShouldClose(window)) {
processInput(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); glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window); glfwSwapBuffers(window);