pub struct Object {
pub transform: Transform,
pub shader_program: ShaderProgram,
/* private fields */
}Expand description
Represents an object in a 3D scene.
Fields§
§transform: TransformThe transformation matrix of the object.
shader_program: ShaderProgramThe shader program used to render the object.
Implementations§
Source§impl Object
impl Object
Sourcepub fn new(mesh: Vao, shader_program: ShaderProgram) -> Self
pub fn new(mesh: Vao, shader_program: ShaderProgram) -> Self
Creates a new object with the specified mesh and shader program.
§Arguments
mesh- The mesh of the object, represented as a VAO.shader_program- The shader program used to render the object.
§Returns
A new Object instance with the given mesh and shader program,
and an identity transformation matrix.
Sourcepub fn render(
&mut self,
view_matrix: Matrix4<f32>,
projection_matrix: Matrix4<f32>,
)
pub fn render( &mut self, view_matrix: Matrix4<f32>, projection_matrix: Matrix4<f32>, )
Renders the object using the given view and projection matrices.
§Arguments
view_matrix- The view matrix to use for rendering.projection_matrix- The projection matrix to use for rendering.
This function binds the object’s shader program and sets the “model”, “view”, and
“projection” uniforms to the object’s transformation matrix, the given view matrix,
and the given projection matrix, respectively. It then binds the object’s mesh and
renders it using the gl::DrawElements function with the gl::TRIANGLES primitive type.
Auto Trait Implementations§
impl Freeze for Object
impl RefUnwindSafe for Object
impl Send for Object
impl Sync for Object
impl Unpin for Object
impl UnsafeUnpin for Object
impl UnwindSafe for Object
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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