mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 15:17:46 +00:00
LibSoftGPU: Apply regular cartesian coordinate system
Currently, LibSoftGPU is still OpenGL-minded in that it uses a coordinate system with the origin of `(0, 0)` at the lower-left of textures, buffers and window coordinates. Because we are blitting to a `Gfx::Bitmap` that has the origin at the top-left, we need to flip the Y-coordinates somewhere in the rasterization logic. We used to do this during conversion of NDC-coordinates to window coordinates. This resulted in some incorrect behavior when rasterization did not pass through the vertex transformation logic, e.g. when calling `glDrawPixels`. This changes the coordinate system to OpenGL's throughout, only to blit the final color buffer upside down to the target bitmap. This fixes drawing to the depth buffer directly resulting in upside down images.
This commit is contained in:
parent
3832656464
commit
8c9fa50c61
3 changed files with 21 additions and 31 deletions
|
@ -47,11 +47,13 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void blit_to_bitmap(Gfx::Bitmap& bitmap, Gfx::IntRect const& target) const requires IsSame<T, u32>
|
||||
void blit_flipped_to_bitmap(Gfx::Bitmap& bitmap, Gfx::IntRect const& target) const requires IsSame<T, u32>
|
||||
{
|
||||
VERIFY(bitmap.format() == Gfx::BitmapFormat::BGRA8888 || bitmap.format() == Gfx::BitmapFormat::BGRx8888);
|
||||
int source_y = 0;
|
||||
for (int y = target.top(); y <= target.bottom(); ++y) {
|
||||
|
||||
// NOTE: we are flipping the Y-coordinate here, which is OpenGL-specific: (0, 0) is considered the lower-left corner of the window
|
||||
for (int y = target.bottom(); y >= target.top(); --y) {
|
||||
auto const* buffer_scanline = scanline(source_y++);
|
||||
auto* bitmap_scanline = bitmap.scanline(y);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue