Add 4 triangle
This commit is contained in:
parent
9256da2094
commit
e58a357381
3 changed files with 55 additions and 12 deletions
|
@ -12,7 +12,7 @@ use vulkano::sync::GpuFuture;
|
|||
use winit::application::ApplicationHandler;
|
||||
use winit::event::WindowEvent;
|
||||
use winit::event_loop::{ActiveEventLoop, EventLoop};
|
||||
use winit::window::{Window, WindowId};
|
||||
use winit::window::WindowId;
|
||||
use crate::renderer::render_context::RenderContext;
|
||||
use crate::renderer::{window_size_dependent_setup, Scene};
|
||||
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
use std::sync::Arc;
|
||||
use vulkano::device::Device;
|
||||
use vulkano::image::{Image, ImageUsage};
|
||||
use vulkano::image::ImageUsage;
|
||||
use vulkano::image::view::ImageView;
|
||||
use vulkano::pipeline::graphics::subpass::PipelineRenderingCreateInfo;
|
||||
use vulkano::pipeline::graphics::viewport::Viewport;
|
||||
use vulkano::pipeline::GraphicsPipeline;
|
||||
use vulkano::render_pass::{Framebuffer, RenderPass};
|
||||
use vulkano::swapchain::{Surface, Swapchain, SwapchainCreateInfo};
|
||||
use vulkano::sync;
|
||||
use vulkano::sync::GpuFuture;
|
||||
|
|
|
@ -164,17 +164,60 @@ impl Scene {
|
|||
|
||||
// We now create a buffer that will store the shape of our triangle.
|
||||
let vertices = [
|
||||
// Triangle en haut à gauche
|
||||
MyVertex {
|
||||
position: [-0.5, -0.25],
|
||||
color: [1.0, 0.0, 0.0],
|
||||
position: [-0.5, -0.75], // Coin supérieur gauche
|
||||
color: [1.0, 0.0, 0.0], // Couleur rouge
|
||||
},
|
||||
MyVertex {
|
||||
position: [0.0, 0.5],
|
||||
color: [0.0, 1.0, 0.0],
|
||||
position: [-0.75, -0.25], // Coin supérieur
|
||||
color: [0.0, 1.0, 0.0], // Couleur verte
|
||||
},
|
||||
MyVertex {
|
||||
position: [0.25, -0.1],
|
||||
color: [0.0, 0.0, 1.0],
|
||||
position: [-0.25, -0.25], // Coin supérieur droit
|
||||
color: [0.0, 0.0, 1.0], // Couleur bleue
|
||||
},
|
||||
|
||||
// Triangle en bas à gauche
|
||||
MyVertex {
|
||||
position: [-0.5, 0.25], // Coin inférieur gauche
|
||||
color: [0.5, 0.5, 0.5], // Couleur gris
|
||||
},
|
||||
MyVertex {
|
||||
position: [-0.75, 0.75], // Coin inférieur
|
||||
color: [0.2, 0.8, 0.2], // Couleur vert clair
|
||||
},
|
||||
MyVertex {
|
||||
position: [-0.25, 0.75], // Coin inférieur droit
|
||||
color: [0.8, 0.2, 0.2], // Couleur rouge clair
|
||||
},
|
||||
|
||||
// Triangle en haut à droite
|
||||
MyVertex {
|
||||
position: [0.5, -0.75], // Coin gauche supérieur
|
||||
color: [1.0, 1.0, 0.0], // Couleur jaune
|
||||
},
|
||||
MyVertex {
|
||||
position: [0.25, -0.25], // Coin gauche
|
||||
color: [0.0, 1.0, 1.0], // Couleur cyan
|
||||
},
|
||||
MyVertex {
|
||||
position: [0.75, -0.25], // Coin gauche inférieur
|
||||
color: [1.0, 0.0, 1.0], // Couleur magenta
|
||||
},
|
||||
|
||||
// Triangle en bas à droite
|
||||
MyVertex {
|
||||
position: [0.5, 0.25], // Coin droit supérieur
|
||||
color: [0.1, 0.5, 0.8], // Couleur bleu clair
|
||||
},
|
||||
MyVertex {
|
||||
position: [0.25, 0.75], // Coin droit
|
||||
color: [0.8, 0.6, 0.1], // Couleur or
|
||||
},
|
||||
MyVertex {
|
||||
position: [0.75, 0.75], // Coin droit inférieur
|
||||
color: [0.3, 0.4, 0.6], // Couleur bleu foncé
|
||||
},
|
||||
];
|
||||
let vertex_buffer = Buffer::from_iter(
|
||||
|
@ -205,6 +248,9 @@ impl Scene {
|
|||
.unwrap();
|
||||
|
||||
// We add a draw command.
|
||||
unsafe { builder.draw(self.vertex_buffer.len() as u32, 1, 0, 0) }.unwrap();
|
||||
let vertex_count = self.vertex_buffer.len() as u32;
|
||||
let instance_count = vertex_count / 3;
|
||||
|
||||
unsafe { builder.draw(vertex_count, instance_count, 0, 0) }.unwrap();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue