mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
LibGL+LibSoftGPU: Implement more of GL_LIGHT_MODEL_COLOR_CONTROL
This gets rid of a place where OpenGL was leaking into LibSoftGPU.
This commit is contained in:
parent
4b6b9f272f
commit
284a629ab4
Notes:
sideshowbarker
2024-07-17 16:40:30 +09:00
Author: https://github.com/gmta
Commit: 284a629ab4
Pull-request: https://github.com/SerenityOS/serenity/pull/13209
Reviewed-by: https://github.com/Quaker762 ✅
Reviewed-by: https://github.com/sunverwerth ✅
5 changed files with 24 additions and 14 deletions
|
@ -263,6 +263,9 @@ extern "C" {
|
|||
#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51
|
||||
#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52
|
||||
#define GL_LIGHT_MODEL_AMBIENT 0x0B53
|
||||
#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8
|
||||
#define GL_SINGLE_COLOR 0x81F9
|
||||
#define GL_SEPARATE_SPECULAR_COLOR 0x81FA
|
||||
|
||||
#define GL_FLAT 0x1D00
|
||||
#define GL_SMOOTH 0x1D01
|
||||
|
|
|
@ -2724,36 +2724,38 @@ void GLContext::gl_light_model(GLenum pname, GLfloat x, GLfloat y, GLfloat z, GL
|
|||
{
|
||||
APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_light_model, pname, x, y, z, w);
|
||||
|
||||
RETURN_WITH_ERROR_IF(pname != GL_LIGHT_MODEL_LOCAL_VIEWER
|
||||
&& pname != GL_LIGHT_MODEL_TWO_SIDE
|
||||
&& pname != GL_LIGHT_MODEL_AMBIENT,
|
||||
RETURN_WITH_ERROR_IF(pname != GL_LIGHT_MODEL_AMBIENT
|
||||
&& pname != GL_LIGHT_MODEL_COLOR_CONTROL
|
||||
&& pname != GL_LIGHT_MODEL_LOCAL_VIEWER
|
||||
&& pname != GL_LIGHT_MODEL_TWO_SIDE,
|
||||
GL_INVALID_ENUM);
|
||||
|
||||
auto lighting_params = m_rasterizer.light_model();
|
||||
bool update_lighting_model = false;
|
||||
|
||||
switch (pname) {
|
||||
case GL_LIGHT_MODEL_AMBIENT:
|
||||
lighting_params.scene_ambient_color = { x, y, z, w };
|
||||
update_lighting_model = true;
|
||||
break;
|
||||
case GL_LIGHT_MODEL_TWO_SIDE:
|
||||
VERIFY(y == 0.0f && z == 0.0f && w == 0.0f);
|
||||
lighting_params.two_sided_lighting = x;
|
||||
update_lighting_model = true;
|
||||
case GL_LIGHT_MODEL_COLOR_CONTROL: {
|
||||
GLenum color_control = static_cast<GLenum>(x);
|
||||
RETURN_WITH_ERROR_IF(color_control != GL_SINGLE_COLOR && color_control != GL_SEPARATE_SPECULAR_COLOR, GL_INVALID_ENUM);
|
||||
lighting_params.color_control = (color_control == GL_SINGLE_COLOR) ? SoftGPU::ColorControl::SingleColor : SoftGPU::ColorControl::SeparateSpecularColor;
|
||||
break;
|
||||
}
|
||||
case GL_LIGHT_MODEL_LOCAL_VIEWER:
|
||||
// 0 means the viewer is at infinity
|
||||
// 1 means they're in local (eye) space
|
||||
lighting_params.viewer_at_infinity = (x != 1.0f);
|
||||
update_lighting_model = true;
|
||||
break;
|
||||
case GL_LIGHT_MODEL_TWO_SIDE:
|
||||
VERIFY(y == 0.0f && z == 0.0f && w == 0.0f);
|
||||
lighting_params.two_sided_lighting = x;
|
||||
break;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
if (update_lighting_model)
|
||||
m_rasterizer.set_light_model_params(lighting_params);
|
||||
m_rasterizer.set_light_model_params(lighting_params);
|
||||
}
|
||||
|
||||
void GLContext::gl_bitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, GLubyte const* bitmap)
|
||||
|
|
|
@ -813,7 +813,7 @@ void Device::draw_primitives(PrimitiveType primitive_type, FloatMatrix4x4 const&
|
|||
}
|
||||
|
||||
// FIXME: The spec allows for splitting the colors calculated here into multiple different colors (primary/secondary color). Investigate what this means.
|
||||
(void)m_lighting_model.single_color;
|
||||
(void)m_lighting_model.color_control;
|
||||
|
||||
// FIXME: Two sided lighting should be implemented eventually (I believe this is where the normals are -ve and then lighting is calculated with the BACK material)
|
||||
(void)m_lighting_model.two_sided_lighting;
|
||||
|
|
|
@ -83,7 +83,7 @@ struct RasterizerOptions {
|
|||
struct LightModelParameters {
|
||||
FloatVector4 scene_ambient_color { 0.2f, 0.2f, 0.2f, 1.0f };
|
||||
bool viewer_at_infinity { false };
|
||||
unsigned int single_color { 0x81F9 }; // This is the value of `GL_SINGLE_COLOR`. Considering we definitely don't leak gl.h stuff into here, we fix it to the gl.h macro value.
|
||||
ColorControl color_control { ColorControl::SingleColor };
|
||||
bool two_sided_lighting { false };
|
||||
};
|
||||
|
||||
|
|
|
@ -39,6 +39,11 @@ enum class BlendFactor {
|
|||
SrcAlphaSaturate,
|
||||
};
|
||||
|
||||
enum class ColorControl {
|
||||
SingleColor,
|
||||
SeparateSpecularColor,
|
||||
};
|
||||
|
||||
enum class ColorMaterialFace {
|
||||
Front,
|
||||
Back,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue