summaryrefslogtreecommitdiff
path: root/engine/src/renderer/opengl.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/renderer/opengl.rs
parentedb5eb812bb6a3e7ed26526fab24b110be3828d4 (diff)
feat(engine): add ability to change polygon mode per object
Diffstat (limited to 'engine/src/renderer/opengl.rs')
-rw-r--r--engine/src/renderer/opengl.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/engine/src/renderer/opengl.rs b/engine/src/renderer/opengl.rs
index 35f4938..108c504 100644
--- a/engine/src/renderer/opengl.rs
+++ b/engine/src/renderer/opengl.rs
@@ -14,6 +14,7 @@ use ecs::{Component, Query};
use crate::camera::Camera;
use crate::color::Color;
use crate::data_types::dimens::Dimens;
+use crate::draw_flags::{DrawFlags, PolygonModeConfig};
use crate::event::{Present as PresentEvent, Start as StartEvent};
use crate::lighting::{DirectionalLight, GlobalLight, PointLight};
use crate::material::{Flags as MaterialFlags, Material};
@@ -102,6 +103,7 @@ fn render(
Option<MaterialFlags>,
Option<Position>,
Option<Scale>,
+ Option<DrawFlags>,
)>,
point_light_query: Query<(PointLight,)>,
directional_lights: Query<(DirectionalLight,)>,
@@ -137,7 +139,9 @@ fn render(
clear_buffers(BufferClearMask::COLOR | BufferClearMask::DEPTH);
- for (mesh, shader_program, material, material_flags, position, scale) in &query {
+ for (mesh, shader_program, material, material_flags, position, scale, draw_flags) in
+ &query
+ {
let material_flags = material_flags
.map(|material_flags| material_flags.clone())
.unwrap_or_default();
@@ -187,7 +191,23 @@ fn render(
shader_program.activate();
+ if let Some(draw_flags) = &draw_flags {
+ crate::opengl::set_polygon_mode(
+ draw_flags.polygon_mode_config.face,
+ draw_flags.polygon_mode_config.mode,
+ )
+ }
+
draw_mesh(&mesh);
+
+ if draw_flags.is_some() {
+ let default_polygon_mode_config = PolygonModeConfig::default();
+
+ crate::opengl::set_polygon_mode(
+ default_polygon_mode_config.face,
+ default_polygon_mode_config.mode,
+ )
+ }
}
}