|
|
|
#![allow(dead_code)]
|
|
|
|
#![allow(unused_variables)]
|
|
|
|
#![allow(unused_mut)]
|
|
|
|
|
|
|
|
extern crate cgmath;
|
|
|
|
extern crate image;
|
|
|
|
extern crate nalgebra as na;
|
|
|
|
extern crate quick_xml;
|
|
|
|
extern crate rand;
|
|
|
|
extern crate sfml;
|
|
|
|
extern crate time;
|
|
|
|
|
|
|
|
use image::{DynamicImage, GenericImage, GenericImageView, Pixel, SubImage};
|
|
|
|
use sfml::graphics::*;
|
|
|
|
use sfml::graphics::{
|
|
|
|
Color, RenderTarget, RenderWindow,
|
|
|
|
};
|
|
|
|
use sfml::system::*;
|
|
|
|
use sfml::system::Vector2 as sfVec2;
|
|
|
|
use sfml::window::*;
|
|
|
|
use sfml::window::{Event, Key, Style};
|
|
|
|
use sfml::window::mouse::Button;
|
|
|
|
|
|
|
|
use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer, DeviceLocalBuffer, ImmutableBuffer, BufferAccess};
|
|
|
|
use vulkano::command_buffer::AutoCommandBufferBuilder;
|
|
|
|
use vulkano::descriptor::descriptor_set::PersistentDescriptorSet;
|
|
|
|
use vulkano::device::{Device, DeviceExtensions};
|
|
|
|
use vulkano::instance::{Instance, InstanceExtensions, PhysicalDevice};
|
|
|
|
use vulkano::pipeline::ComputePipeline;
|
|
|
|
use vulkano::sync::GpuFuture;
|
|
|
|
use vulkano::sync;
|
|
|
|
use std::sync::Arc;
|
|
|
|
use std::{fs, mem, iter, ptr};
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use std::result;
|
|
|
|
|
|
|
|
use crate::input::Input;
|
|
|
|
use crate::slider::Slider;
|
|
|
|
use crate::timer::Timer;
|
|
|
|
use na::DimAdd;
|
|
|
|
use std::time::{SystemTime, Duration};
|
|
|
|
use shade_runner as sr;
|
|
|
|
use std::ffi::CStr;
|
|
|
|
use std::ptr::write;
|
|
|
|
|
|
|
|
mod slider;
|
|
|
|
mod timer;
|
|
|
|
mod input;
|
|
|
|
mod util;
|
|
|
|
mod vkprocessor;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
|
|
|
let mut processor = vkprocessor::VkProcessor::new();
|
|
|
|
processor.compile_kernel();
|
|
|
|
processor.load_buffers();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut window = RenderWindow::new(
|
|
|
|
(900, 900),
|
|
|
|
"Custom drawable",
|
|
|
|
Style::CLOSE,
|
|
|
|
&Default::default(),
|
|
|
|
);
|
|
|
|
|
|
|
|
let mut timer = Timer::new();
|
|
|
|
let mut input = Input::new();
|
|
|
|
|
|
|
|
let font = Font::from_file("resources/fonts/sansation.ttf").unwrap();
|
|
|
|
|
|
|
|
let xy = processor.img.unwrap().dimensions();
|
|
|
|
let mut bg_texture = Texture::new(xy.0, xy.1).unwrap();
|
|
|
|
bg_texture.update_from_pixels(processor.image_buffer.as_slice(), xy.0, xy.1, 0, 0);
|
|
|
|
|
|
|
|
let mut background_sprite = Sprite::with_texture(&bg_texture);
|
|
|
|
background_sprite.set_position((0., 0.));
|
|
|
|
|
|
|
|
let mut slider = Slider::new(40.0, None);
|
|
|
|
|
|
|
|
|
|
|
|
let mut selected_colors = Vec::new();
|
|
|
|
selected_colors.push(RectangleShape::with_size(Vector2f::new(30.0, 30.0)));
|
|
|
|
|
|
|
|
|
|
|
|
let step_size: f32 = 0.005;
|
|
|
|
let mut elapsed_time: f32;
|
|
|
|
let mut delta_time: f32;
|
|
|
|
let mut accumulator_time: f32 = 0.0;
|
|
|
|
let mut current_time: f32 = timer.elap_time();
|
|
|
|
|
|
|
|
while window.is_open() {
|
|
|
|
while let Some(event) = window.poll_event() {
|
|
|
|
match event {
|
|
|
|
Event::Closed => return,
|
|
|
|
Event::KeyPressed { code, .. } => {
|
|
|
|
if code == Key::Escape {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Event::MouseButtonPressed { button, x, y } => {
|
|
|
|
if button == Button::Left {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
input.ingest(&event)
|
|
|
|
}
|
|
|
|
|
|
|
|
if input.is_held(Key::W) {}
|
|
|
|
if input.is_held(Key::A) {}
|
|
|
|
if input.is_held(Key::S) {}
|
|
|
|
if input.is_held(Key::D) {}
|
|
|
|
|
|
|
|
elapsed_time = timer.elap_time();
|
|
|
|
delta_time = elapsed_time - current_time;
|
|
|
|
current_time = elapsed_time;
|
|
|
|
if delta_time > 0.02 {
|
|
|
|
delta_time = 0.02;
|
|
|
|
}
|
|
|
|
accumulator_time += delta_time;
|
|
|
|
|
|
|
|
while (accumulator_time - step_size) >= step_size {
|
|
|
|
accumulator_time -= step_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
window.clear(&Color::BLACK);
|
|
|
|
|
|
|
|
window.draw(&background_sprite);
|
|
|
|
|
|
|
|
// for i in selected_colors {
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
|
|
|
|
window.draw(&slider);
|
|
|
|
|
|
|
|
|
|
|
|
window.display();
|
|
|
|
}
|
|
|
|
}
|