summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGL/SoftwareRasterizer.cpp
diff options
context:
space:
mode:
authorJesse Buhagiar <jooster669@gmail.com>2021-05-30 21:39:31 +1000
committerLinus Groh <mail@linusgroh.de>2021-05-31 14:59:47 +0100
commit8298e406a45945bbd894de005b14fac8f936ae3c (patch)
tree5ab76fc0069319f63931035965ae2fca11a7a351 /Userland/Libraries/LibGL/SoftwareRasterizer.cpp
parent573c1c82f7ea47a33f2899a94a4594e55a3121cc (diff)
downloadserenity-8298e406a45945bbd894de005b14fac8f936ae3c.zip
LibGL: Use Texture Units in Rasterizer and Context
The Context and Software Rasterizer now gets the array of texture units instead of a single texture object. _Technically_, we now support some primitive form of multi-texturing, though I'm not entirely sure how well it will work in its current state.
Diffstat (limited to 'Userland/Libraries/LibGL/SoftwareRasterizer.cpp')
-rw-r--r--Userland/Libraries/LibGL/SoftwareRasterizer.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/Userland/Libraries/LibGL/SoftwareRasterizer.cpp b/Userland/Libraries/LibGL/SoftwareRasterizer.cpp
index d9b57f4da4..41f4a48b1b 100644
--- a/Userland/Libraries/LibGL/SoftwareRasterizer.cpp
+++ b/Userland/Libraries/LibGL/SoftwareRasterizer.cpp
@@ -421,13 +421,24 @@ void SoftwareRasterizer::submit_triangle(const GLTriangle& triangle)
});
}
-void SoftwareRasterizer::submit_triangle(const GLTriangle& triangle, const Texture2D& texture)
+void SoftwareRasterizer::submit_triangle(const GLTriangle& triangle, const Array<TextureUnit, 32>& texture_units)
{
- rasterize_triangle(m_options, *m_render_target, *m_depth_buffer, triangle, [&texture](const FloatVector2& uv, const FloatVector4& color) -> FloatVector4 {
+ rasterize_triangle(m_options, *m_render_target, *m_depth_buffer, triangle, [&texture_units](const FloatVector2& uv, const FloatVector4& color) -> FloatVector4 {
// TODO: We'd do some kind of multitexturing/blending here
// Construct a vector for the texel we want to sample
- FloatVector4 texel = texture.sample_texel(uv);
- return texel * color;
+ FloatVector4 texel = color;
+
+ for (const auto& texture_unit : texture_units) {
+
+ // No texture is bound to this texture unit
+ if (!texture_unit.is_bound())
+ continue;
+
+ // FIXME: Don't assume Texture2D, _and_ work out how we blend/do multitexturing properly.....
+ texel = texel * static_ptr_cast<Texture2D>(texture_unit.bound_texture())->sample_texel(uv);
+ }
+
+ return texel;
});
}