summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGL/SoftwareGLContext.h
diff options
context:
space:
mode:
authorStephan Unverwerth <s.unverwerth@gmx.de>2021-04-24 01:57:01 +0200
committerAndreas Kling <kling@serenityos.org>2021-05-08 10:13:22 +0200
commit5ff248649bc171fe360e7c188aaab62c21f89639 (patch)
treece16d9729a065e484cfb718cb943510dfbd4b6ea /Userland/Libraries/LibGL/SoftwareGLContext.h
parente6c060049945ca34b7a46917a6674486deebf56e (diff)
downloadserenity-5ff248649bc171fe360e7c188aaab62c21f89639.zip
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.
Diffstat (limited to 'Userland/Libraries/LibGL/SoftwareGLContext.h')
-rw-r--r--Userland/Libraries/LibGL/SoftwareGLContext.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.h b/Userland/Libraries/LibGL/SoftwareGLContext.h
index c245cff5b4..38eef4573c 100644
--- a/Userland/Libraries/LibGL/SoftwareGLContext.h
+++ b/Userland/Libraries/LibGL/SoftwareGLContext.h
@@ -8,7 +8,10 @@
#include "GLContext.h"
#include "GLStruct.h"
+#include "SoftwareRasterizer.h"
+#include <AK/RefPtr.h>
#include <AK/Vector.h>
+#include <LibGfx/Bitmap.h>
#include <LibGfx/Matrix4x4.h>
#include <LibGfx/Vector3.h>
@@ -16,6 +19,8 @@ namespace GL {
class SoftwareGLContext : public GLContext {
public:
+ SoftwareGLContext(Gfx::Bitmap&);
+
virtual void gl_begin(GLenum mode) override;
virtual void gl_clear(GLbitfield mask) override;
virtual void gl_clear_color(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) override;
@@ -40,6 +45,8 @@ public:
virtual void gl_front_face(GLenum) override;
virtual void gl_cull_face(GLenum) override;
+ virtual void present() override;
+
private:
GLenum m_current_draw_mode;
GLenum m_current_matrix_mode;
@@ -64,6 +71,10 @@ private:
bool m_cull_faces = false;
GLenum m_front_face = GL_CCW;
GLenum m_culled_sides = GL_BACK;
+
+ NonnullRefPtr<Gfx::Bitmap> m_frontbuffer;
+
+ SoftwareRasterizer m_rasterizer;
};
}