mirror of
https://github.com/RGBCube/serenity
synced 2025-05-15 21:14:59 +00:00

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.
36 lines
697 B
C++
36 lines
697 B
C++
/*
|
|
* Copyright (c) 2021, Jesse Buhagiar <jooster669@gmail.com>
|
|
* Copyright (c) 2021, Stephan Unverwerth <s.unverwerth@gmx.de>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include "SoftwareGLContext.h"
|
|
#include <LibGfx/Bitmap.h>
|
|
|
|
__attribute__((visibility("hidden"))) GL::GLContext* g_gl_context;
|
|
|
|
namespace GL {
|
|
|
|
GLContext::~GLContext()
|
|
{
|
|
if (g_gl_context == this)
|
|
make_context_current(nullptr);
|
|
}
|
|
|
|
OwnPtr<GLContext> create_context(Gfx::Bitmap& bitmap)
|
|
{
|
|
auto context = adopt_own(*new SoftwareGLContext(bitmap));
|
|
|
|
if (!g_gl_context)
|
|
g_gl_context = context;
|
|
|
|
return context;
|
|
}
|
|
|
|
void make_context_current(GLContext* context)
|
|
{
|
|
g_gl_context = context;
|
|
}
|
|
|
|
}
|