Fix image generation

This commit is contained in:
hodasemi 2023-01-20 16:15:19 +01:00
parent 49c716e0e4
commit 5248070a0f
3 changed files with 17 additions and 28 deletions

View file

@ -24,9 +24,7 @@ impl BackgroundGenerator {
let image = Image::empty(
*width as u32,
*height as u32,
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
| VK_IMAGE_USAGE_SAMPLED_BIT
| VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
VK_SAMPLE_COUNT_1_BIT,
)
.format(VK_FORMAT_R8G8B8A8_UNORM)
@ -109,38 +107,29 @@ impl BackgroundGenerator {
image.width() as f32,
0.00,
image.height() as f32,
0.0,
-1.0,
1.0,
);
let command_buffer =
CommandBuffer::new_primary().build(device.clone(), queue.clone())?;
// let corners = [
// vec2(0.0, 0.0),
// vec2(0.0, image.height() as f32),
// vec2(image.width() as f32, image.height() as f32),
// vec2(image.width() as f32, 0.0),
// ];
// angle 70°
let angle: Deg<f32> = Deg(70.0);
let tan = angle.0.atan();
let corners = [
vec2(0.0, 0.0),
vec2((image.height() as f32) / tan, image.height() as f32),
vec2(image.width() as f32, image.height() as f32),
vec2(image.width() as f32 - (image.height() as f32) / tan, 0.0),
];
println!("width: {} height: {}", image.width(), image.height());
for corner in corners.iter() {
println!("corner: {:?}", corner);
}
let vertices = PositionOnlyVertex::from_2d_corners(ortho, corners);
let vertices = PositionOnlyVertex::from_2d_corners(
ortho,
[
vec2(0.0, image.height() as f32),
vec2((image.height() as f32) / tan, 0.0),
vec2(image.width() as f32, 0.0),
vec2(
image.width() as f32 - (image.height() as f32) / tan,
image.height() as f32,
),
],
);
let vertex_buffer = Buffer::builder()
.set_usage(VK_BUFFER_USAGE_VERTEX_BUFFER_BIT)
@ -199,7 +188,7 @@ mod test {
let queue_info = Queue::create_non_presentable_request_info(
&physical_device,
VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_TRANSFER_BIT | VK_QUEUE_COMPUTE_BIT,
VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_TRANSFER_BIT,
)?;
let device = Device::new(

View file

@ -89,7 +89,7 @@ impl Pedals {
history_image.height(),
)?;
let ortho = ortho(0.0, history_image.width() as f32, -0.01, 1.01, 0.0, 1.0);
let ortho = ortho(0.0, history_image.width() as f32, -0.01, 1.01, -1.0, 1.0);
let descriptor_pool = DescriptorPool::builder()
.set_layout(pipeline.descriptor_layout().clone())

View file

@ -105,7 +105,7 @@ impl Radar {
rendering.swapchain().width() as f32,
0.0,
rendering.swapchain().height() as f32,
0.0,
-1.0,
1.0,
);