pub fn new_render_target(width: usize, height: usize) -> RenderTarget {
        let ctxt = Context::get();

        /* Texture */
        verify!(ctxt.active_texture(Context::TEXTURE0));
        let fbo_texture = verify!(
            ctxt.create_texture()
                .expect("Failde to create framebuffer object texture.")
        );
        verify!(ctxt.bind_texture(Context::TEXTURE_2D, Some(&fbo_texture)));
        verify!(ctxt.tex_parameteri(
            Context::TEXTURE_2D,
            Context::TEXTURE_MAG_FILTER,
            Context::LINEAR as i32
        ));
        verify!(ctxt.tex_parameteri(
            Context::TEXTURE_2D,
            Context::TEXTURE_MIN_FILTER,
            Context::LINEAR as i32
        ));
        verify!(ctxt.tex_parameteri(
            Context::TEXTURE_2D,
            Context::TEXTURE_WRAP_S,
            Context::CLAMP_TO_EDGE as i32
        ));
        verify!(ctxt.tex_parameteri(
            Context::TEXTURE_2D,
            Context::TEXTURE_WRAP_T,
            Context::CLAMP_TO_EDGE as i32
        ));
        verify!(ctxt.tex_image2d(
            Context::TEXTURE_2D,
            0,
            Context::RGBA as i32,
            width as i32,
            height as i32,
            0,
            Context::RGBA,
            None
        ));
        verify!(ctxt.bind_texture(Context::TEXTURE_2D, None));

        /* Depth buffer */
        if cfg!(not(any(target_arch = "wasm32", target_arch = "asmjs"))) {
            verify!(ctxt.active_texture(Context::TEXTURE1));
            let fbo_depth = verify!(ctxt.create_texture().expect("Failed to create a texture."));
            verify!(ctxt.bind_texture(Context::TEXTURE_2D, Some(&fbo_depth)));
            verify!(ctxt.tex_parameteri(
                Context::TEXTURE_2D,
                Context::TEXTURE_MAG_FILTER,
                Context::LINEAR as i32
            ));
            verify!(ctxt.tex_parameteri(
                Context::TEXTURE_2D,
                Context::TEXTURE_MIN_FILTER,
                Context::LINEAR as i32
            ));
            verify!(ctxt.tex_parameteri(
                Context::TEXTURE_2D,
                Context::TEXTURE_WRAP_S,
                Context::CLAMP_TO_EDGE as i32
            ));
            verify!(ctxt.tex_parameteri(
                Context::TEXTURE_2D,
                Context::TEXTURE_WRAP_T,
                Context::CLAMP_TO_EDGE as i32
            ));
            verify!(ctxt.tex_image2di(
                Context::TEXTURE_2D,
                0,
                Context::DEPTH_COMPONENT as i32,
                width as i32,
                height as i32,
                0,
                Context::DEPTH_COMPONENT,
                None
            ));
            verify!(ctxt.bind_texture(Context::TEXTURE_2D, None));

            RenderTarget::Offscreen(OffscreenBuffers {
                texture: fbo_texture,
                depth: Some(fbo_depth),
            })
        } else {
            RenderTarget::Offscreen(OffscreenBuffers {
                texture: fbo_texture,
                depth: None,
            })
        }
    }
/// Creates a new render target. A render target is the combination of a color buffer and a
/// depth buffer.
Creates a new render target. A render target is the combination of a color buffer and a
depth buffer.
Creates a new render target . A render target is the combination of a color buffer and a depth buffer .
pub fn new_render_target(width: usize, height: usize) -> RenderTarget {
        let ctxt = Context::get();
        /* Texture */
        verify!(ctxt.active_texture(Context::TEXTURE0));
        let fbo_texture = verify!(
            ctxt.create_texture()
                .expect("Failde to create framebuffer object texture.")
        );
        verify!(ctxt.bind_texture(Context::TEXTURE_2D, Some(&fbo_texture)));
        verify!(ctxt.tex_parameteri(
            Context::TEXTURE_2D,
            Context::TEXTURE_MAG_FILTER,
            Context::LINEAR as i32
        ));
        verify!(ctxt.tex_parameteri(
            Context::TEXTURE_2D,
            Context::TEXTURE_MIN_FILTER,
            Context::LINEAR as i32
        ));
        verify!(ctxt.tex_parameteri(
            Context::TEXTURE_2D,
            Context::TEXTURE_WRAP_S,
            Context::CLAMP_TO_EDGE as i32
        ));
        verify!(ctxt.tex_parameteri(
            Context::TEXTURE_2D,
            Context::TEXTURE_WRAP_T,
            Context::CLAMP_TO_EDGE as i32
        ));
        verify!(ctxt.tex_image2d(
            Context::TEXTURE_2D,
            0,
            Context::RGBA as i32,
            width as i32,
            height as i32,
            0,
            Context::RGBA,
            None
        ));
        verify!(ctxt.bind_texture(Context::TEXTURE_2D, None));
        /* Depth buffer */
        if cfg!(not(any(target_arch = "wasm32", target_arch = "asmjs"))) {
            verify!(ctxt.active_texture(Context::TEXTURE1));
            let fbo_depth = verify!(ctxt.create_texture().expect("Failed to create a texture."));
            verify!(ctxt.bind_texture(Context::TEXTURE_2D, Some(&fbo_depth)));
            verify!(ctxt.tex_parameteri(
                Context::TEXTURE_2D,
                Context::TEXTURE_MAG_FILTER,
                Context::LINEAR as i32
            ));
            verify!(ctxt.tex_parameteri(
                Context::TEXTURE_2D,
                Context::TEXTURE_MIN_FILTER,
                Context::LINEAR as i32
            ));
            verify!(ctxt.tex_parameteri(
                Context::TEXTURE_2D,
                Context::TEXTURE_WRAP_S,
                Context::CLAMP_TO_EDGE as i32
            ));
            verify!(ctxt.tex_parameteri(
                Context::TEXTURE_2D,
                Context::TEXTURE_WRAP_T,
                Context::CLAMP_TO_EDGE as i32
            ));
            verify!(ctxt.tex_image2di(
                Context::TEXTURE_2D,
                0,
                Context::DEPTH_COMPONENT as i32,
                width as i32,
                height as i32,
                0,
                Context::DEPTH_COMPONENT,
                None
            ));
            verify!(ctxt.bind_texture(Context::TEXTURE_2D, None));
            RenderTarget::Offscreen(OffscreenBuffers {
                texture: fbo_texture,
                depth: Some(fbo_depth),
            })
        } else {
            RenderTarget::Offscreen(OffscreenBuffers {
                texture: fbo_texture,
                depth: None,
            })
        }
    }
pub fn new_render_target ( width : usize , height : usize ) -> RenderTarget { let ctxt = Context :: get ( ) ; /* Texture */ verify ! ( ctxt active_texture ( Context TEXTURE0 ) ) ; let fbo_texture = verify ! ( ctxt create_texture ( ) expect ( " " ) ) ; verify ! ( ctxt bind_texture ( Context TEXTURE_2D Some ( fbo_texture ) ) ) ; verify ! ( ctxt tex_parameteri ( Context TEXTURE_2D Context TEXTURE_MAG_FILTER Context LINEAR as i32 ) ) ; verify ! ( ctxt tex_parameteri ( Context TEXTURE_2D Context TEXTURE_MIN_FILTER Context LINEAR as i32 ) ) ; verify ! ( ctxt tex_parameteri ( Context TEXTURE_2D Context TEXTURE_WRAP_S Context CLAMP_TO_EDGE as i32 ) ) ; verify ! ( ctxt tex_parameteri ( Context TEXTURE_2D Context TEXTURE_WRAP_T Context CLAMP_TO_EDGE as i32 ) ) ; verify ! ( ctxt tex_image2d ( Context TEXTURE_2D 0 Context RGBA as i32 width as i32 height as i32 0 Context RGBA None ) ) ; verify ! ( ctxt bind_texture ( Context TEXTURE_2D None ) ) ; /* Depth buffer */ if cfg ! ( not ( any ( target_arch " " target_arch " " ) ) ) { verify ! ( ctxt active_texture ( Context TEXTURE1 ) ) ; let fbo_depth = verify ! ( ctxt create_texture ( ) expect ( " " ) ) ; verify ! ( ctxt bind_texture ( Context TEXTURE_2D Some ( fbo_depth ) ) ) ; verify ! ( ctxt tex_parameteri ( Context TEXTURE_2D Context TEXTURE_MAG_FILTER Context LINEAR as i32 ) ) ; verify ! ( ctxt tex_parameteri ( Context TEXTURE_2D Context TEXTURE_MIN_FILTER Context LINEAR as i32 ) ) ; verify ! ( ctxt tex_parameteri ( Context TEXTURE_2D Context TEXTURE_WRAP_S Context CLAMP_TO_EDGE as i32 ) ) ; verify ! ( ctxt tex_parameteri ( Context TEXTURE_2D Context TEXTURE_WRAP_T Context CLAMP_TO_EDGE as i32 ) ) ; verify ! ( ctxt tex_image2di ( Context TEXTURE_2D 0 Context DEPTH_COMPONENT as i32 width as i32 height as i32 0 Context DEPTH_COMPONENT None ) ) ; verify ! ( ctxt bind_texture ( Context TEXTURE_2D None ) ) ; RenderTarget :: Offscreen ( OffscreenBuffers { texture : fbo_texture , depth : Some ( fbo_depth ) , } ) } else { RenderTarget :: Offscreen ( OffscreenBuffers { texture : fbo_texture , depth : None , } ) } }
Creates a new render target.
Creates a new render target .
width
usize
height
usize
width
usize
height
usize