|
1 | | -use hotline_rs::{*, prelude::*}; |
| 1 | +use hotline_rs::*; |
2 | 2 |
|
3 | 3 | use os::{App, Window}; |
4 | 4 | use gfx::{CmdBuf, Device, SwapChain}; |
5 | 5 |
|
6 | | -use std::fs; |
7 | | - |
8 | | -#[repr(C)] |
9 | | -struct Vertex { |
10 | | - position: [f32; 2], |
11 | | - uv: [f32; 2], |
12 | | - color: [f32; 4], |
13 | | -} |
14 | | - |
15 | 6 | fn main() -> Result<(), hotline_rs::Error> { |
16 | 7 | // app |
17 | 8 | let mut app = os_platform::App::create(os::AppInfo { |
@@ -68,81 +59,6 @@ fn main() -> Result<(), hotline_rs::Error> { |
68 | 59 | }; |
69 | 60 | let mut imgui = imgui::ImGui::create(&mut imgui_info).unwrap(); |
70 | 61 |
|
71 | | - // dummy vb |
72 | | - let vertices = [ |
73 | | - Vertex { |
74 | | - position: [-1.0, -1.0], |
75 | | - uv: [0.0, 0.0], |
76 | | - color: [0.0, 0.0, 0.0, 1.0], |
77 | | - }, |
78 | | - Vertex { |
79 | | - position: [-1.0, 1.0], |
80 | | - uv: [0.0, 0.0], |
81 | | - color: [0.0, 1.0, 0.0, 1.0], |
82 | | - }, |
83 | | - Vertex { |
84 | | - position: [1.0, 1.0], |
85 | | - uv: [0.0, 0.0], |
86 | | - color: [1.0, 1.0, 0.0, 1.0], |
87 | | - }, |
88 | | - Vertex { |
89 | | - position: [1.0, -1.0], |
90 | | - uv: [0.0, 0.0], |
91 | | - color: [1.0, 0.0, 0.0, 1.0], |
92 | | - }, |
93 | | - ]; |
94 | | - |
95 | | - |
96 | | - let info = gfx::BufferInfo { |
97 | | - usage: gfx::BufferUsage::VERTEX, |
98 | | - cpu_access: gfx::CpuAccessFlags::NONE, |
99 | | - format: gfx::Format::Unknown, |
100 | | - stride: std::mem::size_of::<Vertex>(), |
101 | | - num_elements: 4, |
102 | | - initial_state: gfx::ResourceState::VertexConstantBuffer |
103 | | - }; |
104 | | - |
105 | | - let vertex_buffer = dev.create_buffer(&info, Some(gfx::as_u8_slice(&vertices)))?; |
106 | | - |
107 | | - // index buffer |
108 | | - let indices: [u16; 6] = [0, 1, 2, 0, 2, 3]; |
109 | | - let info = gfx::BufferInfo { |
110 | | - usage: gfx::BufferUsage::INDEX, |
111 | | - cpu_access: gfx::CpuAccessFlags::NONE, |
112 | | - format: gfx::Format::R16u, |
113 | | - stride: std::mem::size_of::<u16>(), |
114 | | - num_elements: 6, |
115 | | - initial_state: gfx::ResourceState::IndexBuffer |
116 | | - }; |
117 | | - let index_buffer = dev.create_buffer(&info, Some(gfx::as_u8_slice(&indices)))?; |
118 | | - |
119 | | - // create imgui shader |
120 | | - let mut pmfx : pmfx::Pmfx<gfx_platform::Device> = pmfx::Pmfx::create(&mut dev, 0); |
121 | | - pmfx.load(&hotline_rs::get_data_path("shaders/imgui"))?; |
122 | | - pmfx.create_render_pipeline(&dev, "default", swap_chain.get_backbuffer_pass())?; |
123 | | - let fmt = swap_chain.get_backbuffer_pass().get_format_hash(); |
124 | | - let pso_pmfx = pmfx.get_render_pipeline_for_format("default", fmt)?; |
125 | | - |
126 | | - // create pipeline manually |
127 | | - let vsc_filepath = crate::get_data_path("shaders/imgui/vs_main.vsc"); |
128 | | - let psc_filepath = crate::get_data_path("shaders/imgui/ps_main.psc"); |
129 | | - |
130 | | - let vsc_data = std::fs::read(vsc_filepath)?; |
131 | | - let psc_data = std::fs::read(psc_filepath)?; |
132 | | - |
133 | | - let vs_info = gfx::ShaderInfo { |
134 | | - shader_type: gfx::ShaderType::Vertex, |
135 | | - compile_info: None |
136 | | - }; |
137 | | - |
138 | | - let ps_info = gfx::ShaderInfo { |
139 | | - shader_type: gfx::ShaderType::Fragment, |
140 | | - compile_info: None |
141 | | - }; |
142 | | - |
143 | | - let vs = dev.create_shader(&vs_info, &vsc_data)?; |
144 | | - let fs = dev.create_shader(&ps_info, &psc_data)?; |
145 | | - |
146 | 62 | // .. |
147 | 63 | let mut ci = 0; |
148 | 64 | while app.run() { |
|
0 commit comments