pub fn load_data_to_region(&mut self, data: &[u8], x: u32, y: u32, width: u32, height: u32) {
        if x + width > self.width && y + height > self.height {
            debug_assert!(false, "Invalid region passed ({}:{}) Region: (x: {}, y: {}, width: {}, height: {})",
                          file!(), line!(),
                          x, y, width, height);
            return;
        }
        unsafe {
            // OpenGL is allowed to expect rows in pixel data to be aligned
            // at powers of two. This ensures that any data will be accepted.
            gl::PixelStorei(gl::PACK_ALIGNMENT, 1);
            gl::PixelStorei(gl::UNPACK_ALIGNMENT, 1);

            gl::BindTexture(gl::TEXTURE_2D, self.texture);
            gl::TexSubImage2D(gl::TEXTURE_2D, 0,
                              x as GLint, y as GLint,
                              width as GLsizei, height as GLsizei,
                              self.format.unsized_format(), // It is unclear whether opengl allows a different format here
                              gl::UNSIGNED_BYTE, data.as_ptr() as *const GLvoid);
        }
    }
/// Sets the data in a sub-region of this texture. The data is expected to be in the
/// format this texture was initialized to. This texture needs to be initialized
/// before this method can be used.
/// Note that there is a debug assertion in place to ensure that the given region
/// is within the bounds of this texture. If debug assertions are not enabled this
/// function will return without taking any action.
Sets the data in a sub-region of this texture. The data is expected to be in the
format this texture was initialized to. This texture needs to be initialized
before this method can be used.
Note that there is a debug assertion in place to ensure that the given region
is within the bounds of this texture. If debug assertions are not enabled this
function will return without taking any action.
Sets the data in a sub - region of this texture . The data is expected to be in the format this texture was initialized to . This texture needs to be initialized before this method can be used . Note that there is a debug assertion in place to ensure that the given region is within the bounds of this texture . If debug assertions are not enabled this function will return without taking any action .
pub fn load_data_to_region(&mut self, data: &[u8], x: u32, y: u32, width: u32, height: u32) {
        if x + width > self.width && y + height > self.height {
            debug_assert!(false, "Invalid region passed ({}:{}) Region: (x: {}, y: {}, width: {}, height: {})",
                          file!(), line!(),
                          x, y, width, height);
            return;
        }
        unsafe {
            // OpenGL is allowed to expect rows in pixel data to be aligned
            // at powers of two. This ensures that any data will be accepted.
            gl::PixelStorei(gl::PACK_ALIGNMENT, 1);
            gl::PixelStorei(gl::UNPACK_ALIGNMENT, 1);
            gl::BindTexture(gl::TEXTURE_2D, self.texture);
            gl::TexSubImage2D(gl::TEXTURE_2D, 0,
                              x as GLint, y as GLint,
                              width as GLsizei, height as GLsizei,
                              self.format.unsized_format(), // It is unclear whether opengl allows a different format here
                              gl::UNSIGNED_BYTE, data.as_ptr() as *const GLvoid);
        }
    }
pub fn load_data_to_region ( & mut self , data : & [ u8 ] , x : u32 , y : u32 , width : u32 , height : u32 ) { if x + width > self . width && y + height > self . height { debug_assert ! ( false " " file ( ) line ( ) x y width height ) ; return ; } unsafe { // OpenGL is allowed to expect rows in pixel data to be aligned // at powers of two. This ensures that any data will be accepted. gl :: PixelStorei ( gl :: PACK_ALIGNMENT , 1 ) ; gl :: PixelStorei ( gl :: UNPACK_ALIGNMENT , 1 ) ; gl :: BindTexture ( gl :: TEXTURE_2D , self . texture ) ; gl :: TexSubImage2D ( gl :: TEXTURE_2D , 0 , x as GLint , y as GLint , width as GLsizei , height as GLsizei , self . format . unsized_format ( ) , // It is unclear whether opengl allows a different format here gl :: UNSIGNED_BYTE , data . as_ptr ( ) as * const GLvoid ) ; } }
Sets the data in a sub-region of this texture.
Sets the data in a sub - region of this texture .
&mut self
data
&[u8]
x
u32
y
u32
width
u32
height
u32
&mut self
data
&[u8]
x
u32
y
u32
width
u32
height
u32