pub struct Context { /* private fields */ }Expand description
Contains information about the graphics context to use for rendering and other “global” variables.
Implementations
sourceimpl Context
impl Context
sourcepub fn from_gl_context(context: GLContext) -> Self
pub fn from_gl_context(context: GLContext) -> Self
Creates a new context from a OpenGL/WebGL context.
sourcepub fn program(
&self,
vertex_shader_source: &str,
fragment_shader_source: &str,
callback: impl FnOnce(&Program) -> ThreeDResult<()>
) -> ThreeDResult<()>
pub fn program(
&self,
vertex_shader_source: &str,
fragment_shader_source: &str,
callback: impl FnOnce(&Program) -> ThreeDResult<()>
) -> ThreeDResult<()>
Compiles a Program with the given vertex and fragment shader source and stores it for later use. If it has already been created, then it is just returned.
sourcepub fn effect(
&self,
fragment_shader_source: &str,
callback: impl FnOnce(&ImageEffect) -> ThreeDResult<()>
) -> ThreeDResult<()>
pub fn effect(
&self,
fragment_shader_source: &str,
callback: impl FnOnce(&ImageEffect) -> ThreeDResult<()>
) -> ThreeDResult<()>
Compiles an ImageEffect with the given fragment shader source and stores it for later use. If it has already been created, then it is just returned.
sourcepub fn camera2d(
&self,
viewport: Viewport,
callback: impl FnOnce(&Camera) -> ThreeDResult<()>
) -> ThreeDResult<()>
pub fn camera2d(
&self,
viewport: Viewport,
callback: impl FnOnce(&Camera) -> ThreeDResult<()>
) -> ThreeDResult<()>
Returns a camera for viewing 2D content.
sourceimpl Context
impl Context
sourcepub fn new() -> ThreeDResult<Self>
pub fn new() -> ThreeDResult<Self>
Creates a new headless graphics context (a graphics context that is not associated with any window).
Methods from Deref<Target = GLContext>
pub fn finish(&self)
pub fn create_shader(&self, type_: ShaderType) -> Option<Shader>
pub fn compile_shader(&self, source: &str, shader: &Shader)
pub fn get_shader_info_log(&self, shader: &Shader) -> Option<String>
pub fn delete_shader(&self, shader: Option<&Shader>)
pub fn attach_shader(&self, program: &Program, shader: &Shader)
pub fn detach_shader(&self, program: &Program, shader: &Shader)
pub fn get_program_parameter(&self, program: &Program, pname: u32) -> u32
pub fn get_active_attrib(&self, program: &Program, index: u32) -> ActiveInfo
pub fn get_active_uniform(&self, program: &Program, index: u32) -> ActiveInfo
pub fn create_buffer(&self) -> Option<Buffer>
pub fn delete_buffer(&self, buffer: &Buffer)
pub fn bind_buffer_base(&self, target: u32, index: u32, buffer: &Buffer)
pub fn bind_buffer(&self, target: u32, buffer: &Buffer)
pub fn unbind_buffer(&self, target: u32)
pub fn get_uniform_block_index(&self, program: &Program, name: &str) -> u32
pub fn uniform_block_binding(
&self,
program: &Program,
location: u32,
index: u32
)
pub fn buffer_data(&self, target: u32, size_in_bytes: u32, usage: u32)
pub fn buffer_data_u8(&self, target: u32, data: &[u8], usage: u32)
pub fn buffer_data_u16(&self, target: u32, data: &[u16], usage: u32)
pub fn buffer_data_u32(&self, target: u32, data: &[u32], usage: u32)
pub fn buffer_data_f32(&self, target: u32, data: &[f32], usage: u32)
pub fn create_vertex_array(&self) -> Option<VertexArrayObject>
pub fn bind_vertex_array(&self, array: &VertexArrayObject)
pub fn create_program(&self) -> Program
pub fn link_program(&self, program: &Program) -> bool
pub fn get_program_info_log(&self, program: &Program) -> Option<String>
pub fn use_program(&self, program: &Program)
pub fn unuse_program(&self)
pub fn delete_program(&self, program: &Program)
pub fn get_attrib_location(
&self,
program: &Program,
name: &str
) -> Option<AttributeLocation>
pub fn enable_vertex_attrib_array(&self, location: AttributeLocation)
pub fn disable_vertex_attrib_array(&self, location: AttributeLocation)
pub fn vertex_attrib_pointer(
&self,
location: AttributeLocation,
size: u32,
data_type: DataType,
normalized: bool,
stride: u32,
offset: u32
)
pub fn vertex_attrib_divisor(&self, location: AttributeLocation, divisor: u32)
pub fn get_uniform_location(
&self,
program: &Program,
name: &str
) -> Option<UniformLocation>
pub fn uniform1i(&self, location: &UniformLocation, data: i32)
pub fn uniform1f(&self, location: &UniformLocation, data: f32)
pub fn uniform2fv(&self, location: &UniformLocation, data: &[f32])
pub fn uniform3fv(&self, location: &UniformLocation, data: &[f32])
pub fn uniform4fv(&self, location: &UniformLocation, data: &[f32])
pub fn uniform_matrix2fv(&self, location: &UniformLocation, data: &[f32])
pub fn uniform_matrix3fv(&self, location: &UniformLocation, data: &[f32])
pub fn uniform_matrix4fv(&self, location: &UniformLocation, data: &[f32])
pub fn draw_buffers(&self, draw_buffers: &[u32])
pub fn create_framebuffer(&self) -> Option<Framebuffer>
pub fn bind_framebuffer(&self, target: u32, framebuffer: Option<&Framebuffer>)
pub fn delete_framebuffer(&self, framebuffer: Option<&Framebuffer>)
pub fn check_framebuffer_status(&self) -> Result<(), String>
pub fn blit_framebuffer(
&self,
src_x0: u32,
src_y0: u32,
src_x1: u32,
src_y1: u32,
dst_x0: u32,
dst_y0: u32,
dst_x1: u32,
dst_y1: u32,
mask: u32,
filter: u32
)
pub fn viewport(&self, x: i32, y: i32, width: i32, height: i32)
pub fn clear_color(&self, red: f32, green: f32, blue: f32, alpha: f32)
pub fn clear_depth(&self, depth: f32)
pub fn clear(&self, mask: u32)
pub fn enable(&self, cap: u32)
pub fn disable(&self, cap: u32)
pub fn blend_func(&self, sfactor: u32, dfactor: u32)
pub fn blend_func_separate(
&self,
src_rgb: u32,
dst_rgb: u32,
src_alpha: u32,
dst_alpha: u32
)
pub fn blend_equation(&self, mode: u32)
pub fn blend_equation_separate(&self, mode_rgb: u32, mode_alpha: u32)
pub fn cull_face(&self, mode: u32)
pub fn scissor(&self, x: i32, y: i32, width: i32, height: i32)
pub fn depth_func(&self, func: u32)
pub fn color_mask(&self, red: bool, green: bool, blue: bool, alpha: bool)
pub fn depth_mask(&self, flag: bool)
pub fn create_texture(&self) -> Option<Texture>
pub fn active_texture(&self, texture: u32)
pub fn bind_texture(&self, target: u32, texture: &Texture)
pub fn generate_mipmap(&self, target: u32)
pub fn tex_storage_2d(
&self,
target: u32,
levels: u32,
internalformat: u32,
width: u32,
height: u32
)
pub fn tex_storage_3d(
&self,
target: u32,
levels: u32,
internalformat: u32,
width: u32,
height: u32,
depth: u32
)
pub fn tex_image_2d(
&self,
target: u32,
level: u32,
internalformat: u32,
width: u32,
height: u32,
border: u32,
format: u32,
data_type: DataType
)
pub fn tex_image_2d_with_u8_data(
&self,
target: u32,
level: u32,
internalformat: u32,
width: u32,
height: u32,
border: u32,
format: u32,
data_type: DataType,
pixels: &[u8]
)
pub fn tex_sub_image_2d_with_u8_data(
&self,
target: u32,
level: u32,
x_offset: u32,
y_offset: u32,
width: u32,
height: u32,
format: u32,
data_type: DataType,
pixels: &[u8]
)
pub fn tex_image_2d_with_f32_data(
&self,
target: u32,
level: u32,
internalformat: u32,
width: u32,
height: u32,
border: u32,
format: u32,
data_type: DataType,
pixels: &[f32]
)
pub fn tex_sub_image_2d_with_f32_data(
&self,
target: u32,
level: u32,
x_offset: u32,
y_offset: u32,
width: u32,
height: u32,
format: u32,
data_type: DataType,
pixels: &[f32]
)
pub fn tex_sub_image_2d_with_u16_data(
&self,
target: u32,
level: u32,
x_offset: u32,
y_offset: u32,
width: u32,
height: u32,
format: u32,
data_type: DataType,
pixels: &[u16]
)
pub fn tex_sub_image_2d_with_u32_data(
&self,
target: u32,
level: u32,
x_offset: u32,
y_offset: u32,
width: u32,
height: u32,
format: u32,
data_type: DataType,
pixels: &[u32]
)
pub fn tex_image_3d(
&self,
target: u32,
level: u32,
internalformat: u32,
width: u32,
height: u32,
depth: u32,
format: u32,
data_type: DataType
)
pub fn tex_image_3d_with_u16_data(
&self,
target: u32,
level: u32,
internalformat: u32,
width: u32,
height: u32,
depth: u32,
border: u32,
format: u32,
data_type: DataType,
pixels: &[u16]
)
pub fn tex_parameteri(&self, target: u32, pname: u32, param: i32)
pub fn delete_texture(&self, texture: &Texture)
pub fn framebuffer_texture_2d(
&self,
target: u32,
attachment: u32,
textarget: u32,
texture: &Texture,
level: u32
)
pub fn framebuffer_texture_layer(
&self,
target: u32,
attachment: u32,
texture: &Texture,
level: u32,
layer: u32
)
pub fn draw_arrays(&self, mode: u32, first: u32, count: u32)
pub fn draw_arrays_instanced(
&self,
mode: u32,
first: u32,
count: u32,
instance_count: u32
)
pub fn draw_elements(
&self,
mode: u32,
count: u32,
data_type: DataType,
offset: u32
)
pub fn draw_elements_instanced(
&self,
mode: u32,
count: u32,
data_type: DataType,
offset: u32,
instance_count: u32
)
pub fn read_pixels_with_u8_data(
&self,
x: u32,
y: u32,
width: u32,
height: u32,
format: u32,
data_type: DataType,
dst_data: &mut [u8]
)
pub fn read_pixels_with_u16_data(
&self,
x: u32,
y: u32,
width: u32,
height: u32,
format: u32,
data_type: DataType,
dst_data: &mut [u16]
)
pub fn read_pixels_with_f32_data(
&self,
x: u32,
y: u32,
width: u32,
height: u32,
format: u32,
data_type: DataType,
dst_data: &mut [f32]
)
pub fn read_pixels_with_u32_data(
&self,
x: u32,
y: u32,
width: u32,
height: u32,
format: u32,
data_type: DataType,
dst_data: &mut [u32]
)
pub fn flush(&self)
pub fn fence_sync(&self) -> Sync
pub fn client_wait_sync(&self, sync: &Sync, flags: u32, timeout: u32) -> u32
pub fn delete_sync(&self, sync: &Sync)
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Context
impl !Send for Context
impl !Sync for Context
impl Unpin for Context
impl !UnwindSafe for Context
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more