fn render(&mut self, this: *mut IDXGISwapChain, sync_interval: UINT, flags: UINT) -> HRESULT {
    // SAFETY
    // idk lmao
    unsafe {
      self.p_device_context.as_ref().unwrap().OMSetRenderTargets(
        1,
        &mut self.render_target_view as *mut *mut _,
        null_mut(),
      );
    }
    // SAFETY
    // No reason this.as_ref() should error at this point, and probably it's a
    // good idea to crash and burn if it does. TODO check
    let mut sd: DXGI_SWAP_CHAIN_DESC = unsafe { std::mem::zeroed() };
    unsafe { this.as_ref().unwrap().GetDesc(&mut sd as _) };

    let mut rect: RECT = unsafe { std::mem::zeroed() };
    if unsafe { GetWindowRect(sd.OutputWindow, &mut rect as _) } != 0 {
      let mut io = self.imgui_ctx.io_mut();

      io.display_size = [
        (rect.right - rect.left) as f32,
        (rect.bottom - rect.top) as f32,
      ];

      let io = self.imgui_ctx.io();
      let keys_down = io
        .keys_down
        .iter()
        .enumerate()
        .filter_map(|(idx, &val)| if val { Some(idx) } else { None })
        .collect::<Vec<_>>();
      let imgui::Io {
        key_ctrl,
        key_shift,
        key_alt,
        key_super,
        display_size,
        ..
      } = *io;

      trace!("Calling render loop");
      set_mouse_pos(&mut self.imgui_ctx, sd.OutputWindow);
      let ui = self.imgui_ctx.frame();

      self.render_loop.render(RenderContext {
        frame: &ui,
        key_ctrl,
        key_shift,
        key_alt,
        key_super,
        keys_down,
        display_size,
      });

      trace!("Rendering frame data");
      let dd = ui.render();

      if self.render_loop.is_visible() {
        trace!("Displaying image data");
        match self.renderer.render(dd) {
          Ok(_) => {}
          Err(e) => error!("Renderer errored: {:?}", e),
        };
      }
    }

    unsafe { (self.present_trampoline)(this, sync_interval, flags) }
  }
/// Render loop function.
///
/// This function is called in place of the regular `IDXGISwapChain::Present`
/// function and is responsible for finally calling the trampoline and
/// letting the game run its own code.
Render loop function.
This function is called in place of the regular `IDXGISwapChain::Present`
function and is responsible for finally calling the trampoline and
letting the game run its own code.
Render loop function . This function is called in place of the regular ` IDXGISwapChain :: Present ` function and is responsible for finally calling the trampoline and letting the game run its own code .
fn render(&mut self, this: *mut IDXGISwapChain, sync_interval: UINT, flags: UINT) -> HRESULT {
    // SAFETY
    // idk lmao
    unsafe {
      self.p_device_context.as_ref().unwrap().OMSetRenderTargets(
        1,
        &mut self.render_target_view as *mut *mut _,
        null_mut(),
      );
    }
    // SAFETY
    // No reason this.as_ref() should error at this point, and probably it's a
    // good idea to crash and burn if it does. TODO check
    let mut sd: DXGI_SWAP_CHAIN_DESC = unsafe { std::mem::zeroed() };
    unsafe { this.as_ref().unwrap().GetDesc(&mut sd as _) };
    let mut rect: RECT = unsafe { std::mem::zeroed() };
    if unsafe { GetWindowRect(sd.OutputWindow, &mut rect as _) } != 0 {
      let mut io = self.imgui_ctx.io_mut();
      io.display_size = [
        (rect.right - rect.left) as f32,
        (rect.bottom - rect.top) as f32,
      ];
      let io = self.imgui_ctx.io();
      let keys_down = io
        .keys_down
        .iter()
        .enumerate()
        .filter_map(|(idx, &val)| if val { Some(idx) } else { None })
        .collect::<Vec<_>>();
      let imgui::Io {
        key_ctrl,
        key_shift,
        key_alt,
        key_super,
        display_size,
        ..
      } = *io;
      trace!("Calling render loop");
      set_mouse_pos(&mut self.imgui_ctx, sd.OutputWindow);
      let ui = self.imgui_ctx.frame();
      self.render_loop.render(RenderContext {
        frame: &ui,
        key_ctrl,
        key_shift,
        key_alt,
        key_super,
        keys_down,
        display_size,
      });
      trace!("Rendering frame data");
      let dd = ui.render();
      if self.render_loop.is_visible() {
        trace!("Displaying image data");
        match self.renderer.render(dd) {
          Ok(_) => {}
          Err(e) => error!("Renderer errored: {:?}", e),
        };
      }
    }
    unsafe { (self.present_trampoline)(this, sync_interval, flags) }
  }
fn render ( & mut self , this : * mut IDXGISwapChain , sync_interval : UINT , flags : UINT ) -> HRESULT { // SAFETY // idk lmao unsafe { self . p_device_context . as_ref ( ) . unwrap ( ) . OMSetRenderTargets ( 1 , & mut self . render_target_view as * mut * mut _ , null_mut ( ) , ) ; } // SAFETY // No reason this.as_ref() should error at this point, and probably it's a // good idea to crash and burn if it does. TODO check let mut sd : DXGI_SWAP_CHAIN_DESC = unsafe { std :: mem :: zeroed ( ) } ; unsafe { this . as_ref ( ) . unwrap ( ) . GetDesc ( & mut sd as _ ) } ; let mut rect : RECT = unsafe { std :: mem :: zeroed ( ) } ; if unsafe { GetWindowRect ( sd . OutputWindow , & mut rect as _ ) } != 0 { let mut io = self . imgui_ctx . io_mut ( ) ; io . display_size = [ ( rect . right - rect . left ) as f32 , ( rect . bottom - rect . top ) as f32 , ] ; let io = self . imgui_ctx . io ( ) ; let keys_down = io . keys_down . iter ( ) . enumerate ( ) . filter_map ( | ( idx , & val ) | if val { Some ( idx ) } else { None } ) . collect :: < Vec < _ > > ( ) ; let imgui :: Io { key_ctrl , key_shift , key_alt , key_super , display_size , .. } = * io ; trace ! ( " " ) ; set_mouse_pos ( & mut self . imgui_ctx , sd . OutputWindow ) ; let ui = self . imgui_ctx . frame ( ) ; self . render_loop . render ( RenderContext { frame : & ui , key_ctrl , key_shift , key_alt , key_super , keys_down , display_size , } ) ; trace ! ( " " ) ; let dd = ui . render ( ) ; if self . render_loop . is_visible ( ) { trace ! ( " " ) ; match self . renderer . render ( dd ) { Ok ( _ ) => { } Err ( e ) => error ! ( " " e ) , } ; } } unsafe { ( self . present_trampoline ) ( this , sync_interval , flags ) } }
Render loop function.
Render loop function .
&mut self
this
*mut IDXGISwapChain
sync_interval
UINT
flags
UINT