sprites are working, but the implementation is pretty bad
This commit is contained in:
@@ -5,7 +5,7 @@ layout(location = 1) in vec4 color;
|
|||||||
layout(location = 0) out vec4 out_color;
|
layout(location = 0) out vec4 out_color;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
// out_color = color;
|
out_color = color;
|
||||||
gl_Position = vec4(position, 0.0, 1.0);
|
gl_Position = vec4(position, 0.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ fn main() {
|
|||||||
|
|
||||||
let mut mouse_xy = Vector2i::new(0,0);
|
let mut mouse_xy = Vector2i::new(0,0);
|
||||||
|
|
||||||
let sprite = Sprite::new_with_color((0.,0.), (0,0), (0.,0.,0.,0.));
|
let sprite = Sprite::new_with_color((0.,0.), (0.1,0.1), (1.,0.,0.,1.));
|
||||||
|
let sprite2 = Sprite::new_with_color((-1.,-0.5), (0.1,0.1), (0.,1.,0.,1.));
|
||||||
|
|
||||||
while let Some(p) = window.get_position() {
|
while let Some(p) = window.get_position() {
|
||||||
|
|
||||||
@@ -113,6 +114,7 @@ fn main() {
|
|||||||
|
|
||||||
let mut canvas = CanvasFrame::new();
|
let mut canvas = CanvasFrame::new();
|
||||||
canvas.draw(&sprite);
|
canvas.draw(&sprite);
|
||||||
|
canvas.draw(&sprite2);
|
||||||
|
|
||||||
(frame_future) = processor.run(&surface, frame_future, canvas);
|
(frame_future) = processor.run(&surface, frame_future, canvas);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ pub struct Sprite {
|
|||||||
pub vertices: [(f32, f32); 6],
|
pub vertices: [(f32, f32); 6],
|
||||||
|
|
||||||
position: (f32, f32),
|
position: (f32, f32),
|
||||||
size: (u32, u32),
|
size: (f32, f32),
|
||||||
color: (f32, f32, f32, f32),
|
color: (f32, f32, f32, f32),
|
||||||
|
|
||||||
textured: bool,
|
textured: bool,
|
||||||
@@ -16,11 +16,11 @@ pub struct Sprite {
|
|||||||
|
|
||||||
impl Sprite {
|
impl Sprite {
|
||||||
|
|
||||||
pub fn new(position: (f32, f32), size: (u32, u32)) -> Sprite {
|
pub fn new(position: (f32, f32), size: (f32, f32)) -> Sprite {
|
||||||
Sprite::new_with_color(position, size, (0.,0.,0.,0.))
|
Sprite::new_with_color(position, size, (0.,0.,0.,0.))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_with_color(position: (f32, f32), size: (u32, u32), color: (f32, f32, f32, f32)) -> Sprite {
|
pub fn new_with_color(position: (f32, f32), size: (f32, f32), color: (f32, f32, f32, f32)) -> Sprite {
|
||||||
|
|
||||||
let fsize = (size.0 as f32, size.1 as f32);
|
let fsize = (size.0 as f32, size.1 as f32);
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ impl Sprite {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_with_texture(position: (f32, f32), size: (u32, u32), texture_id: String) -> Sprite {
|
pub fn new_with_texture(position: (f32, f32), size: (f32, f32), texture_id: String) -> Sprite {
|
||||||
|
|
||||||
let fsize = (size.0 as f32, size.1 as f32);
|
let fsize = (size.0 as f32, size.1 as f32);
|
||||||
|
|
||||||
@@ -55,8 +55,8 @@ impl Sprite {
|
|||||||
(position.0 + fsize.0, position.1 + fsize.1 ), // bottom right
|
(position.0 + fsize.0, position.1 + fsize.1 ), // bottom right
|
||||||
(position.0 + fsize.0, position.1 ), // top right
|
(position.0 + fsize.0, position.1 ), // top right
|
||||||
],
|
],
|
||||||
position,
|
position: position,
|
||||||
size,
|
size: size,
|
||||||
color: (0.0, 0.0, 0.0, 0.0),
|
color: (0.0, 0.0, 0.0, 0.0),
|
||||||
textured: false,
|
textured: false,
|
||||||
texture_id: Some(texture_id)
|
texture_id: Some(texture_id)
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ impl ShaderKernels {
|
|||||||
third_constant: 0.0,
|
third_constant: 0.0,
|
||||||
})
|
})
|
||||||
|
|
||||||
.triangle_fan()
|
.triangle_list()
|
||||||
// Use a resizable viewport set to draw over the entire window
|
// Use a resizable viewport set to draw over the entire window
|
||||||
.viewports_dynamic_scissors_irrelevant(1)
|
.viewports_dynamic_scissors_irrelevant(1)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user