vulkanapp-graphics-api
MIT License
- In development [2024.2]!
+ Authors: Gustavo Silva, Danilo Dutra, Cludio Evangelista, Matheus Araujo.
# Work for the Computer Graphics course at the Federal University of Catalo (UFCAT), Gois
This project demonstrates how to draw a triangle on the screen using vertex and fragment shaders in 2D, leveraging the Vulkan API (using the Vulkan SDK provided by LunarG) and the Python language. The code includes all the necessary steps to render the triangle, making it a comprehensive and easy-to-understand example of 2D rendering based on Vulkan.
pip
:
pip install glfw
pip
with the command:
pip install vulkan
Clone the repository:
git clone https://github.com/GustavoBorges13/vulkanapp-graphics-api.git
cd vulkanapp-graphics-api
Install the required Python packages:
pip install -r requirements.txt
Ensure the Vulkan SDK is properly installed on your system. You can check by running:
vulkaninfo
Run the Python script to launch the 3D rotating cube:
python main.py
coming soon
comming soon
To run graphical applications in Docker, you'll need to configure X11 display support based on your operating system.
Ensure Docker is installed and configured on your machine.
You can also follow the windows procedure in a solved problem here. If you need to display graphical applications from Docker on Windows, follow these steps:
Download and Install X Server:
Configure Xlaunch:
Run the Docker Container:
docker run -it --rm --name my_vulkan_app -e DISPLAY=host.docker.internal:0 gustavoborges13/vulkan_app
# If you have an NVIDIA GPU (optional), use:
docker run --gpus all -it --rm --name my_vulkan_app -e DISPLAY=host.docker.internal:0 gustavoborges13/vulkan_app
Xlaunch will run in the background, waiting for X11 applications to connect and use display :0.
To display graphical applications from Docker on Linux, follow these steps:
Install X Server:
Most Linux distributions come with an X server installed. If not, install it using your package manager:
sudo apt-get install xorg
Configure X Server for Docker:
Allow Docker containers to access the X server:
xhost +local:docker
# To revoke access later (optional):
xhost -local:docker
Run the Docker Container:
docker run -it --rm --name my_vulkan_app -e DISPLAY=host.docker.internal:0 -v /tmp/.X11-unix:/tmp/.X11-unix gustavoborges13/vulkan_app
# If you have an NVIDIA GPU (optional), use:
docker run --gpus all -it --rm --name my_vulkan_app -e DISPLAY=host.docker.internal:0 -v /tmp/.X11-unix:/tmp/.X11-unix gustavoborges13/vulkan_app
This setup will allow Docker containers to use the X11 display server on your Linux system.
To display graphical applications from Docker on macOS, follow these steps:
Install X Server:
Configure XQuartz:
Run the Docker Container:
Run the Docker container:
docker run -it --rm --name my_vulkan_app -e DISPLAY=host.docker.internal:0 gustavoborges13/vulkan_app
# If you have an NVIDIA GPU (optional), use:
docker run --gpus all -it --rm --name my_vulkan_app -e DISPLAY=host.docker.internal:0 gustavoborges13/vulkan_app
XQuartz will provide the display server necessary for running X11 applications.
The build will be performed by ./Dockerfile.
Clone the repository:
git clone https://github.com/GustavoBorges13/vulkanapp-graphics-api.git
cd vulkanapp-graphics-api
To build the Docker image, use the following command:
docker build -t vulkanapp-graphics-api .
Run the Docker container:
docker run -it --rm -e DISPLAY=host.docker.internal:0 vulkanapp-graphics-api
# If you have an NVIDIA GPU (optional), use:
docker run --gpus all -it --rm -e DISPLAY=host.docker.internal:0 vulkanapp-graphics-api
This command ensures that the container has access to the GPU and connects to the X Server on your host machine for graphical output.
It's worth remembering that the observations made earlier in the from docker hub procedure apply here too. Have the X server configured and docker installed.
The build will be performed by ./docker-compose.yml.
It's worth remembering that the observations made earlier in the from docker hub procedure apply here too. Have the X server configured and docker installed for the application window to appear.
Clone the repository:
git clone https://github.com/GustavoBorges13/vulkanapp-graphics-api.git
cd vulkanapp-graphics-api
To build the Docker image and run, use the following command:
docker-compose up
For detailed Docker commands, see the docker-commands.md file.
Once the application is running, a window will open displaying a 2D triangle. The triangle will be rendered using vertex and fragment shaders, demonstrating basic 2D rendering with the Vulkan API.
.
.gitignore # Git ignore file
app.py # Window glfw prepare
colors.py # Color handling for print debugMode
commands.py # Command handling and execution
config.py # Python imports general
device.py # Device selection and management
docker-commands.md # Docker commands and setup instructions
docker-compose.yml # Docker Compose configuration
Dockerfile # Docker configuration for building the image
engine.py # Core engine logic for the application
frame.py # Frame handling for rendering
framebuffer.py # Framebuffer management
instance.py # Vulkan instance creation
LICENSE # License file for the project
logging.py # Logging utilities - Validation Layers
main.py # Main application to launch program
memory.py # Memory management for Vulkan
pipeline.py # Pipeline configuration and management
queue_families.py # Queue families management for Vulkan
README.md # Project documentation and overview
requirements.txt # Python dependencies
shaders.py # Shader management for rendering
swapchain.py # Swapchain handling for Vulkan
sync.py # Synchronization primitives
.github
workflows
Docker.yml # GitHub Actions automatic workflow for Docker
shaders # Shader files for the application
compile_shaders.bat # Batch script to compile shaders
frag.spv # Compiled fragment shader
shader.frag # Fragment shader source code
shader.vert # Vertex shader source code
vert.spv # Compiled vertex shader
__pycache__ # Compiled Python files
Dive into the world of Vulkan API! Whether you're new to graphics programming or looking to expand your skills, our guide provides a clear and engaging introduction to Vulkan's core concepts. Start building high-performance graphics applications today! Explore the Wiki