Skip to main content

GlGraphicsServer

Struct GlGraphicsServer 

Source
pub struct GlGraphicsServer {
    pub gl: Context,
    pub named_objects: Cell<bool>,
    /* private fields */
}
Expand description

GlGraphicsServer implements the GraphicsServer trait using the glow crate. glow is “GL on Whatever: a set of bindings to run GL anywhere (Open GL, OpenGL ES, and WebGL) and avoid target-specific code.”

Fields§

§gl: Context

glow::Context provides access to the current rendering state. It creates buffers, creates textures, compiles shaders, accepts geometry data, and broadly provides access too all sorts of rendering services.

§named_objects: Cell<bool>

Controls whether objects the glow::Context::object_label method should be used to assign labels to rendering objects. These labels can help with debugging.

Implementations§

Source§

impl GlGraphicsServer

Source

pub fn new( vsync: bool, msaa_sample_count: Option<u8>, window_target: &ActiveEventLoop, window_attributes: WindowAttributes, named_objects: bool, ) -> Result<(Window, Rc<dyn GraphicsServer>), FrameworkError>

Source

pub fn weak(&self) -> Weak<GlGraphicsServer>

A weak reference to the Rc where the server is stored.

Source

pub fn gl_kind(&self) -> GlKind

Determine if we are using the embedded version of OpenGL.

Source

pub fn free_texture_unit(&self) -> Option<u32>

Find the number of a texture unit where no texture is bound, if possible.

Source

pub fn delete_program(&self, program: <Context as HasContext>::Program)

Delete the given program. See glDeleteProgram from OpenGL.

Trait Implementations§

Source§

impl GraphicsServer for GlGraphicsServer

Source§

fn create_buffer( &self, desc: GpuBufferDescriptor<'_>, ) -> Result<GpuBuffer, FrameworkError>

Creates a GPU buffer with the given size and kind. Usage is a hint to the video driver that allows to perform some potential performance optimizations.
Source§

fn create_texture( &self, desc: GpuTextureDescriptor<'_>, ) -> Result<GpuTexture, FrameworkError>

Creates a new GPU texture using the given descriptor.
Source§

fn create_sampler( &self, desc: GpuSamplerDescriptor, ) -> Result<GpuSampler, FrameworkError>

Creates a new GPU sampler that can be used to sample texels from a texture.
Source§

fn create_frame_buffer( &self, depth_attachment: Option<Attachment>, color_attachments: Vec<Attachment>, ) -> Result<GpuFrameBuffer, FrameworkError>

Creates a new frame buffer using the given depth and color attachments. Depth attachment not exist, but there must be at least one color attachment of a format that supports rendering.
Source§

fn back_buffer(&self) -> GpuFrameBuffer

Creates a frame buffer that “connected” to the final image that will be displayed to the screen.
Source§

fn create_query(&self) -> Result<GpuQuery, FrameworkError>

Creates a new GPU query, that can perform asynchronous data fetching from GPU. Usually it is used to create occlusion queries.
Source§

fn create_shader( &self, name: String, kind: ShaderKind, source: String, resources: &[ShaderResourceDefinition], line_offset: isize, ) -> Result<GpuShader, FrameworkError>

Creates a new named GPU shader. The name could be used for debugging purposes. The implementation of graphics server will generate proper resource bindings in the shader code for you.
Source§

fn create_program( &self, name: &str, vertex_source: String, vertex_source_line_offset: isize, fragment_source: String, fragment_source_line_offset: isize, resources: &[ShaderResourceDefinition], ) -> Result<GpuProgram, FrameworkError>

Creates a new named GPU program using source code of both vertex and fragment shaders. The name could be used for debugging purposes. The implementation of graphics server will generate proper resource bindings in the shader code for you.
Source§

fn create_program_from_shaders( &self, name: &str, vertex_shader: &GpuShader, fragment_shader: &GpuShader, resources: &[ShaderResourceDefinition], ) -> Result<GpuProgram, FrameworkError>

Creates a new named GPU program using a pair of vertex and fragment shaders. The name could be used for debugging purposes. The implementation of graphics server will generate proper resource bindings in the shader code for you.
Source§

fn create_async_read_buffer( &self, name: &str, pixel_size: usize, pixel_count: usize, ) -> Result<GpuAsyncReadBuffer, FrameworkError>

Creates a new read-back buffer, that can be used to obtain texture data from GPU. It can be used to read rendering result from GPU to CPU memory and save the result to disk.
Source§

fn create_geometry_buffer( &self, desc: GpuGeometryBufferDescriptor<'_>, ) -> Result<GpuGeometryBuffer, FrameworkError>

Creates a new geometry buffer, which consists of one or more vertex buffers and only one element buffer. Geometry buffer could be considered as a complex mesh storage allocated on GPU.
Source§

fn weak(&self) -> Weak<dyn GraphicsServer>

Creates a weak reference to the shared graphics server.
Source§

fn flush(&self)

Sends all scheduled GPU command buffers for execution on GPU without waiting for a certain threshold.
Source§

fn finish(&self)

Waits until all the scheduled GPU commands are fully executed. This is blocking operation, and it blocks the current thread until all the commands are fully executed.
Source§

fn invalidate_resource_bindings_cache(&self)

Unbinds the all bound resources from the graphics pipeline.
Source§

fn pipeline_statistics(&self) -> PipelineStatistics

Returns GPU pipeline statistics. See PipelineStatistics for more info.
Source§

fn swap_buffers(&self) -> Result<(), FrameworkError>

Swaps the front and back buffers and thus presenting the final image on screen. There could be more than two buffers, and it is up to the graphics server implementation to choose the right amount, but it can’t be less than two.
Source§

fn set_frame_size(&self, new_size: (u32, u32))

Notifies the graphics server that the size of the back buffer has changed. It has very limited use and there are very few platforms (Linux with Wayland mostly) that needs this function to be called.
Source§

fn generate_mipmap(&self, texture: &GpuTexture)

Generates mipmaps for the given texture. Graphics server implementation can pick any desired way of mipmaps generation, depending on the underlying GAPI capabilities.
Source§

fn capabilities(&self) -> ServerCapabilities

Returns current capabilities of the graphics server. See ServerCapabilities for more info.
Source§

fn set_polygon_fill_mode( &self, polygon_face: PolygonFace, polygon_fill_mode: PolygonFillMode, )

Sets current polygon fill mode for front faces, back faces, or both. The mode of front faces is controlled separately from the mode of back faces, and polygon_face determines which mode is set by this method. See PolygonFace and PolygonFillMode docs for more info.
Source§

fn memory_usage(&self) -> ServerMemoryUsage

Fetches the total amount of memory used by the graphics server.
Source§

fn push_debug_group(&self, name: &str)

Begins a new named debug group. It is recommended to use Self::begin_scope instead, so that the compiler will manage the scope lifetime for your correctly. Otherwise, a forgotten call to Self::pop_debug_group may cause stack overflow or underflow errors.
Source§

fn pop_debug_group(&self)

Ends the current debug group.
Source§

fn begin_scope(&self, name: &str) -> RenderingScope

Begins a new debug scope by creating a temporary object that automatically exits the scope on drop. The scope could be created like so: let _debug_scope = server.begin_scope("ScopeName"); Note the let _debug_scope = ... part - it is important to keep the produced object alive until the end of the current semantic scope. Do not call this method like so: server.begin_scope("VisibilityTest"); because it will enter and leave the scope instantly.
Source§

fn create_2d_render_target( &self, name: &str, pixel_kind: PixelKind, width: usize, height: usize, ) -> Result<GpuTexture, FrameworkError>

A shortcut for Self::create_texture, that creates a rectangular texture with the given size and pixel kind.
Source§

fn create_cube_render_target( &self, name: &str, pixel_kind: PixelKind, size: usize, ) -> Result<GpuTexture, FrameworkError>

A shortcut for Self::create_texture, that creates a cube texture with the given size and pixel kind.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> GraphicsServerAsAny for T
where T: GraphicsServer,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Casts self as &dyn Any.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Casts self as &mut dyn Any.
Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Casts Box<Self> as Box<dyn Any>.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T, U> ObjectOrVariant<T> for U

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more