Skip to content

Commit

Permalink
make it work
Browse files Browse the repository at this point in the history
  • Loading branch information
mkovaxx committed Mar 9, 2023
1 parent 93bcd2d commit 6a40b08
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
3 changes: 2 additions & 1 deletion examples/custom_material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ extern crate nalgebra as na;
use kiss3d::camera::Camera;
use kiss3d::context::Context;
use kiss3d::light::Light;
use kiss3d::resource::vertex_index::VERTEX_INDEX_TYPE;
use kiss3d::resource::{Effect, Material, Mesh, ShaderAttribute, ShaderUniform};
use kiss3d::scene::ObjectData;
use kiss3d::window::Window;
Expand Down Expand Up @@ -97,7 +98,7 @@ impl Material for NormalMaterial {
Context::get().draw_elements(
Context::TRIANGLES,
mesh.num_pts() as i32,
Context::UNSIGNED_SHORT,
VERTEX_INDEX_TYPE,
0,
);

Expand Down
11 changes: 6 additions & 5 deletions src/builtin/object_material.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::camera::Camera;
use crate::context::Context;
use crate::light::Light;
use crate::resource::vertex_index::VERTEX_INDEX_TYPE;
use crate::resource::Material;
use crate::resource::{Effect, Mesh, ShaderAttribute, ShaderUniform};
use crate::scene::ObjectData;
Expand Down Expand Up @@ -122,7 +123,7 @@ impl Material for ObjectMaterial {
verify!(ctxt.draw_elements(
Context::TRIANGLES,
mesh.num_pts() as i32,
Context::UNSIGNED_SHORT,
VERTEX_INDEX_TYPE,
0
));
}
Expand All @@ -138,15 +139,15 @@ impl Material for ObjectMaterial {
verify!(ctxt.draw_elements(
Context::TRIANGLES,
mesh.num_pts() as i32,
Context::UNSIGNED_SHORT,
VERTEX_INDEX_TYPE,
0
));
} else {
mesh.bind_edges();
verify!(ctxt.draw_elements(
Context::LINES,
mesh.num_pts() as i32 * 2,
Context::UNSIGNED_SHORT,
VERTEX_INDEX_TYPE,
0
));
}
Expand All @@ -162,14 +163,14 @@ impl Material for ObjectMaterial {
verify!(ctxt.draw_elements(
Context::TRIANGLES,
mesh.num_pts() as i32,
Context::UNSIGNED_SHORT,
VERTEX_INDEX_TYPE,
0
));
} else {
verify!(ctxt.draw_elements(
Context::POINTS,
mesh.num_pts() as i32,
Context::UNSIGNED_SHORT,
VERTEX_INDEX_TYPE,
0
));
}
Expand Down
11 changes: 6 additions & 5 deletions src/builtin/planar_object_material.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::context::Context;
use crate::planar_camera::PlanarCamera;
use crate::resource::vertex_index::VERTEX_INDEX_TYPE;
use crate::resource::PlanarMaterial;
use crate::resource::{Effect, PlanarMesh, ShaderAttribute, ShaderUniform};
use crate::scene::PlanarObjectData;
Expand Down Expand Up @@ -97,7 +98,7 @@ impl PlanarMaterial for PlanarObjectMaterial {
verify!(ctxt.draw_elements(
Context::TRIANGLES,
mesh.num_pts() as i32,
Context::UNSIGNED_SHORT,
VERTEX_INDEX_TYPE,
0
));
}
Expand All @@ -113,15 +114,15 @@ impl PlanarMaterial for PlanarObjectMaterial {
verify!(ctxt.draw_elements(
Context::TRIANGLES,
mesh.num_pts() as i32,
Context::UNSIGNED_SHORT,
VERTEX_INDEX_TYPE,
0
));
} else {
mesh.bind_edges();
verify!(ctxt.draw_elements(
Context::LINES,
mesh.num_pts() as i32 * 2,
Context::UNSIGNED_SHORT,
VERTEX_INDEX_TYPE,
0
));
}
Expand All @@ -138,14 +139,14 @@ impl PlanarMaterial for PlanarObjectMaterial {
verify!(ctxt.draw_elements(
Context::TRIANGLES,
mesh.num_pts() as i32,
Context::UNSIGNED_SHORT,
VERTEX_INDEX_TYPE,
0
));
} else {
verify!(ctxt.draw_elements(
Context::POINTS,
mesh.num_pts() as i32,
Context::UNSIGNED_SHORT,
VERTEX_INDEX_TYPE,
0
));
}
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/conrod_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub struct ConrodRenderer {
image_uvs: ShaderAttribute<Point2<f32>>,
image_texture: ShaderUniform<i32>,
points: GPUVec<f32>,
indices: GPUVec<Point3<u16>>,
indices: GPUVec<Point3<VertexIndex>>,
cache: GlyphCache<'static>,
texture: Texture,
resized_once: bool,
Expand Down Expand Up @@ -270,7 +270,7 @@ impl ConrodRenderer {
verify!(ctxt.draw_elements(
Context::TRIANGLES,
self.indices.len() as i32 * 3,
Context::UNSIGNED_SHORT,
VERTEX_INDEX_TYPE,
0
));

Expand Down
7 changes: 7 additions & 0 deletions src/resource/vertex_index.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
use crate::context::Context;

#[cfg(not(feature = "vertex_index_u32"))]
pub type VertexIndex = u16;
#[cfg(feature = "vertex_index_u32")]
pub type VertexIndex = u32;

#[cfg(not(feature = "vertex_index_u32"))]
pub const VERTEX_INDEX_TYPE: u32 = Context::UNSIGNED_SHORT;
#[cfg(feature = "vertex_index_u32")]
pub const VERTEX_INDEX_TYPE: u32 = Context::UNSIGNED_INT;

0 comments on commit 6a40b08

Please sign in to comment.