pub(crate) struct Binder {
pub(crate) vbo: u32,
pub(crate) vao: u32,
pub(crate) ebo: u32,
pub(crate) texture: u32,
}
Expand description
General Information
Variables asocciated with GPU and drawable object(s). Assigned by OpenGL. Should always be mutable.
Fields
vbo
(Vertex Buffer Object) - Vertices Generated by Mesh.vao
(Vertex Array Object) - Binds vertices and it’s configuration with OpenGL.ebo
(Element Buffer Object) - Indices to draw vertices.texture
- Texture in 2D to use over object to draw.
Fields§
§vbo: u32
§vao: u32
§ebo: u32
§texture: u32
Implementations§
source§impl Binder
impl Binder
sourcepub(crate) fn setup(&mut self)
pub(crate) fn setup(&mut self)
General Information
sets up binder’s variables with GPU. Should always be used after instance of window has set up OpenGL context. Never binds texture.
Parameters
&mut self
- OpenGL changes the values of instance fields effectively setting up linkage beetween vao and vbo and ebo. Texture has to be set up later since not all drawings have it.
sourcepub(crate) fn bind_vao(&self)
pub(crate) fn bind_vao(&self)
General Information
Binds binder’s vao to use.
Parameters
&self
- Instance does not need to be mutable since it’s already setup.
sourcepub(crate) fn bind_vbo(&self)
pub(crate) fn bind_vbo(&self)
General Information
Binds binder’s vbo to use.
Parameters
&self
- Instance does not need to be mutable since it’s already setup.
sourcepub(crate) fn bind_ebo(&self)
pub(crate) fn bind_ebo(&self)
General Information
Binds binder’s ebo to use.
Parameters
&self
- Instance does not need to be mutable since it’s already setup.
sourcepub(crate) fn bind_all_no_texture(&self)
pub(crate) fn bind_all_no_texture(&self)
General Information
Binds vao, ebo and vbo. Never binds texture.
Parameters
&self
- Instance does not need to be mutable since it’s already setup.
sourcepub(crate) fn setup_texture(&mut self)
pub(crate) fn setup_texture(&mut self)
General Information
Binds a 2D texture providing a standar way to scale up and down (mipmap), and enabling blending so that alpha channel is respected. When enabling blending, it’s necessary to change how it occurs: If alpha channel is to be respected, the incoming pixels have to be alpha transparent, while the pixes already present have to be (1-alpha) transparent.
Parameters
&mut self
- OpenGL changes values of instance field texture effectively linking current texture to use.
sourcepub(crate) fn bind_texture(&self)
pub(crate) fn bind_texture(&self)
General Information
Binds binder’s texture to use.
Parameters
&self
- Instance does not need to be mutable since it’s already setup.
sourcepub(crate) fn unbind_texture(&self)
pub(crate) fn unbind_texture(&self)
General information
Unbind texture when needed. Since not all objects posess a texture, this has to be done sometimes.
sourcepub(crate) fn bind_all(&self)
pub(crate) fn bind_all(&self)
General Information
Binds vao, ebo, vbo and texture.
Parameters
&self
- Instance does not need to be mutable since it’s already setup.