Skip to content

Instantly share code, notes, and snippets.

Avatar

Pavlo Stavytskyi Morfly

View GitHub Profile
View main.cpp
// triangle/main.cpp
...
void createGraphicsPipeline() {
auto vertShaderCode = readFile("triangle/shaders/shader.vert.spv");
auto fragShaderCode = readFile("triangle/shaders/shader.frag.spv");
...
}
View BUILD
# triangle/BUILD
load("@rules_cc//cc:defs.bzl", "cc_binary")
cc_binary(
name = "triangle",
srcs = glob(["*.cpp"]),
data = [
"//triangle/shaders:vert_shader",
"//triangle/shaders:frag_shader",
],
View BUILD
# triangle/shaders/BUILD
load("@rules_vulkan//glsl:defs.bzl", "glsl_shader")
package(default_visibility = ["//triangle:__pkg__"])
glsl_shader(
name = "vert_shader",
shader = "shader.vert",
)
View shader.vert
// triangle/shaders/shader.vert
#version 450
layout(location = 0) out vec3 fragColor;
vec2 positions[3] = vec2[](
vec2(0.0, -0.5),
vec2(0.5, 0.5),
vec2(-0.5, 0.5)
);
View shader.frag
// triangle/shaders/shader.frag
#version 450
layout(location = 0) in vec3 fragColor;
layout(location = 0) out vec4 outColor;
void main() {
outColor = vec4(fragColor, 1.0);
}
View main.cpp
// env_setup/main.cpp
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
#define GLM_FORCE_RADIANS
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#include <glm/vec4.hpp>
#include <glm/mat4x4.hpp>
#include <iostream>
View WORKSPACE
# WORKSPACE
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
git_repository(
name = "rules_vulkan",
remote = "https://github.com/jadarve/rules_vulkan.git",
tag = "v0.0.6"
)
load("@rules_vulkan//vulkan:repositories.bzl", "vulkan_repositories")
View BUILD
# third_party/glfw/BUILD
package(default_visibility = ["//visibility:public"])
alias(
name = "glfw",
actual = "@glfw",
)
View WORKSPACE
# WORKSPACE
...
GLFW_VERSION = "3.3.5"
http_archive(
name = "glfw",
build_file = "@//third_party/glfw:glfw.BUILD",
sha256 = "a89bb6074bc12bc12fcd322dcf848af81b679ccdc695f70b29ca8a9aa066684b",
strip_prefix = "glfw-{}".format(GLFW_VERSION),
urls = ["https://github.com/glfw/glfw/archive/{}.zip".format(GLFW_VERSION)],
View BUILD
# third_party/glfw/glfw.BUILD
...
cc_library(
name = "glfw",
hdrs = [
"include/GLFW/glfw3.h",
"include/GLFW/glfw3native.h",
],
linkopts = select({
"@bazel_tools//src/conditions:windows": WIN32_LINKOPTS,