compiles and renders textures again

This commit is contained in:
2020-02-20 23:55:36 -08:00
parent d1051a0ca3
commit 438f96eb32
16 changed files with 110 additions and 89 deletions

View File

@@ -27,8 +27,9 @@ use crate::compute::compu_frame::CompuFrame;
use crate::canvas::canvas_frame::{CanvasFrame, Drawable};
use crate::compute::managed::compu_sprite::CompuSprite;
use std::sync::Arc;
use crate::canvas::managed::handles::{CanvasTextureHandle, Handle};
use crate::util::vertex::{VertexTypes, TextureVertex2D};
use crate::canvas::managed::handles::{CanvasTextureHandle, Handle, CanvasFontHandle};
use crate::util::vertex::{VertexTypes, TextureVertex3D};
use crate::compute::managed::handles::{CompuBufferHandle, CompuKernelHandle};
pub mod util;
@@ -89,13 +90,11 @@ pub fn main() {
processor.preload_fonts();
}
let q2 = hprof::enter("Game Objects");
let mut timer = Timer::new();
let mut frame_future = Box::new(sync::now(processor.device.clone())) as Box<dyn GpuFuture>;
let mut frame_future : Box<dyn GpuFuture> =
Box::new(sync::now(processor.device.clone())) as Box<dyn GpuFuture>;
let step_size: f32 = 0.005;
let mut elapsed_time: f32;
@@ -104,26 +103,31 @@ pub fn main() {
let mut current_time: f32 = timer.elap_time();
let image_data = load_raw(String::from("funky-bird.jpg"));
let image_dimensions_f = ((image_data.1).0 as f32, (image_data.1).1 as f32);
let image_dimensions_u = image_data.1;
let compu_sprite1 = CompuSprite::new((0.0, -0.5), (0.4, 0.4), 0, image_dimensions_f,
// This swap image needs to match the size of the compute
processor.new_swap_image(image_dimensions_u));
let image_dimensions_f : (f32, f32) = ((image_data.1).0 as f32, (image_data.1).1 as f32);
let image_dimensions_u : (u32, u32) = image_data.1;
let compu_sprite1 : CompuSprite =
CompuSprite::new((0.0, -0.5), (0.4, 0.4), 0, image_dimensions_f,
// Swap image to render the result to. Must match dimensions
processor.new_swap_image(image_dimensions_u));
let compute_buffer = processor.new_compute_buffer(image_data.0, image_data.1, 4);
let compute_buffer : Arc<CompuBufferHandle> =
processor.new_compute_buffer(image_data.0, image_data.1, 4);
let compute_kernel = processor.get_kernel_handle(String::from("simple-edge.compute"))
let compute_kernel : Arc<CompuKernelHandle> =
processor.get_kernel_handle(String::from("simple-edge.compute"))
.expect("Can't find that kernel");
let funky_handle = processor.get_texture_handle(String::from("funky-bird.jpg")).unwrap();
let sfml_handle = processor.get_texture_handle(String::from("sfml.png")).unwrap();
let font_handle = processor.get_font_handle(String::from("sansation.ttf")).unwrap();
// Get the handles for the assets
let funky_handle : Arc<CanvasTextureHandle> =
processor.get_texture_handle(String::from("funky-bird.jpg")).unwrap();
let sfml_handle : Arc<CanvasTextureHandle> =
processor.get_texture_handle(String::from("sfml.png")).unwrap();
let font_handle : Arc<CanvasFontHandle> =
processor.get_font_handle(String::from("sansation.ttf")).unwrap();
let funky_sprite = Sprite::new((0.0, -0.5), (0.5, 0.5), 0, funky_handle.clone());
let sfml_sprite = Sprite::new((0.0, -0.5), (0.5, 0.5), 1, sfml_handle.clone());
//let text_sprite = Text::new((-0.1,-0.1), (10.0, 10.0), font_handle.clone());
//let test_polygon = Poly::new_with_color((-0.5, -0.5), (0.5, 0.5), 1, (1.0,0.0,0.0,0.0));
drop(q2);