text almost works
This commit is contained in:
@@ -30,7 +30,7 @@
|
|||||||
{
|
{
|
||||||
"mesh_index": 1,
|
"mesh_index": 1,
|
||||||
"position": [
|
"position": [
|
||||||
0.0,
|
-2.0,
|
||||||
0.0,
|
0.0,
|
||||||
0.0
|
0.0
|
||||||
],
|
],
|
||||||
@@ -50,15 +50,15 @@
|
|||||||
"player": {
|
"player": {
|
||||||
"mesh_index": null,
|
"mesh_index": null,
|
||||||
"position": [
|
"position": [
|
||||||
0,
|
3.735453,
|
||||||
1.0,
|
-0.27469593,
|
||||||
5.0
|
-7.2023296
|
||||||
],
|
],
|
||||||
"rotation": [
|
"rotation": [
|
||||||
1,
|
0.106049195,
|
||||||
0,
|
0.0023422977,
|
||||||
0,
|
-0.99411577,
|
||||||
0
|
-0.021956932
|
||||||
],
|
],
|
||||||
"scale": [
|
"scale": [
|
||||||
1.0,
|
1.0,
|
||||||
|
|||||||
@@ -21,6 +21,5 @@ layout(location = 0) in vec2 tex_coords;
|
|||||||
layout(location = 0) out vec4 out_color;
|
layout(location = 0) out vec4 out_color;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
out_color = vec4(1., 1., 1., 1.);
|
out_color = vec4(1., 1., 1., texture(diffuse_tex, tex_coords).r);
|
||||||
// out_color = vec4(1., 1., 1., texture(diffuse_tex, tex_coords).r);
|
|
||||||
}
|
}
|
||||||
Binary file not shown.
@@ -25,8 +25,15 @@ out gl_PerVertex {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
mat4 invert = mat4(
|
||||||
|
1., 0., 0., 0.,
|
||||||
|
0., -1., 0., 0.,
|
||||||
|
0., 0., 1., 0.,
|
||||||
|
0., 0., 0., 1.
|
||||||
|
);
|
||||||
|
|
||||||
// Vertex position in camera
|
// Vertex position in camera
|
||||||
gl_Position = ubo.projection * ubo.view * push.model * vec4(position, 1.0);
|
gl_Position = ubo.projection * ubo.view * invert * push.model * vec4(position, 1.0);
|
||||||
|
|
||||||
// Just interpolate UV coords, no transformation needed
|
// Just interpolate UV coords, no transformation needed
|
||||||
tex_coords = uv;
|
tex_coords = uv;
|
||||||
|
|||||||
Binary file not shown.
@@ -60,14 +60,15 @@ pub fn save_level(path: &str, game: &mut TestGame, renderer: &mut VulkanRenderer
|
|||||||
}
|
}
|
||||||
}).collect();
|
}).collect();
|
||||||
|
|
||||||
let objects = game.game_objects.iter().map(|game_object_handle| {
|
let objects = game.game_objects.iter().filter_map(|game_object_handle| {
|
||||||
let game_object = game_object_handle.get_game_object(renderer).unwrap();
|
let game_object = game_object_handle.get_game_object(renderer).unwrap();
|
||||||
ObjectJson {
|
if game_object.pipeline_index != 0 { return None; }
|
||||||
|
Some(ObjectJson {
|
||||||
mesh_index: Some(game_object_handle.object_index),
|
mesh_index: Some(game_object_handle.object_index),
|
||||||
position: game_object.position.into(),
|
position: game_object.position.into(),
|
||||||
rotation: game_object.rotation.into(),
|
rotation: game_object.rotation.into(),
|
||||||
scale: game_object.scale.into()
|
scale: game_object.scale.into()
|
||||||
}
|
})
|
||||||
}).collect();
|
}).collect();
|
||||||
|
|
||||||
let player = ObjectJson {
|
let player = ObjectJson {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use cgmath::{Deg, Euler, Quaternion, vec3};
|
|||||||
use glyph_brush::{BrushAction, BrushError, GlyphBrushBuilder, Section, Text};
|
use glyph_brush::{BrushAction, BrushError, GlyphBrushBuilder, Section, Text};
|
||||||
use glyph_brush::ab_glyph::FontArc;
|
use glyph_brush::ab_glyph::FontArc;
|
||||||
use vulkano::format::Format;
|
use vulkano::format::Format;
|
||||||
|
use vulkano::sampler::Filter;
|
||||||
use winit::event::Event;
|
use winit::event::Event;
|
||||||
|
|
||||||
use level::{load_level, save_level};
|
use level::{load_level, save_level};
|
||||||
@@ -121,7 +122,7 @@ impl TestGame {
|
|||||||
let mut glyph_brush = GlyphBrushBuilder::using_font(font).build();
|
let mut glyph_brush = GlyphBrushBuilder::using_font(font).build();
|
||||||
glyph_brush.queue(Section::default().add_text(Text::new("penis lol")));
|
glyph_brush.queue(Section::default().add_text(Text::new("penis lol")));
|
||||||
match glyph_brush.process_queued(|rect, text_data| {
|
match glyph_brush.process_queued(|rect, text_data| {
|
||||||
renderer.upload_texture(text_data, rect.width(), rect.height(), Format::R8Unorm, renderer.device.clone());
|
renderer.upload_texture(text_data, rect.width(), rect.height(), Format::R8Unorm, Filter::Nearest, renderer.device.clone());
|
||||||
self.texture_index_counter += 1;
|
self.texture_index_counter += 1;
|
||||||
}, |vertex_data| {
|
}, |vertex_data| {
|
||||||
println!("vd: {:?}", vertex_data);
|
println!("vd: {:?}", vertex_data);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::{convert::TryInto, io::Read};
|
use std::{convert::TryInto, io::Read};
|
||||||
|
|
||||||
use vulkano::format::Format;
|
use vulkano::{format::Format, sampler::Filter};
|
||||||
|
|
||||||
use super::VulkanRenderer;
|
use super::VulkanRenderer;
|
||||||
|
|
||||||
@@ -26,14 +26,14 @@ pub fn upload_texture_from_file(path: &str, renderer: &mut VulkanRenderer) -> Re
|
|||||||
|
|
||||||
if is_dxt1
|
if is_dxt1
|
||||||
{
|
{
|
||||||
renderer.upload_texture(&tex_bytes[128..], tex_width, tex_height, Format::BC1_RGBUnormBlock, renderer.device.clone());
|
renderer.upload_texture(&tex_bytes[128..], tex_width, tex_height, Format::BC1_RGBUnormBlock, Filter::Linear, renderer.device.clone());
|
||||||
}
|
}
|
||||||
if is_dx10
|
if is_dx10
|
||||||
{
|
{
|
||||||
let dxgi_type = u32::from_ne_bytes(tex_bytes[128..132].try_into()?);
|
let dxgi_type = u32::from_ne_bytes(tex_bytes[128..132].try_into()?);
|
||||||
assert!(dxgi_type == 83); // BC5 Unorm Typeless
|
assert!(dxgi_type == 83); // BC5 Unorm Typeless
|
||||||
|
|
||||||
renderer.upload_texture(&tex_bytes[128+20..], tex_width, tex_height, Format::BC5UnormBlock, renderer.device.clone());
|
renderer.upload_texture(&tex_bytes[128+20..], tex_width, tex_height, Format::BC5UnormBlock, Filter::Linear, renderer.device.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -155,6 +155,7 @@ impl VulkanRenderer {
|
|||||||
ext_debug_utils: true,
|
ext_debug_utils: true,
|
||||||
..vulkano_win::required_extensions()
|
..vulkano_win::required_extensions()
|
||||||
};
|
};
|
||||||
|
println!("Using extensions: {:?}", extensions);
|
||||||
|
|
||||||
let app_info = ApplicationInfo {
|
let app_info = ApplicationInfo {
|
||||||
application_name: Some("Asuro's Editor".into()),
|
application_name: Some("Asuro's Editor".into()),
|
||||||
@@ -454,7 +455,7 @@ impl VulkanRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn upload_texture(self: &mut Self, bytes: &[u8], width: u32, height: u32, format: Format, device: Arc<Device>) {
|
pub fn upload_texture(self: &mut Self, bytes: &[u8], width: u32, height: u32, format: Format, filter: Filter, device: Arc<Device>) {
|
||||||
let dimensions = Dimensions::Dim2d { width, height };
|
let dimensions = Dimensions::Dim2d { width, height };
|
||||||
|
|
||||||
let usage = ImageUsage {
|
let usage = ImageUsage {
|
||||||
@@ -538,7 +539,7 @@ impl VulkanRenderer {
|
|||||||
|
|
||||||
future.flush().unwrap();
|
future.flush().unwrap();
|
||||||
|
|
||||||
let sampler = Sampler::new(device.clone(), Filter::Linear, Filter::Linear,
|
let sampler = Sampler::new(device.clone(), filter, filter,
|
||||||
MipmapMode::Linear, SamplerAddressMode::Repeat, SamplerAddressMode::Repeat,
|
MipmapMode::Linear, SamplerAddressMode::Repeat, SamplerAddressMode::Repeat,
|
||||||
SamplerAddressMode::Repeat, 0.0, 1.0, 0.0, (image_view.mipmap_levels() - 1) as f32).unwrap();
|
SamplerAddressMode::Repeat, 0.0, 1.0, 0.0, (image_view.mipmap_levels() - 1) as f32).unwrap();
|
||||||
|
|
||||||
|
|||||||
@@ -142,8 +142,6 @@ impl Drawcall for DefaultShader {
|
|||||||
let mesh = &game_data.meshes[game_object.mesh_index];
|
let mesh = &game_data.meshes[game_object.mesh_index];
|
||||||
let push_constants = game_object.get_push_constants();
|
let push_constants = game_object.get_push_constants();
|
||||||
|
|
||||||
println!("default: {:?}", game_object.mesh_index);
|
|
||||||
|
|
||||||
builder.draw_indexed(
|
builder.draw_indexed(
|
||||||
self.pipeline.clone(),
|
self.pipeline.clone(),
|
||||||
dynamic_state,
|
dynamic_state,
|
||||||
@@ -328,11 +326,9 @@ impl Drawcall for TextShader {
|
|||||||
fn draw(self: &Self, builder: &mut AutoCommandBufferBuilder, fb_index: usize, game_objects: Vec<&GameObject>, game_data: &GameData, dynamic_state: &DynamicState) {
|
fn draw(self: &Self, builder: &mut AutoCommandBufferBuilder, fb_index: usize, game_objects: Vec<&GameObject>, game_data: &GameData, dynamic_state: &DynamicState) {
|
||||||
for i in 0..game_objects.len() {
|
for i in 0..game_objects.len() {
|
||||||
let game_object = &game_objects[i];
|
let game_object = &game_objects[i];
|
||||||
let mesh = &game_data.meshes[game_object.mesh_index];
|
let mesh = &game_data.meshes_text[game_object.mesh_index];
|
||||||
let push_constants = game_object.get_push_constants();
|
let push_constants = game_object.get_push_constants();
|
||||||
|
|
||||||
println!("text: {:?}", game_object.mesh_index);
|
|
||||||
|
|
||||||
builder.draw_indexed(
|
builder.draw_indexed(
|
||||||
self.pipeline.clone(),
|
self.pipeline.clone(),
|
||||||
dynamic_state,
|
dynamic_state,
|
||||||
|
|||||||
Reference in New Issue
Block a user