LibGL: Add support for GL_BLEND in glEnable() and glDisable()

This commit is contained in:
Stephan Unverwerth 2021-05-15 22:55:40 +02:00 committed by Linus Groh
parent 279737642c
commit d6e9b433cf
Notes: sideshowbarker 2024-07-18 18:03:44 +09:00
4 changed files with 22 additions and 1 deletions

View File

@ -36,6 +36,7 @@ extern "C" {
// Enable capabilities
#define GL_CULL_FACE 0x0B44
#define GL_DEPTH_TEST 0x0B71
#define GL_BLEND 0x0BE2
// Utility
#define GL_VENDOR 0x1F00

View File

@ -683,6 +683,11 @@ void SoftwareGLContext::gl_enable(GLenum capability)
rasterizer_options.enable_depth_test = true;
update_rasterizer_options = true;
break;
case GL_BLEND:
m_blend_enabled = true;
rasterizer_options.enable_blending = true;
update_rasterizer_options = true;
break;
default:
m_error = GL_INVALID_ENUM;
break;
@ -713,6 +718,11 @@ void SoftwareGLContext::gl_disable(GLenum capability)
rasterizer_options.enable_depth_test = false;
update_rasterizer_options = true;
break;
case GL_BLEND:
m_blend_enabled = false;
rasterizer_options.enable_blending = false;
update_rasterizer_options = false;
break;
default:
m_error = GL_INVALID_ENUM;
break;
@ -908,6 +918,11 @@ void SoftwareGLContext::gl_blend_func(GLenum src_factor, GLenum dst_factor)
m_blend_source_factor = src_factor;
m_blend_destination_factor = dst_factor;
auto options = m_rasterizer.options();
options.blend_source_factor = m_blend_source_factor;
options.blend_destination_factor = m_blend_destination_factor;
m_rasterizer.set_options(options);
}
void SoftwareGLContext::present()

View File

@ -106,6 +106,7 @@ private:
GLenum m_front_face = GL_CCW;
GLenum m_culled_sides = GL_BACK;
bool m_blend_enabled = false;
GLenum m_blend_source_factor = GL_ONE;
GLenum m_blend_destination_factor = GL_ZERO;

View File

@ -7,6 +7,7 @@
#pragma once
#include "DepthBuffer.h"
#include "GL/gl.h"
#include "GLStruct.h"
#include <AK/OwnPtr.h>
#include <LibGfx/Bitmap.h>
@ -15,8 +16,11 @@
namespace GL {
struct RasterizerOptions {
bool shade_smooth { false };
bool shade_smooth { true };
bool enable_depth_test { false };
bool enable_blending { false };
GLenum blend_source_factor { GL_ONE };
GLenum blend_destination_factor { GL_ONE };
};
class SoftwareRasterizer final {