ok, papyrus is now drawing something on screen
This commit is contained in:
parent
1f32af8307
commit
e1a270bfcb
|
|
@ -100,6 +100,14 @@ pub const Renderer = struct {
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn imageExtents(self: @This()) core.Vectorf {
|
||||||
|
_ = self;
|
||||||
|
return .{
|
||||||
|
.x = @floatFromInt(platform.getInstance().windowExtent.x),
|
||||||
|
.y = @floatFromInt(platform.getInstance().windowExtent.y),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
pub fn createRenderTargets(self: *@This()) !void {
|
pub fn createRenderTargets(self: *@This()) !void {
|
||||||
var gci = std.mem.zeroes(gpu.GPUTextureCreateInfo);
|
var gci = std.mem.zeroes(gpu.GPUTextureCreateInfo);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -255,9 +255,29 @@ pub fn drawToTarget(self: *@This(), cmd: *gpu.GPUCommandBuffer, ctx: *papyrus.Co
|
||||||
.store_op = .storeopStore,
|
.store_op = .storeopStore,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
{
|
||||||
|
var data = std.mem.zeroes([@sizeOf(rect_vert.Uniforms) / 8 + 1]usize);
|
||||||
|
const ptr: *rect_vert.Uniforms = @ptrCast(@alignCast(&data));
|
||||||
|
|
||||||
|
ptr.Extents.x = rend.context().imageExtents().x;
|
||||||
|
ptr.Extents.y = rend.context().imageExtents().y;
|
||||||
|
|
||||||
|
cmd.pushGPUVertexUniformData(0, &data, @sizeOf(rect_vert.Uniforms));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// var data = std.mem.zeroes([@sizeOf(rect_frag.Uniforms) / 8 + 1]usize);
|
||||||
|
// const ptr: *rect_frag.Uniforms = @ptrCast(@alignCast(&data));
|
||||||
|
// ptr.Extents.x = rend.context().rendererExtent().x;
|
||||||
|
// ptr.Extents.y = rend.context().rendererExtent().y;
|
||||||
|
|
||||||
|
// cmd.pushGPUFragmentUniformData(0, &data, @sizeOf(rect_frag.Uniforms));
|
||||||
|
}
|
||||||
|
|
||||||
const pass = cmd.beginGPURenderPass(&targetInfo, 1, null);
|
const pass = cmd.beginGPURenderPass(&targetInfo, 1, null);
|
||||||
pass.bindGPUVertexBuffers(1, &.{ .buffer = rend.context().meshPool.vertexBuffer, .offset = 0 }, 1);
|
pass.bindGPUVertexBuffers(0, &.{ .buffer = rend.context().meshPool.vertexBuffer, .offset = 0 }, 1);
|
||||||
pass.bindGPUIndexBuffer(&.{ .buffer = rend.context().meshPool.indexBuffer, .offset = 0 }, .indexelementsize32bit);
|
pass.bindGPUIndexBuffer(&.{ .buffer = rend.context().meshPool.indexBuffer, .offset = 0 }, .indexelementsize32bit);
|
||||||
|
pass.bindGPUFragmentSamplers(0, &.{ .sampler = rend.context().blockySampler, .texture = rend.context().defaultTexture.texture }, 1);
|
||||||
|
|
||||||
if (self.quadMesh) |quadMesh| {
|
if (self.quadMesh) |quadMesh| {
|
||||||
for (self.tempDrawCommand.items) |item| {
|
for (self.tempDrawCommand.items) |item| {
|
||||||
|
|
@ -278,6 +298,8 @@ pub fn drawToTarget(self: *@This(), cmd: *gpu.GPUCommandBuffer, ctx: *papyrus.Co
|
||||||
}
|
}
|
||||||
|
|
||||||
pass.endGPURenderPass();
|
pass.endGPURenderPass();
|
||||||
|
|
||||||
|
self.tempDrawCommand.clearRetainingCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const rect_frag = @import("rect.frag");
|
pub const rect_frag = @import("rect.frag");
|
||||||
|
|
|
||||||
|
|
@ -96,11 +96,12 @@ pub const ExternGameObject = struct {
|
||||||
const ctx = ui.getScreen();
|
const ctx = ui.getScreen();
|
||||||
const panel2 = try ctx.addPanel(.{});
|
const panel2 = try ctx.addPanel(.{});
|
||||||
{
|
{
|
||||||
ctx.getPanel(panel2).hasTitle = false;
|
ctx.getPanel(panel2).hasTitle = true;
|
||||||
ctx.get(panel2).anchor = .TopRight;
|
//ctx.get(panel2).anchor = .TopRight;
|
||||||
// ctx.get(panel2).fill = .FillY; todo, this is a bug. why.
|
// ctx.get(panel2).fill = .FillY; todo, this is a bug. why.
|
||||||
ctx.get(panel2).pos = .{ .x = -105, .y = 1 };
|
ctx.get(panel2).pos = .{ .x = 200, .y = 200 };
|
||||||
ctx.get(panel2).size = .{ .x = 100, .y = 1 };
|
ctx.get(panel2).size = .{ .x = 100, .y = 100 };
|
||||||
|
ctx.get(panel2).style.backgroundColor = ui.ModernStyle.GreyDark;
|
||||||
ctx.getPanel(panel2).titleColor = ui.ModernStyle.GreyDark;
|
ctx.getPanel(panel2).titleColor = ui.ModernStyle.GreyDark;
|
||||||
|
|
||||||
// add some text to this panel
|
// add some text to this panel
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue