diff options
author | Stephan Unverwerth <s.unverwerth@gmx.de> | 2021-05-08 22:18:34 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-09 15:58:35 +0200 |
commit | 608f81e6c2220fe2dc01c8c903ccc3706243dcd3 (patch) | |
tree | a19525f901c46cb404a7dfa6e315e8ab92576c27 /Userland/Libraries/LibGL/DepthBuffer.cpp | |
parent | a8fc4be47abf93a1e3cf1c190b50ad3d3444907e (diff) | |
download | serenity-608f81e6c2220fe2dc01c8c903ccc3706243dcd3.zip |
LibGL: Add depth buffer class
Diffstat (limited to 'Userland/Libraries/LibGL/DepthBuffer.cpp')
-rw-r--r-- | Userland/Libraries/LibGL/DepthBuffer.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGL/DepthBuffer.cpp b/Userland/Libraries/LibGL/DepthBuffer.cpp new file mode 100644 index 0000000000..431b043354 --- /dev/null +++ b/Userland/Libraries/LibGL/DepthBuffer.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021, Stephan Unverwerth <s.unverwerth@gmx.de> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include "DepthBuffer.h" + +namespace GL { + +DepthBuffer::DepthBuffer(Gfx::IntSize const& size) + : m_size(size) + , m_data(new float[size.width() * size.height()]) +{ +} + +DepthBuffer::~DepthBuffer() +{ + delete[] m_data; +} + +float* DepthBuffer::scanline(int y) +{ + VERIFY(y >= 0 && y < m_size.height()); + return &m_data[y * m_size.width()]; +} + +void DepthBuffer::clear(float depth) +{ + int num_entries = m_size.width() * m_size.height(); + for (int i = 0; i < num_entries; ++i) { + m_data[i] = depth; + } +} + +} |