A direct conversion of this vulkan example to C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
load-library "/usr/local/lib/libwgpu_native.so" | |
load-library "/usr/lib/libglfw.so.3" | |
run-stage; | |
include; | |
""""#include <wgpu.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <GLFW/glfw3.h> | |
#define GLFW_EXPOSE_NATIVE_X11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using import struct | |
inline Slice (T) | |
struct ("[" .. (tostring T) .. "]") | |
first : (mutable pointer T) | |
size : usize | |
inline __countof (self) | |
self.size | |
fn slice (array start end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline va-type@ (T args...) | |
va-lfold none | |
inline "#hidden" (key value) | |
static-if ((typeof value) <= T) | |
return value | |
args... | |
inline va-type@... (T args...) | |
va-rfold none | |
inline (key value result...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local layout-bindings = | |
arrayof wgpu.BindGroupLayoutBinding | |
typeinit | |
binding = 0 | |
visibility = wgpu.ShaderStage.COMPUTE | |
ty = wgpu.BindingType.StorageTexture | |
let size = 0x10 | |
let texture = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#version 460 | |
layout(local_size_x = 4, local_size_y = 4, local_size_z = 4) in; | |
struct Sphere { | |
vec4 center; | |
}; | |
layout(binding = 1, std140) uniform Camera { | |
vec4 pos; | |
vec4 dir; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#version 450 | |
layout(location = 0) in vec2 v_TexCoord; | |
layout(location = 0) out vec4 o_Target; | |
layout(set = 0, binding = 1) uniform texture2D t_Color; | |
layout(set = 0, binding = 2) uniform sampler s_Color; | |
void main() { | |
o_Target = texture(sampler2D(t_Color, s_Color), v_TexCoord); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline value-to-number-maker (number-type) | |
fn (value) | |
match ('typeof value) | |
case i8 | |
number-type | |
value as i8 | |
case i16 | |
number-type | |
value as i16 | |
case i32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import .glfw | |
fn start-glfw () | |
if ((glfw.init) == 0) | |
return; | |
defer glfw.terminate | |
let window = | |
glfw.createWindow 640 480 "Hello World" null null | |
if (window == null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using import ..pijul.utils.va | |
#inline va-pos (val args...) | |
va-lifold none | |
inline "#hidden" (i key arg result) | |
dump i key arg result | |
static-if (not (none? result)) result | |
elseif (arg == val) i | |
else result | |
args... |
OlderNewer