From 129324f0a25d303f1d7b045496391f5e837e2697 Mon Sep 17 00:00:00 2001 From: Connor Fitzgerald Date: Wed, 22 Sep 2021 09:16:44 -0400 Subject: [PATCH] Fix cube example --- CHANGELOG.md | 6 + Cargo.toml | 32 ++--- README.md | 2 +- deny.toml | 3 +- examples/basic_simple_api.rs | 10 -- examples/cube.rs | 129 ++++++------------ .../{custom_textures.rs => custom-texture.rs} | 6 +- examples/{hello_world.rs => hello-world.rs} | 15 +- resources/cube.frag | 12 -- resources/cube.frag.spv | Bin 1208 -> 0 bytes resources/cube.vert | 14 -- resources/cube.vert.spv | Bin 1176 -> 0 bytes resources/cube.wgsl | 37 +++++ simple-api/Cargo.toml | 25 ++++ simple-api/examples/basic-simple-api.rs | 10 ++ .../examples/fullscreen-simple-api.rs | 11 +- src/simple_api.rs => simple-api/src/lib.rs | 12 +- src/lib.rs | 3 - 18 files changed, 151 insertions(+), 176 deletions(-) delete mode 100644 examples/basic_simple_api.rs rename examples/{custom_textures.rs => custom-texture.rs} (97%) rename examples/{hello_world.rs => hello-world.rs} (93%) delete mode 100644 resources/cube.frag delete mode 100644 resources/cube.frag.spv delete mode 100644 resources/cube.vert delete mode 100644 resources/cube.vert.spv create mode 100644 resources/cube.wgsl create mode 100644 simple-api/Cargo.toml create mode 100644 simple-api/examples/basic-simple-api.rs rename examples/fullscreen_simple_api.rs => simple-api/examples/fullscreen-simple-api.rs (81%) rename src/simple_api.rs => simple-api/src/lib.rs (97%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1404e7a..88d7908 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,12 @@ Per Keep a Changelog there are 6 main categories of changes: ## Unreleased +#### Updated +- updated imgui dependency to `>=0.1,<0.9` + +#### Removed +- unstable simple-api is now it's own, unpublished, crate. + ## v0.17.0 Released 2021-09-04 diff --git a/Cargo.toml b/Cargo.toml index 7f77677..6add198 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,8 @@ +[workspace] +members = [".", "simple-api"] +default-members = [".", "simple-api"] +resolver = "2" + [package] name = "imgui-wgpu" version = "0.17.0" @@ -11,7 +16,6 @@ readme = "README.md" categories = ["gui", "graphics", "rendering", "rendering::graphics-api"] keywords = ["gui", "graphics", "wgpu", "imgui"] license = "MIT OR Apache-2.0" -resolver = "2" exclude = [ ".gitignore", @@ -19,14 +23,6 @@ exclude = [ "resources", ] -[[example]] -name = "basic_simple_api" -required-features = ["simple_api_unstable"] - -[[example]] -name = "fullscreen_simple_api" -required-features = ["simple_api_unstable"] - [[package.metadata.release.pre-release-replacements]] file = "CHANGELOG.md" search = "\\[Unreleased\\]\\(#unreleased\\)" @@ -50,32 +46,22 @@ search = "" replace = "- [Unreleased](https://github.com/Yatekii/imgui-wgpu-rs/compare/v{{version}}...HEAD)" min = 0 # allow non-first increment -[features] -# used in src/simple_api.rs -default = [] -simple_api_unstable = [ "winit", "pollster", "imgui-winit-support" ] - [dependencies] bytemuck = "1" -imgui = "0.7" +imgui = ">=0.1, <0.9" log = "0.4" smallvec = "1" -wgpu = { version = "0.10", features = ["spirv"] } - -# deps for simple_api_unstable -imgui-winit-support = { version = "0.7", optional = true } -pollster = { version = "0.2.0", optional = true } # for block_on executor -winit = { version = ">= 0.23, < 0.25", optional = true } +wgpu = "0.10" [dev-dependencies] bytemuck = { version = "1.4", features = ["derive"] } cgmath = "0.18" env_logger = "0.9" image = { version = "0.23", default-features = false, features = ["jpeg"] } -imgui-winit-support = "0.7" +imgui-winit-support = "0.8" pollster = "0.2" raw-window-handle = "0.3" -winit = "0.24" +winit = "0.25" [package.metadata.docs.rs] all-features = true diff --git a/README.md b/README.md index 2894827..b30a797 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ cargo run --release --example hello_world # Status -Basic features are useable. Uses `wgpu-0.9` and `imgui-0.7` upstream. `winit-0.24` is used with the examples. +Uses `wgpu-0.10` upstream. Compatible with all imgui versions after `0.1`. `winit-0.25` is used with the examples. Contributions are very welcome. diff --git a/deny.toml b/deny.toml index 11d62b0..6ab6ccd 100644 --- a/deny.toml +++ b/deny.toml @@ -18,14 +18,13 @@ skip = [ { name = "dlib", version = "0.4.2" }, { name = "libloading", version = "0.6.7" }, { name = "nix", version = "0.18.0" }, - { name = "winapi", version = "0.2.8" }, + { name = "proc-macro-crate", version = "0.1.5" }, ] [advisories] vulnerability = "deny" unmaintained = "deny" ignore = [ - "RUSTSEC-2020-0016" ] [sources] diff --git a/examples/basic_simple_api.rs b/examples/basic_simple_api.rs deleted file mode 100644 index b1125de..0000000 --- a/examples/basic_simple_api.rs +++ /dev/null @@ -1,10 +0,0 @@ -// you need to set --feature=simple_api_unstable to run this example -// cargo run --example basic_simple_api --features=simple_api_unstable - -fn main() { - imgui_wgpu::simple_api::run(Default::default(), (), |ui, _| { - imgui::Window::new(imgui::im_str!("hello world")).build(&ui, || { - ui.text(imgui::im_str!("Hello world!")); - }); - }); -} diff --git a/examples/cube.rs b/examples/cube.rs index fe890ff..ac6bdb6 100644 --- a/examples/cube.rs +++ b/examples/cube.rs @@ -2,9 +2,8 @@ use bytemuck::{Pod, Zeroable}; use imgui::*; use imgui_wgpu::{Renderer, RendererConfig, Texture, TextureConfig}; use pollster::block_on; -use std::num::NonZeroU32; use std::time::Instant; -use wgpu::{util::DeviceExt, BlendState, Extent3d}; +use wgpu::{include_wgsl, util::DeviceExt, Extent3d}; use winit::{ dpi::LogicalSize, event::{ElementState, Event, KeyboardInput, VirtualKeyCode, WindowEvent}, @@ -12,12 +11,11 @@ use winit::{ window::Window, }; -// Example code modified from https://github.com/gfx-rs/wgpu-rs/tree/master/examples/cube - const OPENGL_TO_WGPU_MATRIX: cgmath::Matrix4 = cgmath::Matrix4::new( 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5, 1.0, ); +// Example code modified from https://github.com/gfx-rs/wgpu-rs/tree/master/examples/cube #[repr(C)] #[derive(Clone, Copy, Pod, Zeroable)] struct Vertex { @@ -79,10 +77,8 @@ fn create_vertices() -> (Vec, Vec) { } fn create_texels(size: usize) -> Vec { - use std::iter; - (0..size * size) - .flat_map(|id| { + .map(|id| { // get high five for recognizing this ;) let cx = 3.0 * (id % size) as f32 / (size - 1) as f32 - 2.0; let cy = 2.0 * (id / size) as f32 / (size - 1) as f32 - 1.0; @@ -93,10 +89,7 @@ fn create_texels(size: usize) -> Vec { y = 2.0 * old_x * y + cy; count += 1; } - iter::once(0xFF - (count * 5) as u8) - .chain(iter::once(0xFF - (count * 15) as u8)) - .chain(iter::once(0xFF - (count * 50) as u8)) - .chain(iter::once(1)) + count }) .collect() } @@ -112,10 +105,10 @@ struct Example { } impl Example { - fn generate_matrix(aspect_ratio: f32, theta: f32) -> cgmath::Matrix4 { + fn generate_matrix(aspect_ratio: f32) -> cgmath::Matrix4 { let mx_projection = cgmath::perspective(cgmath::Deg(45f32), aspect_ratio, 1.0, 10.0); let mx_view = cgmath::Matrix4::look_at_rh( - cgmath::Point3::new(6.0 * theta.cos(), 6.0 * theta.sin(), 3.0), + cgmath::Point3::new(1.5f32, -5.0, 3.0), cgmath::Point3::new(0f32, 0.0, 0.0), cgmath::Vector3::unit_z(), ); @@ -126,7 +119,7 @@ impl Example { impl Example { fn init( - surface_desc: &wgpu::SurfaceConfiguration, + config: &wgpu::SurfaceConfiguration, device: &wgpu::Device, queue: &wgpu::Queue, ) -> Self { @@ -167,20 +160,11 @@ impl Example { visibility: wgpu::ShaderStages::FRAGMENT, ty: wgpu::BindingType::Texture { multisampled: false, - sample_type: wgpu::TextureSampleType::Float { filterable: true }, + sample_type: wgpu::TextureSampleType::Uint, view_dimension: wgpu::TextureViewDimension::D2, }, count: None, }, - wgpu::BindGroupLayoutEntry { - binding: 2, - visibility: wgpu::ShaderStages::FRAGMENT, - ty: wgpu::BindingType::Sampler { - filtering: true, - comparison: false, - }, - count: None, - }, ], }); let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { @@ -203,38 +187,23 @@ impl Example { mip_level_count: 1, sample_count: 1, dimension: wgpu::TextureDimension::D2, - format: wgpu::TextureFormat::Rgba8UnormSrgb, + format: wgpu::TextureFormat::R8Uint, usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST, }); let texture_view = texture.create_view(&wgpu::TextureViewDescriptor::default()); queue.write_texture( - wgpu::ImageCopyTexture { - texture: &texture, - mip_level: 0, - origin: wgpu::Origin3d::ZERO, - aspect: wgpu::TextureAspect::All, - }, + texture.as_image_copy(), &texels, wgpu::ImageDataLayout { offset: 0, - bytes_per_row: NonZeroU32::new(4 * size), + bytes_per_row: Some(std::num::NonZeroU32::new(size).unwrap()), rows_per_image: None, }, texture_extent, ); // Create other resources - let sampler = device.create_sampler(&wgpu::SamplerDescriptor { - address_mode_u: wgpu::AddressMode::ClampToEdge, - address_mode_v: wgpu::AddressMode::ClampToEdge, - address_mode_w: wgpu::AddressMode::ClampToEdge, - mag_filter: wgpu::FilterMode::Nearest, - min_filter: wgpu::FilterMode::Linear, - mipmap_filter: wgpu::FilterMode::Nearest, - ..Default::default() - }); - let mx_total = - Self::generate_matrix(surface_desc.width as f32 / surface_desc.height as f32, 0.0); + let mx_total = Self::generate_matrix(config.width as f32 / config.height as f32); let mx_ref: &[f32; 16] = mx_total.as_ref(); let uniform_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { label: Some("Uniform Buffer"), @@ -254,62 +223,48 @@ impl Example { binding: 1, resource: wgpu::BindingResource::TextureView(&texture_view), }, - wgpu::BindGroupEntry { - binding: 2, - resource: wgpu::BindingResource::Sampler(&sampler), - }, ], label: None, }); - // Create the render pipeline - let vs_module = - device.create_shader_module(&wgpu::include_spirv!("../resources/cube.vert.spv")); - let fs_module = - device.create_shader_module(&wgpu::include_spirv!("../resources/cube.frag.spv")); + let shader = device.create_shader_module(&include_wgsl!("../resources/cube.wgsl")); + + let vertex_buffers = [wgpu::VertexBufferLayout { + array_stride: vertex_size as wgpu::BufferAddress, + step_mode: wgpu::VertexStepMode::Vertex, + attributes: &[ + wgpu::VertexAttribute { + format: wgpu::VertexFormat::Float32x4, + offset: 0, + shader_location: 0, + }, + wgpu::VertexAttribute { + format: wgpu::VertexFormat::Float32x2, + offset: 4 * 4, + shader_location: 1, + }, + ], + }]; let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { label: None, layout: Some(&pipeline_layout), vertex: wgpu::VertexState { - module: &vs_module, - entry_point: "main", - buffers: &[wgpu::VertexBufferLayout { - array_stride: vertex_size as wgpu::BufferAddress, - step_mode: wgpu::VertexStepMode::Vertex, - attributes: &[ - wgpu::VertexAttribute { - format: wgpu::VertexFormat::Float32x4, - offset: 0, - shader_location: 0, - }, - wgpu::VertexAttribute { - format: wgpu::VertexFormat::Float32x2, - offset: 4 * 4, - shader_location: 1, - }, - ], - }], + module: &shader, + entry_point: "vs_main", + buffers: &vertex_buffers, }, + fragment: Some(wgpu::FragmentState { + module: &shader, + entry_point: "fs_main", + targets: &[config.format.into()], + }), primitive: wgpu::PrimitiveState { - front_face: wgpu::FrontFace::Ccw, cull_mode: Some(wgpu::Face::Back), ..Default::default() }, depth_stencil: None, multisample: wgpu::MultisampleState::default(), - fragment: Some(wgpu::FragmentState { - module: &fs_module, - entry_point: "main", - targets: &[wgpu::ColorTargetState { - format: surface_desc.format, - blend: Some(BlendState { - color: wgpu::BlendComponent::REPLACE, - alpha: wgpu::BlendComponent::REPLACE, - }), - write_mask: wgpu::ColorWrites::ALL, - }], - }), }); // Done @@ -329,7 +284,7 @@ impl Example { } fn setup_camera(&mut self, queue: &wgpu::Queue, size: [f32; 2]) { - let mx_total = Self::generate_matrix(size[0] / size[1], self.time * 0.1); + let mx_total = Self::generate_matrix(size[0] / size[1]); let mx_ref: &[f32; 16] = mx_total.as_ref(); queue.write_buffer(&self.uniform_buf, 0, bytemuck::cast_slice(mx_ref)); } @@ -341,14 +296,14 @@ impl Example { let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { label: None, color_attachments: &[wgpu::RenderPassColorAttachment { - view: &view, + view, resolve_target: None, ops: wgpu::Operations { load: wgpu::LoadOp::Clear(wgpu::Color { r: 0.1, g: 0.2, b: 0.3, - a: 0.1, // semi-transparent background + a: 1.0, }), store: true, }, @@ -551,7 +506,7 @@ fn main() { // Store the new size of Image() or None to indicate that the window is collapsed. let mut new_example_size: Option<[f32; 2]> = None; - imgui::Window::new(im_str!("Cube")) + imgui::Window::new("Cube") .size([512.0, 512.0], Condition::FirstUseEver) .build(&ui, || { new_example_size = Some(ui.content_region_avail()); diff --git a/examples/custom_textures.rs b/examples/custom-texture.rs similarity index 97% rename from examples/custom_textures.rs rename to examples/custom-texture.rs index 0ca489d..3aeb883 100644 --- a/examples/custom_textures.rs +++ b/examples/custom-texture.rs @@ -194,12 +194,12 @@ fn main() { { let size = [width as f32, height as f32]; - let window = imgui::Window::new(im_str!("Hello world")); + let window = imgui::Window::new("Hello world"); window .size([400.0, 600.0], Condition::FirstUseEver) .build(&ui, || { - ui.text(im_str!("Hello textures!")); - ui.text(im_str!("Say hello to Lenna.jpg")); + ui.text("Hello textures!"); + ui.text("Say hello to Lenna.jpg"); Image::new(lenna_texture_id, size).build(&ui); }); } diff --git a/examples/hello_world.rs b/examples/hello-world.rs similarity index 93% rename from examples/hello_world.rs rename to examples/hello-world.rs index 2d0d59f..fe21094 100644 --- a/examples/hello_world.rs +++ b/examples/hello-world.rs @@ -165,27 +165,26 @@ fn main() { let ui = imgui.frame(); { - let window = imgui::Window::new(im_str!("Hello world")); + let window = imgui::Window::new("Hello world"); window .size([300.0, 100.0], Condition::FirstUseEver) .build(&ui, || { - ui.text(im_str!("Hello world!")); - ui.text(im_str!("This...is...imgui-rs on WGPU!")); + ui.text("Hello world!"); + ui.text("This...is...imgui-rs on WGPU!"); ui.separator(); let mouse_pos = ui.io().mouse_pos; - ui.text(im_str!( + ui.text(format!( "Mouse Position: ({:.1},{:.1})", - mouse_pos[0], - mouse_pos[1] + mouse_pos[0], mouse_pos[1] )); }); - let window = imgui::Window::new(im_str!("Hello too")); + let window = imgui::Window::new("Hello too"); window .size([400.0, 200.0], Condition::FirstUseEver) .position([400.0, 200.0], Condition::FirstUseEver) .build(&ui, || { - ui.text(im_str!("Frametime: {:?}", delta_s)); + ui.text(format!("Frametime: {:?}", delta_s)); }); ui.show_demo_window(&mut demo_open); diff --git a/resources/cube.frag b/resources/cube.frag deleted file mode 100644 index 966bfdb..0000000 --- a/resources/cube.frag +++ /dev/null @@ -1,12 +0,0 @@ -#version 450 - -layout(location = 0) in vec2 v_TexCoord; -layout(location = 0) out vec4 o_Target; -layout(set = 0, binding = 1) uniform texture2D t_Color; -layout(set = 0, binding = 2) uniform sampler s_Color; - -void main() { - vec4 tex = texture(sampler2D(t_Color, s_Color), v_TexCoord); - float mag = length(v_TexCoord-vec2(0.5)); - o_Target = vec4(mix(tex.xyz, vec3(0.0), mag*mag), 1.0); -} diff --git a/resources/cube.frag.spv b/resources/cube.frag.spv deleted file mode 100644 index f41e3c9ecc1f4afb329f0ed1d0db1806b3db0900..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1208 zcmYk4T}xC^6o%J09krbN$kf!z8STrQCWDF~O2`XugcPMN2f;yv>cBXJmqPT%`c>Wt zKF^-B!wv83z25b%&pGvxwXuj=+=}sd6T>qTBQOyYF`Dk3-GklE+2FYI_T8q6$*3ox znyDBgHWGdwo&M4>4_aUvojwZis*^S1A3+7IeAXBEZetI6=gHUb-Q6yKl>KB+W1s!E ziWit2kq~hc~#=8&o=6nv!k?j|i z{g*!UuLCvmdobpF3FI>xRjmy;^LK!C{cqInSGivCR^!Q>+8md;*A-`|O?YoXuR@#J)JRL?JtUcP!^#Cqs9 zfyQivJI#5S-^(mzQ3_O7~{WB&$8>|vaBwQ={5J$|G0kG zB<^c5{ghRovud7Q1L?5kJ?ks$e4dvx*p(*U9veQN%}?{2%(&>YCw#|6{_SI4&(qm? zcI$IOeOE+3OxGbzroi=C9`X;HU*h?T49S(VP}FJ*N}TsJ&!>E@36NNp24CWo`j zDPs2~w(k>eII|+JL{7ilzj4kZXYVo2vz$90<1wFcCyV|$Ql*WL{f{IOb3~3u5+0!D zkTZwn=MgqR z&1)U;HmdA_cd+KQuK~B*shqj@u+A@MZn1lgJ9)A=$M|Pp>zL1YaePDO8-ndi|7-qJ z^H^7r{{`b4cn9kq@1gGSJzjS${y>CvpQ85SEXLczJ}NJ^#&gvAKe!`KP-EoHV?PI| Q`!bJp#0mPFN#3A;07fE7i2wiq diff --git a/resources/cube.wgsl b/resources/cube.wgsl new file mode 100644 index 0000000..9051a6c --- /dev/null +++ b/resources/cube.wgsl @@ -0,0 +1,37 @@ +struct VertexOutput { + [[location(0)]] tex_coord: vec2; + [[builtin(position)]] position: vec4; +}; + +[[block]] +struct Locals { + transform: mat4x4; +}; +[[group(0), binding(0)]] +var r_locals: Locals; + +[[stage(vertex)]] +fn vs_main( + [[location(0)]] position: vec4, + [[location(1)]] tex_coord: vec2, +) -> VertexOutput { + var out: VertexOutput; + out.tex_coord = tex_coord; + out.position = r_locals.transform * position; + return out; +} + +[[group(0), binding(1)]] +var r_color: texture_2d; + +[[stage(fragment)]] +fn fs_main(in: VertexOutput) -> [[location(0)]] vec4 { + let tex = textureLoad(r_color, vec2(in.tex_coord * 256.0), 0); + let v = f32(tex.x) / 255.0; + return vec4(1.0 - (v * 5.0), 1.0 - (v * 15.0), 1.0 - (v * 50.0), 1.0); +} + +[[stage(fragment)]] +fn fs_wire() -> [[location(0)]] vec4 { + return vec4(0.0, 0.5, 0.0, 0.5); +} diff --git a/simple-api/Cargo.toml b/simple-api/Cargo.toml new file mode 100644 index 0000000..10754e1 --- /dev/null +++ b/simple-api/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "imgui-wgpu-simple" +version = "0.1.0" +authors = ["Noah Hüsser ", "Connor Fitzgerald ", "Steven Wittens "] +edition = "2018" +description = "A simple api for imgui-rs." +documentation = "https://docs.rs/imgui-wgpu/" +homepage = "https://github.com/Yatekii/imgui-wgpu-rs" +repository = "https://github.com/Yatekii/imgui-wgpu-rs" +readme = "README.md" +categories = ["gui", "graphics", "rendering", "rendering::graphics-api"] +keywords = ["gui", "graphics", "wgpu", "imgui"] +license = "MIT OR Apache-2.0" +publish = false + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +imgui = "0.8" +imgui-wgpu = { path = ".." } +imgui-winit-support = "0.8" +pollster = "0.2" # for block_on executor +winit = "0.25" +wgpu = "0.10" + diff --git a/simple-api/examples/basic-simple-api.rs b/simple-api/examples/basic-simple-api.rs new file mode 100644 index 0000000..e90723c --- /dev/null +++ b/simple-api/examples/basic-simple-api.rs @@ -0,0 +1,10 @@ +// you need to set --feature=simple_api_unstable to run this example +// cargo run --example basic_simple_api --features=simple_api_unstable + +fn main() { + imgui_wgpu_simple::run(Default::default(), (), |ui, _| { + imgui::Window::new("hello world").build(&ui, || { + ui.text("Hello world!"); + }); + }); +} diff --git a/examples/fullscreen_simple_api.rs b/simple-api/examples/fullscreen-simple-api.rs similarity index 81% rename from examples/fullscreen_simple_api.rs rename to simple-api/examples/fullscreen-simple-api.rs index fe61c8c..66cb94b 100644 --- a/examples/fullscreen_simple_api.rs +++ b/simple-api/examples/fullscreen-simple-api.rs @@ -1,8 +1,7 @@ // you need to set --feature=simple_api_unstable to run this example // cargo run --example fullscreen_simple_api --features=simple_api_unstable -use imgui::{im_str, Condition}; -use imgui_wgpu::simple_api; +use imgui::Condition; struct State { last_frame: std::time::Instant, @@ -12,7 +11,7 @@ struct State { } fn main() { - let config = simple_api::Config { + let config = imgui_wgpu_simple::Config { on_resize: &|input, state: &mut State, hdpi| { state.height = input.height as f32; state.width = input.width as f32; @@ -28,10 +27,10 @@ fn main() { high_dpi_factor: 2.0, }; - imgui_wgpu::simple_api::run(config, state, |ui, state| { + imgui_wgpu_simple::run(config, state, |ui, state| { let now = std::time::Instant::now(); - imgui::Window::new(im_str!("full-window example")) + imgui::Window::new("full-window example") .position([0.0, 0.0], Condition::Always) .collapsible(false) .resizable(false) @@ -44,7 +43,7 @@ fn main() { ) .menu_bar(true) .build(&ui, || { - ui.text(im_str!("Hello world!")); + ui.text("Hello world!"); }); state.last_frame = now; diff --git a/src/simple_api.rs b/simple-api/src/lib.rs similarity index 97% rename from src/simple_api.rs rename to simple-api/src/lib.rs index d6c4bac..a9d9d65 100644 --- a/src/simple_api.rs +++ b/simple-api/src/lib.rs @@ -13,18 +13,16 @@ The API consists of a Config which you may not need to touch and just use the De Optionally, you can provide your own Struct to have a place to store mutable state in your small application. ```no_run -fn main() { - imgui_wgpu::simple_api::run(Default::default(), (), |ui, _| { - imgui::Window::new(imgui::im_str!("hello world")).build(&ui, || { - ui.text(imgui::im_str!("Hello world!")); - }); +imgui_wgpu_simple::run(Default::default(), (), |ui, _| { + imgui::Window::new(imgui::im_str!("hello world")).build(&ui, || { + ui.text(imgui::im_str!("Hello world!")); }); -} +}); ``` */ -use crate::{Renderer, RendererConfig}; use imgui::*; +use imgui_wgpu::{Renderer, RendererConfig}; use pollster::block_on; use std::time::Instant; diff --git a/src/lib.rs b/src/lib.rs index 9100a19..e832b90 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,9 +14,6 @@ static FS_ENTRY_POINT_SRGB: &str = "fs_main_srgb"; pub type RendererResult = Result; -#[cfg(feature = "simple_api_unstable")] -pub mod simple_api; - #[repr(transparent)] #[derive(Debug, Copy, Clone)] struct DrawVertPod(DrawVert);