summaryrefslogtreecommitdiff
path: root/engine/src/renderer/mod.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-11-02 20:22:33 +0100
committerHampusM <hampus@hampusmat.com>2023-11-02 20:22:33 +0100
commit9aafb51e0be1720019db1c3d0a294ce9a42653df (patch)
tree40881ff26bff5a928280223d8aced87e1370d63b /engine/src/renderer/mod.rs
parentf2c54d47e6b61198520824117339aaa21c32accd (diff)
feat(engine): add texturing
Diffstat (limited to 'engine/src/renderer/mod.rs')
-rw-r--r--engine/src/renderer/mod.rs44
1 files changed, 27 insertions, 17 deletions
diff --git a/engine/src/renderer/mod.rs b/engine/src/renderer/mod.rs
index 6c56964..3691f76 100644
--- a/engine/src/renderer/mod.rs
+++ b/engine/src/renderer/mod.rs
@@ -116,23 +116,33 @@ pub fn render<'obj>(
apply_transformation_matrices(obj, camera, window_size);
- obj.renderable().vertex_arr.bind(|vert_arr_curr_bound| {
- if let Some(index_info) = &obj.renderable().index_info {
- VertexArray::draw_elements(
- &vert_arr_curr_bound,
- PrimitiveKind::Triangles,
- 0,
- index_info.cnt,
- );
- } else {
- VertexArray::draw_arrays(
- &vert_arr_curr_bound,
- PrimitiveKind::Triangles,
- 0,
- 3,
- );
- }
- });
+ let draw = || {
+ obj.renderable().vertex_arr.bind(|vert_arr_curr_bound| {
+ if let Some(index_info) = &obj.renderable().index_info {
+ VertexArray::draw_elements(
+ &vert_arr_curr_bound,
+ PrimitiveKind::Triangles,
+ 0,
+ index_info.cnt,
+ );
+ } else {
+ VertexArray::draw_arrays(
+ &vert_arr_curr_bound,
+ PrimitiveKind::Triangles,
+ 0,
+ 3,
+ );
+ }
+ });
+ };
+
+ if let Some(texture) = obj.texture() {
+ texture.inner().bind(|_| {
+ draw();
+ });
+ } else {
+ draw();
+ }
}
}