Commit graph

14 commits

Author SHA1 Message Date
Jesse Buhagiar
8298e406a4 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.
2021-05-31 14:59:47 +01:00
Stephan Unverwerth
755393e684 LibGL: Implement glBindTexture()
Textures are now initialized with a nullptr upon generation.
They are only actually created once they are bound to a target.
Currently only the GL_TEXTURE_2D target is supported.
The software rasterizer now allows rendering with or without
a bound TEXTURE_2D.
2021-05-30 00:32:37 +01:00
Stephan Unverwerth
fde0045ebe LibGL: Introduce Texture base class for all texture types 2021-05-30 00:32:37 +01:00
Stephan Unverwerth
10ceeb092f Everywhere: Use s.unverwerth@serenityos.org :^) 2021-05-29 12:30:08 +01:00
Jesse Buhagiar
3287709df9 LibGL: Add texture sampling to SW Rasterizer
The software rasterizer now samples a texture passed to us from the
GL context. This is currently a bit of a hack, as we should be
scanning from a list of texture units and checking if they are
enabled. For now, this at least gives some visual confirmation
that texturing is working as it should
2021-05-26 16:36:53 +04:30
Stephan Unverwerth
e54d96d53e LibGL: Implement glReadPixels() 2021-05-24 19:03:25 +01:00
Stephan Unverwerth
2dcafde330 LibGL: Implement alpha testing in SoftwareRasterizer 2021-05-16 19:27:23 +02:00
Stephan Unverwerth
da57563c1c LibGL: Implement glShadeModel()
This turns off interpolation of vertex colors when GL_FLAT is selected.
2021-05-16 15:53:58 +02:00
Stephan Unverwerth
f70a6ff712 LibGL: Implement color blending
This implements different blend modes in the SoftwareRasterizer by
first setting up the blend factors then rendering the pixels into a
temporary buffer and finally mixing the contents of the temporary buffer
with the contents of the backbuffer based on the blend factors.
2021-05-16 00:44:31 +01:00
Stephan Unverwerth
b63b15eeb5 LibGL: SoftwareRasterizer: Use perspective correct interpolation 2021-05-13 08:34:26 +02:00
Stephan Unverwerth
4b55aea307 LibGL: Generate coverage and depth masks in the software rasterizer
This untangles several concepts in the rasterizer and makes it possible
to toggle different stages on a per-block level rather than having to
check whether the feature is enabled for every pixel.
2021-05-13 08:34:26 +02:00
Stephan Unverwerth
f112c594a7 LibGL: Use integer math in rasterizer coverage calculations
This makes the software rasterizer use integers for triangle coverage
calculations. The previously used floating point algorithm was not
precise enough in certain situations and showed gaps between triangles.

This is not yet subpixel accurate.
2021-05-13 08:34:26 +02:00
Stephan Unverwerth
e8f66f821c LibGL: Add depth tests and writes to SoftwareRasterizer
Tests against and writes to the depth buffer when GL_DEPTH_TEST is
enabled via glEnable(). Currently fragment z is always compared against
existing depth with GL_LESS.
2021-05-09 15:58:35 +02:00
Stephan Unverwerth
5ff248649b LibGL: Add software rasterizer
This is based mostly on Fabian "ryg" Giesen's 2011 blog series
"A trip through the Graphics Pipeline" and Scratchapixel's
"Rasterization: a Practical Implementation".

The rasterizer processes triangles in grid aligned 16x16 pixel blocks,
calculates barycentric coordinates and edge derivatives and interpolates
bilinearly across each block.

This will theoretically allow for better utilization of modern processor
features such as SMT and SIMD, as opposed to a classic scanline based
triangle rasterizer.

This serves as a starting point to get something on the screen.
In the future we might look into properly pipelining the main loop to
make the rasterizer more flexible, enabling us to enable/disable
certain features at the block rather than the pixel level.
2021-05-08 10:13:22 +02:00