mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 12:17:35 +00:00
LibGL+LibSoftGPU: Move rendering related code to LibSoftGPU library
This introduces a new library, LibSoftGPU, that incorporates all rendering related features that formerly resided within LibGL itself. Going forward we will make both libraries completely independent from each other allowing LibGL to load different, possibly accelerated, rendering backends.
This commit is contained in:
parent
46b1c2d609
commit
ad3d5d43bd
12 changed files with 58 additions and 45 deletions
44
Userland/Libraries/LibSoftGPU/DepthBuffer.cpp
Normal file
44
Userland/Libraries/LibSoftGPU/DepthBuffer.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Stephan Unverwerth <s.unverwerth@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibSoftGPU/DepthBuffer.h>
|
||||
|
||||
namespace SoftGPU {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
void DepthBuffer::clear(Gfx::IntRect bounds, float depth)
|
||||
{
|
||||
bounds.intersect({ 0, 0, m_size.width(), m_size.height() });
|
||||
for (int y = bounds.top(); y <= bounds.bottom(); ++y)
|
||||
for (int x = bounds.left(); x <= bounds.right(); ++x)
|
||||
m_data[y * m_size.width() + x] = depth;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue