summaryrefslogtreecommitdiff
path: root/engine/src/opengl/mod.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-06-22 14:00:27 +0200
committerHampusM <hampus@hampusmat.com>2024-06-22 14:00:27 +0200
commita0dce2164cf348416ea15c63c5baa52afa66508f (patch)
tree9cc86afee8ddb615cf2738636bc67f408f4fbafc /engine/src/opengl/mod.rs
parentedb5eb812bb6a3e7ed26526fab24b110be3828d4 (diff)
feat(engine): add ability to change polygon mode per object
Diffstat (limited to 'engine/src/opengl/mod.rs')
-rw-r--r--engine/src/opengl/mod.rs49
1 files changed, 49 insertions, 0 deletions
diff --git a/engine/src/opengl/mod.rs b/engine/src/opengl/mod.rs
index 40f0c58..0b1bb8a 100644
--- a/engine/src/opengl/mod.rs
+++ b/engine/src/opengl/mod.rs
@@ -33,6 +33,13 @@ pub fn clear_buffers(mask: BufferClearMask)
}
}
+pub fn set_polygon_mode(face: impl Into<PolygonModeFace>, mode: impl Into<PolygonMode>)
+{
+ unsafe {
+ gl::PolygonMode(face.into() as u32, mode.into() as u32);
+ }
+}
+
pub fn enable(capacity: Capability)
{
unsafe {
@@ -56,3 +63,45 @@ pub enum Capability
DepthTest = gl::DEPTH_TEST,
MultiSample = gl::MULTISAMPLE,
}
+
+#[derive(Debug)]
+#[repr(u32)]
+pub enum PolygonMode
+{
+ Point = gl::POINT,
+ Line = gl::LINE,
+ Fill = gl::FILL,
+}
+
+impl From<crate::draw_flags::PolygonMode> for PolygonMode
+{
+ fn from(mode: crate::draw_flags::PolygonMode) -> Self
+ {
+ match mode {
+ crate::draw_flags::PolygonMode::Point => Self::Point,
+ crate::draw_flags::PolygonMode::Fill => Self::Fill,
+ crate::draw_flags::PolygonMode::Line => Self::Line,
+ }
+ }
+}
+
+#[derive(Debug)]
+#[repr(u32)]
+pub enum PolygonModeFace
+{
+ Front = gl::FRONT,
+ Back = gl::BACK,
+ FrontAndBack = gl::FRONT_AND_BACK,
+}
+
+impl From<crate::draw_flags::PolygonModeFace> for PolygonModeFace
+{
+ fn from(face: crate::draw_flags::PolygonModeFace) -> Self
+ {
+ match face {
+ crate::draw_flags::PolygonModeFace::Front => Self::Front,
+ crate::draw_flags::PolygonModeFace::Back => Self::Back,
+ crate::draw_flags::PolygonModeFace::FrontAndBack => Self::FrontAndBack,
+ }
+ }
+}