Skip to main content

GL

Struct GL 

Source
pub struct GL;
Expand description

Low-level, stateless OpenGL 4.6 wrappers.

Every method is a thin wrapper around a single gl::* call — no state tracking, no error handling. Use GPU for stateful rendering.

§Example

optic_render::GL::clear();
optic_render::GL::set_clear(RGBA::grey(0.2));

Implementations§

Source§

impl GL

Source

pub fn clear()

Clears the colour and depth buffer of the currently bound framebuffer.

Source

pub fn set_clear(color: RGBA)

Sets the clear colour for subsequent clear calls.

Source

pub fn resize(size: Size2D)

Sets the OpenGL viewport to span (0, 0, size.w, size.h).

Source

pub fn poly_mode(mode: PolyMode)

Sets polygon rasterisation mode (filled, wireframe, or points).

Source

pub fn enable_msaa(enable: bool)

Enables or disables multisample anti-aliasing.

Source

pub fn enable_depth(enable: bool)

Enables or disables depth testing.

Source

pub fn enable_alpha(enable: bool)

Enables or disables alpha blending (SRC_ALPHA, ONE_MINUS_SRC_ALPHA).

Source

pub fn enable_cull(enable: bool)

Enables or disables back-face culling.

Source

pub fn set_cull_face(face: Cull)

Sets the front face winding order (clockwise or counter-clockwise).

Source

pub fn set_point_size(size: f32)

Sets the point size (used with PolyMode::Points).

Source

pub fn set_wire_width(width: f32)

Sets the line width (used with PolyMode::WireFrame).

Source

pub fn bind_shader(id: u32)

Binds a shader program (glUseProgram).

Source

pub fn unbind_shader()

Unbinds the current shader program (binds 0).

Source

pub fn bind_texture_at(tex_id: u32, slot: u32)

Binds a 2D texture to the given texture unit slot.

Source

pub fn unbind_texture()

Unbinds the currently bound 2D texture (binds 0).

Source

pub fn bind_vao(id: u32)

Binds a vertex array object.

Source

pub fn unbind_vao()

Unbinds the current VAO (binds 0).

Source

pub fn bind_buffer(id: u32)

Binds an array buffer (GL_ARRAY_BUFFER).

Source

pub fn unbind_buffer()

Unbinds the current array buffer (binds 0).

Source

pub fn bind_ebo(id: u32)

Binds an element array buffer (GL_ELEMENT_ARRAY_BUFFER).

Source

pub fn unbind_ebo()

Unbinds the current element array buffer (binds 0).

Source

pub fn bind_ssbo(id: u32)

Binds a shader storage buffer (GL_SHADER_STORAGE_BUFFER).

Source

pub fn unbind_ssbo()

Unbinds the current SSBO (binds 0).

Auto Trait Implementations§

§

impl Freeze for GL

§

impl RefUnwindSafe for GL

§

impl Send for GL

§

impl Sync for GL

§

impl Unpin for GL

§

impl UnsafeUnpin for GL

§

impl UnwindSafe for GL

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>