mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-25 16:25:31 +00:00
Upgrade examples to rust 2018 (#1131)
This commit is contained in:
parent
f997e9322f
commit
34eeea6b52
@ -1,14 +1,22 @@
|
||||
[package]
|
||||
name = "examples"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>"]
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
# The `vulkano` crate is the main crate that you must use to use Vulkan.
|
||||
vulkano = { path = "../vulkano" }
|
||||
# Provides the `shader!` macro that is used to generate code for using shaders.
|
||||
vulkano-shaders = { path = "../vulkano-shaders" }
|
||||
# The Vulkan library doesn't provide any functionality to create and handle windows, as
|
||||
# this would be out of scope. In order to open a window, we are going to use the `winit` crate.
|
||||
winit = "0.18"
|
||||
# The `vulkano_win` crate is the link between `vulkano` and `winit`. Vulkano doesn't know about winit,
|
||||
# and winit doesn't know about vulkano, so import a crate that will provide a link between the two.
|
||||
vulkano-win = { path = "../vulkano-win" }
|
||||
|
||||
cgmath = "0.16.1"
|
||||
image = "0.20.0"
|
||||
winit = "0.18"
|
||||
time = "0.1.38"
|
||||
|
@ -13,10 +13,6 @@
|
||||
// been more or more used for general-purpose operations as well. This is called "General-Purpose
|
||||
// GPU", or *GPGPU*. This is what this example demonstrates.
|
||||
|
||||
// Note that since we don't create any window, fewer imports are needed.
|
||||
extern crate vulkano;
|
||||
extern crate vulkano_shaders;
|
||||
|
||||
use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer};
|
||||
use vulkano::command_buffer::AutoCommandBufferBuilder;
|
||||
use vulkano::descriptor::descriptor_set::PersistentDescriptorSet;
|
||||
|
@ -7,8 +7,6 @@
|
||||
// notice may not be copied, modified, or distributed except
|
||||
// according to those terms.
|
||||
|
||||
extern crate vulkano;
|
||||
|
||||
use vulkano::device::{Device, DeviceExtensions};
|
||||
use vulkano::format::Format;
|
||||
use vulkano::image::ImmutableImage;
|
||||
|
@ -140,7 +140,7 @@ impl AmbientLightingSystem {
|
||||
struct Vertex {
|
||||
position: [f32; 2]
|
||||
}
|
||||
impl_vertex!(Vertex, position);
|
||||
vulkano::impl_vertex!(Vertex, position);
|
||||
|
||||
mod vs {
|
||||
vulkano_shaders::shader!{
|
||||
|
@ -152,7 +152,7 @@ impl DirectionalLightingSystem {
|
||||
struct Vertex {
|
||||
position: [f32; 2]
|
||||
}
|
||||
impl_vertex!(Vertex, position);
|
||||
vulkano::impl_vertex!(Vertex, position);
|
||||
|
||||
mod vs {
|
||||
vulkano_shaders::shader!{
|
||||
|
@ -166,7 +166,7 @@ impl PointLightingSystem {
|
||||
struct Vertex {
|
||||
position: [f32; 2]
|
||||
}
|
||||
impl_vertex!(Vertex, position);
|
||||
vulkano::impl_vertex!(Vertex, position);
|
||||
|
||||
mod vs {
|
||||
vulkano_shaders::shader!{
|
||||
|
@ -25,9 +25,9 @@ use vulkano::image::ImageUsage;
|
||||
use vulkano::image::ImageViewAccess;
|
||||
use vulkano::sync::GpuFuture;
|
||||
|
||||
use frame::ambient_lighting_system::AmbientLightingSystem;
|
||||
use frame::directional_lighting_system::DirectionalLightingSystem;
|
||||
use frame::point_lighting_system::PointLightingSystem;
|
||||
use crate::frame::ambient_lighting_system::AmbientLightingSystem;
|
||||
use crate::frame::directional_lighting_system::DirectionalLightingSystem;
|
||||
use crate::frame::point_lighting_system::PointLightingSystem;
|
||||
|
||||
/// System that contains the necessary facilities for rendering a single frame.
|
||||
pub struct FrameSystem {
|
||||
@ -95,7 +95,7 @@ impl FrameSystem {
|
||||
// but can't deal with these restrictions, then you should create multiple render passes
|
||||
// instead.
|
||||
let render_pass = Arc::new(
|
||||
ordered_passes_renderpass!(gfx_queue.device().clone(),
|
||||
vulkano::ordered_passes_renderpass!(gfx_queue.device().clone(),
|
||||
attachments: {
|
||||
// The image that will contain the final rendering (in this example the swapchain
|
||||
// image, but it could be another image).
|
||||
|
@ -26,13 +26,6 @@
|
||||
// expensive otherwise. It has some drawbacks, which are the fact that transparent objects must be
|
||||
// drawn after the lighting, and that the whole process consumes more memory.
|
||||
|
||||
extern crate cgmath;
|
||||
#[macro_use]
|
||||
extern crate vulkano;
|
||||
extern crate vulkano_shaders;
|
||||
extern crate winit;
|
||||
extern crate vulkano_win;
|
||||
|
||||
use vulkano::device::{Device, DeviceExtensions};
|
||||
use vulkano::instance::{Instance, PhysicalDevice};
|
||||
use vulkano::swapchain::{AcquireError, PresentMode, SurfaceTransform, Swapchain, SwapchainCreationError};
|
||||
@ -51,8 +44,8 @@ use cgmath::Vector3;
|
||||
mod frame;
|
||||
mod triangle_draw_system;
|
||||
|
||||
use frame::*;
|
||||
use triangle_draw_system::*;
|
||||
use crate::frame::*;
|
||||
use crate::triangle_draw_system::*;
|
||||
|
||||
fn main() {
|
||||
// Basic initialization. See the triangle example if you want more details about this.
|
||||
|
@ -92,7 +92,7 @@ impl TriangleDrawSystem {
|
||||
struct Vertex {
|
||||
position: [f32; 2]
|
||||
}
|
||||
impl_vertex!(Vertex, position);
|
||||
vulkano::impl_vertex!(Vertex, position);
|
||||
|
||||
mod vs {
|
||||
vulkano_shaders::shader!{
|
||||
|
@ -7,15 +7,6 @@
|
||||
// notice may not be copied, modified, or distributed except
|
||||
// according to those terms.
|
||||
|
||||
|
||||
#[macro_use]
|
||||
extern crate vulkano;
|
||||
extern crate vulkano_shaders;
|
||||
extern crate vulkano_win;
|
||||
extern crate winit;
|
||||
extern crate cgmath;
|
||||
extern crate image;
|
||||
|
||||
use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer};
|
||||
use vulkano::command_buffer::{AutoCommandBufferBuilder, DynamicState};
|
||||
use vulkano::descriptor::descriptor_set::PersistentDescriptorSet;
|
||||
@ -87,7 +78,7 @@ fn main() {
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct Vertex { position: [f32; 2] }
|
||||
impl_vertex!(Vertex, position);
|
||||
vulkano::impl_vertex!(Vertex, position);
|
||||
|
||||
let vertex_buffer = CpuAccessibleBuffer::<[Vertex]>::from_iter(
|
||||
device.clone(),
|
||||
@ -104,7 +95,7 @@ fn main() {
|
||||
let fs = fs::Shader::load(device.clone()).unwrap();
|
||||
|
||||
let render_pass = Arc::new(
|
||||
single_pass_renderpass!(device.clone(),
|
||||
vulkano::single_pass_renderpass!(device.clone(),
|
||||
attachments: {
|
||||
color: {
|
||||
load: Clear,
|
||||
|
@ -64,11 +64,6 @@
|
||||
//! an error), instead it is called *resolving* the image.
|
||||
//!
|
||||
|
||||
extern crate image;
|
||||
#[macro_use]
|
||||
extern crate vulkano;
|
||||
extern crate vulkano_shaders;
|
||||
|
||||
use std::sync::Arc;
|
||||
use image::ImageBuffer;
|
||||
use image::Rgba;
|
||||
@ -108,7 +103,7 @@ fn main() {
|
||||
// into a non-multisampled one) as part of the render pass. This is the preferred method of
|
||||
// doing so, as it the advantage that the Vulkan implementation doesn't have to write the
|
||||
// content of the multisampled image back to memory at the end.
|
||||
let render_pass = Arc::new(single_pass_renderpass!(
|
||||
let render_pass = Arc::new(vulkano::single_pass_renderpass!(
|
||||
device.clone(),
|
||||
attachments: {
|
||||
// The first framebuffer attachment is the intermediary image.
|
||||
@ -187,7 +182,7 @@ void main() {
|
||||
struct Vertex {
|
||||
position: [f32; 2],
|
||||
}
|
||||
impl_vertex!(Vertex, position);
|
||||
vulkano::impl_vertex!(Vertex, position);
|
||||
|
||||
let vertex1 = Vertex { position: [-0.5, -0.5] };
|
||||
let vertex2 = Vertex { position: [ 0.0, 0.5] };
|
||||
|
@ -8,8 +8,6 @@
|
||||
// according to those terms.
|
||||
|
||||
// TODO: Give a paragraph about what push constants are and what problems they solve
|
||||
extern crate vulkano;
|
||||
extern crate vulkano_shaders;
|
||||
|
||||
use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer};
|
||||
use vulkano::command_buffer::AutoCommandBufferBuilder;
|
||||
|
@ -18,10 +18,6 @@
|
||||
// $ glslangValidator vert.glsl -V -S vert -o vert.spv
|
||||
// $ glslangValidator frag.glsl -V -S frag -o frag.spv
|
||||
// Vulkano uses glslangValidator to build your shaders internally.
|
||||
#[macro_use]
|
||||
extern crate vulkano;
|
||||
extern crate vulkano_win;
|
||||
extern crate winit;
|
||||
|
||||
use vulkano as vk;
|
||||
use vulkano::buffer::BufferUsage;
|
||||
@ -62,7 +58,7 @@ pub struct Vertex {
|
||||
pub color: [f32; 3],
|
||||
}
|
||||
|
||||
impl_vertex!(Vertex, position, color);
|
||||
vulkano::impl_vertex!(Vertex, position, color);
|
||||
|
||||
fn main() {
|
||||
let instance = vk::instance::Instance::new(None, &vulkano_win::required_extensions(), None).unwrap();
|
||||
@ -99,7 +95,7 @@ fn main() {
|
||||
1, usage, &queue, SurfaceTransform::Identity, alpha, PresentMode::Fifo, true, None).unwrap()
|
||||
};
|
||||
|
||||
let render_pass = Arc::new(single_pass_renderpass!(
|
||||
let render_pass = Arc::new(vulkano::single_pass_renderpass!(
|
||||
device.clone(),
|
||||
attachments: {
|
||||
color: {
|
||||
|
@ -11,9 +11,6 @@
|
||||
// shader source code. The boilerplate is taken from the "basic-compute-shader.rs" example, where
|
||||
// most of the boilerplate is explained.
|
||||
|
||||
extern crate vulkano;
|
||||
extern crate vulkano_shaders;
|
||||
|
||||
use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer};
|
||||
use vulkano::command_buffer::AutoCommandBufferBuilder;
|
||||
use vulkano::descriptor::descriptor_set::PersistentDescriptorSet;
|
||||
|
@ -8,8 +8,6 @@
|
||||
// according to those terms.
|
||||
|
||||
// TODO: Give a paragraph about what specialization are and what problems they solve
|
||||
extern crate vulkano;
|
||||
extern crate vulkano_shaders;
|
||||
|
||||
use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer};
|
||||
use vulkano::command_buffer::AutoCommandBufferBuilder;
|
||||
|
@ -7,14 +7,6 @@
|
||||
// notice may not be copied, modified, or distributed except
|
||||
// according to those terms.
|
||||
|
||||
#[macro_use]
|
||||
extern crate vulkano;
|
||||
extern crate vulkano_win;
|
||||
extern crate winit;
|
||||
extern crate cgmath;
|
||||
extern crate time;
|
||||
extern crate examples;
|
||||
|
||||
use vulkano::buffer::cpu_pool::CpuBufferPool;
|
||||
use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer};
|
||||
use vulkano::command_buffer::{AutoCommandBufferBuilder, DynamicState};
|
||||
@ -106,7 +98,7 @@ fn main() {
|
||||
let fs = fs::Shader::load(device.clone()).unwrap();
|
||||
|
||||
let render_pass = Arc::new(
|
||||
single_pass_renderpass!(device.clone(),
|
||||
vulkano::single_pass_renderpass!(device.clone(),
|
||||
attachments: {
|
||||
color: {
|
||||
load: Clear,
|
||||
|
@ -18,12 +18,6 @@
|
||||
// * tessellation control shader and a tessellation evaluation shader
|
||||
// * tessellation_shaders(..), patch_list(3) and polygon_mode_line() are called on the pipeline builder
|
||||
|
||||
#[macro_use]
|
||||
extern crate vulkano;
|
||||
extern crate vulkano_shaders;
|
||||
extern crate winit;
|
||||
extern crate vulkano_win;
|
||||
|
||||
use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer};
|
||||
use vulkano::command_buffer::{AutoCommandBufferBuilder, DynamicState};
|
||||
use vulkano::device::{Device, DeviceExtensions};
|
||||
@ -175,7 +169,7 @@ fn main() {
|
||||
let vertex_buffer = {
|
||||
#[derive(Debug, Clone)]
|
||||
struct Vertex { position: [f32; 2] }
|
||||
impl_vertex!(Vertex, position);
|
||||
vulkano::impl_vertex!(Vertex, position);
|
||||
|
||||
CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), [
|
||||
Vertex { position: [-0.5, -0.25] },
|
||||
@ -195,7 +189,7 @@ fn main() {
|
||||
let tes = tes::Shader::load(device.clone()).unwrap();
|
||||
let fs = fs::Shader::load(device.clone()).unwrap();
|
||||
|
||||
let render_pass = Arc::new(single_pass_renderpass!(
|
||||
let render_pass = Arc::new(vulkano::single_pass_renderpass!(
|
||||
device.clone(),
|
||||
attachments: {
|
||||
color: {
|
||||
|
@ -7,7 +7,6 @@
|
||||
// notice may not be copied, modified, or distributed except
|
||||
// according to those terms.
|
||||
|
||||
|
||||
// Welcome to the triangle example!
|
||||
//
|
||||
// This is the only example that is entirely detailed. All the other examples avoid code
|
||||
@ -17,19 +16,6 @@
|
||||
// and that you want to learn Vulkan. This means that for example it won't go into details about
|
||||
// what a vertex or a shader is.
|
||||
|
||||
// The `vulkano` crate is the main crate that you must use to use Vulkan.
|
||||
#[macro_use]
|
||||
extern crate vulkano;
|
||||
// Provides the `shader!` macro that is used to generate code for using shaders.
|
||||
extern crate vulkano_shaders;
|
||||
// The Vulkan library doesn't provide any functionality to create and handle windows, as
|
||||
// this would be out of scope. In order to open a window, we are going to use the `winit` crate.
|
||||
extern crate winit;
|
||||
// The `vulkano_win` crate is the link between `vulkano` and `winit`. Vulkano doesn't know about
|
||||
// winit, and winit doesn't know about vulkano, so import a crate that will provide a link between
|
||||
// the two.
|
||||
extern crate vulkano_win;
|
||||
|
||||
use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer};
|
||||
use vulkano::command_buffer::{AutoCommandBufferBuilder, DynamicState};
|
||||
use vulkano::device::{Device, DeviceExtensions};
|
||||
@ -186,7 +172,7 @@ fn main() {
|
||||
let vertex_buffer = {
|
||||
#[derive(Debug, Clone)]
|
||||
struct Vertex { position: [f32; 2] }
|
||||
impl_vertex!(Vertex, position);
|
||||
vulkano::impl_vertex!(Vertex, position);
|
||||
|
||||
CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), [
|
||||
Vertex { position: [-0.5, -0.25] },
|
||||
@ -242,7 +228,7 @@ void main() {
|
||||
// The next step is to create a *render pass*, which is an object that describes where the
|
||||
// output of the graphics pipeline will go. It describes the layout of the images
|
||||
// where the colors, depth and/or stencil information will be written.
|
||||
let render_pass = Arc::new(single_pass_renderpass!(
|
||||
let render_pass = Arc::new(vulkano::single_pass_renderpass!(
|
||||
device.clone(),
|
||||
attachments: {
|
||||
// `color` is a custom name we give to the first and only attachment.
|
||||
|
Loading…
Reference in New Issue
Block a user