vec4 and indices
This commit is contained in:
@@ -109,7 +109,7 @@ pub const GraphicsContext = struct {
|
|||||||
.application_version = vk.makeApiVersion(0, 0, 0, 0),
|
.application_version = vk.makeApiVersion(0, 0, 0, 0),
|
||||||
.p_engine_name = app_name,
|
.p_engine_name = app_name,
|
||||||
.engine_version = vk.makeApiVersion(0, 0, 0, 0),
|
.engine_version = vk.makeApiVersion(0, 0, 0, 0),
|
||||||
.api_version = vk.API_VERSION_1_2,
|
.api_version = vk.API_VERSION_1_3,
|
||||||
};
|
};
|
||||||
|
|
||||||
self.instance = try self.vkb.createInstance(&.{
|
self.instance = try self.vkb.createInstance(&.{
|
||||||
|
29
src/main.zig
29
src/main.zig
@@ -19,7 +19,7 @@ const Vertex = extern struct {
|
|||||||
.{
|
.{
|
||||||
.binding = 0,
|
.binding = 0,
|
||||||
.location = 0,
|
.location = 0,
|
||||||
.format = .r32g32_sfloat,
|
.format = .r32g32b32a32_sfloat,
|
||||||
.offset = @offsetOf(Vertex, "pos"),
|
.offset = @offsetOf(Vertex, "pos"),
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
@@ -30,20 +30,25 @@ const Vertex = extern struct {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
pos: [2]f32,
|
pos: [4]f32,
|
||||||
color: [3]f32,
|
color: [3]f32,
|
||||||
};
|
};
|
||||||
|
|
||||||
const vertices = [_]Vertex{
|
|
||||||
.{ .pos = .{ -0.5, -0.5 }, .color = .{ 1, 0, 0 } },
|
|
||||||
.{ .pos = .{ -0.5, 0.5 }, .color = .{ 0, 1, 0 } },
|
|
||||||
.{ .pos = .{ 0.5, -0.5 }, .color = .{ 0, 0, 1 } },
|
|
||||||
.{ .pos = .{ 0.5, 0.5 }, .color = .{ 1, 1, 0 } },
|
|
||||||
};
|
|
||||||
|
|
||||||
const Index = u16;
|
const Index = u16;
|
||||||
|
|
||||||
const indices = [_]Index{ 0, 2, 1, 1, 2, 3 };
|
const vertices = [_]Vertex{
|
||||||
|
// Vulkan depth range is 0, 1 instead of OpenGL -1, 1
|
||||||
|
.{ .pos = .{ -0.5, -0.5, -0.5, 1.0 }, .color = .{ 1, 0, 0 } },
|
||||||
|
.{ .pos = .{ -0.5, 0.5, -0.5, 1.0 }, .color = .{ 0, 1, 0 } },
|
||||||
|
.{ .pos = .{ 0.5, -0.5, -0.5, 1.0 }, .color = .{ 0, 0, 1 } },
|
||||||
|
.{ .pos = .{ 0.5, 0.5, -0.5, 1.0 }, .color = .{ 1, 1, 0 } },
|
||||||
|
.{ .pos = .{ -0.5, -0.5, 0.5, 1.0 }, .color = .{ 1, 0, 0 } },
|
||||||
|
.{ .pos = .{ -0.5, 0.5, 0.5, 1.0 }, .color = .{ 0, 1, 0 } },
|
||||||
|
.{ .pos = .{ 0.5, -0.5, 0.5, 1.0 }, .color = .{ 0, 0, 1 } },
|
||||||
|
.{ .pos = .{ 0.5, 0.5, 0.5, 1.0 }, .color = .{ 1, 1, 0 } },
|
||||||
|
};
|
||||||
|
|
||||||
|
const indices = [_]Index{ 4, 5, 6, 6, 5, 7 };
|
||||||
|
|
||||||
pub fn main() !void {
|
pub fn main() !void {
|
||||||
if (c.glfwInit() != c.GLFW_TRUE) return error.GlfwInitFailed;
|
if (c.glfwInit() != c.GLFW_TRUE) return error.GlfwInitFailed;
|
||||||
@@ -56,6 +61,8 @@ pub fn main() !void {
|
|||||||
|
|
||||||
var extent = vk.Extent2D{ .width = 800, .height = 600 };
|
var extent = vk.Extent2D{ .width = 800, .height = 600 };
|
||||||
|
|
||||||
|
c.glfwWindowHintString(c.GLFW_X11_CLASS_NAME, "floating_window");
|
||||||
|
c.glfwWindowHintString(c.GLFW_X11_INSTANCE_NAME, "floating_window");
|
||||||
c.glfwWindowHint(c.GLFW_CLIENT_API, c.GLFW_NO_API);
|
c.glfwWindowHint(c.GLFW_CLIENT_API, c.GLFW_NO_API);
|
||||||
const window = c.glfwCreateWindow(
|
const window = c.glfwCreateWindow(
|
||||||
@intCast(extent.width),
|
@intCast(extent.width),
|
||||||
@@ -377,7 +384,7 @@ fn createPipeline(gc: *const GraphicsContext, layout: vk.PipelineLayout, swapcha
|
|||||||
.rasterizer_discard_enable = vk.FALSE,
|
.rasterizer_discard_enable = vk.FALSE,
|
||||||
.polygon_mode = .fill,
|
.polygon_mode = .fill,
|
||||||
.cull_mode = .{ .back_bit = true },
|
.cull_mode = .{ .back_bit = true },
|
||||||
.front_face = .clockwise,
|
.front_face = .counter_clockwise,
|
||||||
.depth_bias_enable = vk.FALSE,
|
.depth_bias_enable = vk.FALSE,
|
||||||
.depth_bias_constant_factor = 0,
|
.depth_bias_constant_factor = 0,
|
||||||
.depth_bias_clamp = 0,
|
.depth_bias_clamp = 0,
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
#version 450
|
#version 450
|
||||||
|
|
||||||
layout(location = 0) in vec2 a_pos;
|
layout(location = 0) in vec4 a_pos;
|
||||||
layout(location = 1) in vec3 a_color;
|
layout(location = 1) in vec3 a_color;
|
||||||
|
|
||||||
layout(location = 0) out vec3 v_color;
|
layout(location = 0) out vec3 v_color;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
gl_Position = vec4(a_pos, 0.0, 1.0);
|
gl_Position = a_pos;
|
||||||
v_color = a_color;
|
v_color = a_color;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user