-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbackground_image.rs
More file actions
37 lines (30 loc) · 956 Bytes
/
background_image.rs
File metadata and controls
37 lines (30 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use processing_glfw::GlfwContext;
use processing::prelude::*;
use processing_render::render::command::DrawCommand;
fn main() {
match sketch() {
Ok(_) => {
eprintln!("Sketch completed successfully");
exit(0).unwrap();
}
Err(e) => {
eprintln!("Sketch error: {:?}", e);
exit(1).unwrap();
}
};
}
fn sketch() -> error::Result<()> {
let mut glfw_ctx = GlfwContext::new(400, 400)?;
init(Config::default())?;
let width = 400;
let height = 400;
let surface = glfw_ctx.create_surface(width, height)?;
let graphics = graphics_create(surface, width, height, TextureFormat::Rgba16Float)?;
let image = image_load("images/logo.png")?;
while glfw_ctx.poll_events() {
graphics_begin_draw(graphics)?;
graphics_record_command(graphics, DrawCommand::BackgroundImage(image))?;
graphics_end_draw(graphics)?;
}
Ok(())
}