Skip to content

Instantly share code, notes, and snippets.

View Morfly's full-sized avatar

Pavlo Stavytskyi Morfly

View GitHub Profile
# triangle/shaders/BUILD
load("@rules_vulkan//glsl:defs.bzl", "glsl_shader")
package(default_visibility = ["//triangle:__pkg__"])
glsl_shader(
name = "vert_shader",
shader = "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)
);
@Morfly
Morfly / shader.frag
Last active September 5, 2022 03:31
// 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);
}
// 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>
# 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")
# third_party/glfw/BUILD
package(default_visibility = ["//visibility:public"])
alias(
name = "glfw",
actual = "@glfw",
)
# 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)],
# 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,
# third_party/glfw/glfw.BUILD
...
objc_library(
name = "glfw_src_darwin",
srcs = COMMON_SRCS + DARWIN_SRCS,
hdrs = COMMON_HDRS + DARWIN_HDRS,
copts = ["-fno-objc-arc"],
defines = DARWIN_DEFINES,
)
# third_party/glfw/glfw.BUILD
...
cc_library(
name = "glfw_src",
srcs = COMMON_SRCS + select({
"@bazel_tools//src/conditions:windows": WIN32_SRCS,
"@bazel_tools//src/conditions:linux_x86_64": LINUX_SRCS,
}),
hdrs = COMMON_HDRS + select({
"@bazel_tools//src/conditions:windows": WIN32_HDRS,