Compare commits

...

2 Commits

Author SHA1 Message Date
3db30fee6e A load of stuff 2026-02-20 13:38:05 +00:00
7dc47faeab Auto shader compilation 2026-02-20 12:11:06 +00:00
8 changed files with 95 additions and 12 deletions

23
Dockerfile Normal file
View File

@@ -0,0 +1,23 @@
FROM ubuntu:22.04
# Install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
git \
vulkan-tools \
libvulkan-dev \
vulkan-validationlayers \
spirv-tools \
libxxf86vm-dev \
libxi-dev \
libglfw3-dev \
libglm-dev \
wget \
&& rm -rf /var/lib/apt/lists/*
# Install glslc
RUN wget -O /tmp/glslc.deb https://storage.googleapis.com/shaderc/badges/build_link_linux_gcc_release.html && \
apt-get update && apt-get install -y /tmp/glslc.deb || true
WORKDIR /workspace

View File

@@ -1,13 +1,17 @@
CFLAGS = -std=c++17 -O2 CFLAGS = -std=c++17 -O2
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
VulkanTest: *.cpp *.hpp SOURCES = $(wildcard *.cpp)
g++ $(CFLAGS) -o a.out *.cpp $(LDFLAGS) HEADERS = $(wildcard *.hpp)
VulkanTest: $(SOURCES) $(HEADERS)
./compile.sh
g++ $(CFLAGS) -o VulkanTest $(SOURCES) $(LDFLAGS)
.PHONY: test clean .PHONY: test clean
test: a.out test: VulkanTest
./a.out ./VulkanTest
clean: clean:
rm -f a.out rm -f VulkanTest

37
README.md Normal file
View File

@@ -0,0 +1,37 @@
# Most linux distros
## To build the container
`docker build -t vulkan-dev .`
## To run the container
```sh
sudo docker run -it \
--device /dev/dri \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v "$(pwd)":/workspace \
vulkan-dev
```
## To enable X11 access:
`xhost +local:docker`
# Windows
## To build the container (in powershell)
`docker build -t vulkan-dev .`
## To run it
### Option one with WSLg (recommended)
```sh
docker run -it \
-v "$(pwd)":/workspace \
vulkan-dev
```
### Option two with VcXsrv
Set display in powershell:
`$env:DISPLAY="host.docker.internal:0.0"`
Run container:
```sh
docker run -it `
-e DISPLAY=host.docker.internal:0.0 `
-v ${PWD}:/workspace `
vulkan-dev
```
Not working

BIN
VulkanTest Executable file

Binary file not shown.

22
cve_model.hpp Normal file
View File

@@ -0,0 +1,22 @@
#pragma once
#include "cve_device.hpp"
namespace cve {
class CveModel {
public:
CveModel();
~CveModel();
CveModel(const CveModel &) = delete;
CveModel &operator=(const CveModel &) = delete;
void bind(VkCommandBuffer commandBuffer);
void draw(VkCommandBuffer commandBuffer);
private:
CveDevice &cveDevice;
VkBuffer vertexBuffer;
VkDeviceMemory vertexBufferMemory;
uint32_t vertexCount;
};
}

View File

@@ -3,5 +3,5 @@
layout (location = 0) out vec4 outColor; layout (location = 0) out vec4 outColor;
void main() { void main() {
outColor = vec4(1.0, 0.0, 0.0, 1.0); outColor = vec4(1.0, 1.0, 0.0, 1.0);
} }

Binary file not shown.

View File

@@ -1,10 +1,7 @@
#version 450 #version 450
vec2 positions[3] = vec2[] ( layout(location = 0) in vec2 position;
vec2(0.0, -0.5),
vec2(0.5, 0.5),
vec2(-0.5, 0.5)
);
void main() { void main() {
gl_Position = vec4(positions[gl_VertexIndex], 0.0, 1.0); gl_Position = vec4(position, 0.0, 1.0);
} }