MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / begin_mode_2d

Method begin_mode_2d

native/shared/src/renderer/mod.rs:12047–12074  ·  view source on GitHub ↗
(&mut self, offset_x: f32, offset_y: f32, target_x: f32, target_y: f32, rotation: f32, zoom: f32)

Source from the content-addressed store, hash-verified

12045 // ============================================================
12046
12047 pub fn begin_mode_2d(&mut self, offset_x: f32, offset_y: f32, target_x: f32, target_y: f32, rotation: f32, zoom: f32) {
12048 self.uniform_slot_count += 1;
12049 if self.uniform_slot_count >= MAX_UNIFORM_SLOTS { return; }
12050 self.current_uniform_idx = self.uniform_slot_count as u32;
12051
12052 let cos_r = rotation.to_radians().cos();
12053 let sin_r = rotation.to_radians().sin();
12054 let tx = target_x;
12055 let ty = target_y;
12056 let view_proj: [[f32; 4]; 4] = [
12057 [zoom * cos_r, -zoom * sin_r, 0.0, 0.0],
12058 [zoom * sin_r, zoom * cos_r, 0.0, 0.0],
12059 [0.0, 0.0, 1.0, 0.0],
12060 [offset_x - zoom * (cos_r * tx + sin_r * ty),
12061 offset_y + zoom * (sin_r * tx - cos_r * ty),
12062 0.0, 1.0],
12063 ];
12064
12065 let w = self.logical_width as f32;
12066 let h = self.logical_height as f32;
12067 let uniforms = Uniforms2D { screen_size: [w, h], _pad: [0.0; 2], view_proj };
12068 self.queue.write_buffer(
12069 &self.uniform_buffers[self.current_uniform_idx as usize],
12070 0,
12071 bytemuck::bytes_of(&uniforms),
12072 );
12073 self.render_mode = RenderMode::Mode2D;
12074 }
12075
12076 pub fn end_mode_2d(&mut self) {
12077 self.current_uniform_idx = 0;

Callers 7

bloom_begin_mode_2dFunction · 0.80
bloom_begin_mode_2dFunction · 0.80
bloom_begin_mode_2dFunction · 0.80
bloom_begin_mode_2dFunction · 0.80
bloom_begin_mode_2dFunction · 0.80
bloom_begin_mode_2dFunction · 0.80
bloom_begin_mode_2dFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected