summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/src/opengl/mod.rs14
-rw-r--r--engine/src/renderer/mod.rs6
2 files changed, 18 insertions, 2 deletions
diff --git a/engine/src/opengl/mod.rs b/engine/src/opengl/mod.rs
index 6f95a1f..4f4f96f 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 enable(capacity: Capability)
+{
+ unsafe {
+ gl::Enable(capacity as u32);
+ }
+}
+
bitflags! {
#[derive(Debug, Clone, Copy)]
pub struct BufferClearMask: u32 {
@@ -41,3 +48,10 @@ bitflags! {
const STENCIL = gl::STENCIL_BUFFER_BIT;
}
}
+
+#[derive(Debug)]
+#[repr(u32)]
+pub enum Capability
+{
+ DepthTest = gl::DEPTH_TEST,
+}
diff --git a/engine/src/renderer/mod.rs b/engine/src/renderer/mod.rs
index aa828fe..4dcc075 100644
--- a/engine/src/renderer/mod.rs
+++ b/engine/src/renderer/mod.rs
@@ -16,7 +16,7 @@ use crate::opengl::buffer::{
use crate::opengl::debug::{MessageSeverity, MessageSource, MessageType};
use crate::opengl::shader::Program as ShaderProgram;
use crate::opengl::vertex_array::{PrimitiveKind, VertexArray};
-use crate::opengl::{clear_buffers, BufferClearMask};
+use crate::opengl::{clear_buffers, enable, BufferClearMask, Capability};
use crate::projection::new_perspective;
use crate::vector::Vec2;
use crate::vertex::Vertex;
@@ -59,6 +59,8 @@ pub fn initialize(window: &glfw::Window) -> Result<(), Error>
set_viewport(&Vec2 { x: 0, y: 0 }, &window_size);
+ enable(Capability::DepthTest);
+
Ok(())
}
@@ -107,7 +109,7 @@ pub fn render<'obj>(
camera: &Camera,
)
{
- clear_buffers(BufferClearMask::COLOR);
+ clear_buffers(BufferClearMask::COLOR | BufferClearMask::DEPTH);
for obj in objects {
obj.renderable().shader_program.activate();