Skip to content
Snippets Groups Projects
Unverified Commit 5aa0d6d0 authored by John's avatar John Committed by GitHub
Browse files

Merge pull request #22 from StarArawn/fix-image-rendering

Fixed image rendering.
parents 9cbc10ec b11a3bf5
No related branches found
No related tags found
No related merge requests found
assets/generic-rpg-vendor.png

2.98 KiB

...@@ -99,7 +99,7 @@ fn fragment(in: VertexOutput) -> [[location(0)]] vec4<f32> { ...@@ -99,7 +99,7 @@ fn fragment(in: VertexOutput) -> [[location(0)]] vec4<f32> {
return vec4<f32>(in.color.rgb, a); return vec4<f32>(in.color.rgb, a);
} }
if (quad_type.t == 2) { if (quad_type.t == 2) {
var color = textureSample(image_texture, image_sampler, vec2<f32>(in.uv.x, in.uv.y)); var color = textureSample(image_texture, image_sampler, vec2<f32>(in.uv.x, 1.0 - in.uv.y));
return vec4<f32>(color.rgb * in.color.rgb, color.a * in.color.a); return vec4<f32>(color.rgb * in.color.rgb, color.a * in.color.a);
} }
return in.color; return in.color;
......
...@@ -5,7 +5,11 @@ use bevy::{ ...@@ -5,7 +5,11 @@ use bevy::{
DefaultPlugins, DefaultPlugins,
}; };
use kayak_ui::bevy::{BevyContext, BevyKayakUIPlugin, ImageManager, UICameraBundle}; use kayak_ui::bevy::{BevyContext, BevyKayakUIPlugin, ImageManager, UICameraBundle};
use kayak_ui::core::{render, Index}; use kayak_ui::core::{
render,
styles::{Style, StyleProp, Units},
Index,
};
use kayak_widgets::{App, Image}; use kayak_widgets::{App, Image};
fn startup( fn startup(
...@@ -22,13 +26,19 @@ fn startup( ...@@ -22,13 +26,19 @@ fn startup(
panic!("Couldn't find primary window!"); panic!("Couldn't find primary window!");
}; };
let handle: Handle<bevy::render::texture::Image> = asset_server.load("panel.png"); let handle: Handle<bevy::render::texture::Image> = asset_server.load("generic-rpg-vendor.png");
let ui_image_handle = image_manager.get(&handle); let ui_image_handle = image_manager.get(&handle);
let context = BevyContext::new(window_size.x, window_size.y, |styles, context| { let context = BevyContext::new(window_size.x, window_size.y, |styles, context| {
let image_styles = Style {
width: StyleProp::Value(Units::Pixels(200.0)),
height: StyleProp::Value(Units::Pixels(182.0)),
..Style::default()
};
render! { render! {
<App styles={Some(styles.clone())}> <App styles={Some(styles.clone())}>
<Image handle={ui_image_handle} /> <Image styles={Some(image_styles)} handle={ui_image_handle} />
</App> </App>
} }
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment