vec4 and indices
This commit is contained in:
29
src/main.zig
29
src/main.zig
@@ -19,7 +19,7 @@ const Vertex = extern struct {
|
||||
.{
|
||||
.binding = 0,
|
||||
.location = 0,
|
||||
.format = .r32g32_sfloat,
|
||||
.format = .r32g32b32a32_sfloat,
|
||||
.offset = @offsetOf(Vertex, "pos"),
|
||||
},
|
||||
.{
|
||||
@@ -30,20 +30,25 @@ const Vertex = extern struct {
|
||||
},
|
||||
};
|
||||
|
||||
pos: [2]f32,
|
||||
pos: [4]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 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 {
|
||||
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 };
|
||||
|
||||
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);
|
||||
const window = c.glfwCreateWindow(
|
||||
@intCast(extent.width),
|
||||
@@ -377,7 +384,7 @@ fn createPipeline(gc: *const GraphicsContext, layout: vk.PipelineLayout, swapcha
|
||||
.rasterizer_discard_enable = vk.FALSE,
|
||||
.polygon_mode = .fill,
|
||||
.cull_mode = .{ .back_bit = true },
|
||||
.front_face = .clockwise,
|
||||
.front_face = .counter_clockwise,
|
||||
.depth_bias_enable = vk.FALSE,
|
||||
.depth_bias_constant_factor = 0,
|
||||
.depth_bias_clamp = 0,
|
||||
|
Reference in New Issue
Block a user