mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:07:34 +00: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
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_LOCAL_VIEWER 0x0B51
|
||||||
#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52
|
#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52
|
||||||
#define GL_LIGHT_MODEL_AMBIENT 0x0B53
|
#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_FLAT 0x1D00
|
||||||
#define GL_SMOOTH 0x1D01
|
#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);
|
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
|
RETURN_WITH_ERROR_IF(pname != GL_LIGHT_MODEL_AMBIENT
|
||||||
&& pname != GL_LIGHT_MODEL_TWO_SIDE
|
&& pname != GL_LIGHT_MODEL_COLOR_CONTROL
|
||||||
&& pname != GL_LIGHT_MODEL_AMBIENT,
|
&& pname != GL_LIGHT_MODEL_LOCAL_VIEWER
|
||||||
|
&& pname != GL_LIGHT_MODEL_TWO_SIDE,
|
||||||
GL_INVALID_ENUM);
|
GL_INVALID_ENUM);
|
||||||
|
|
||||||
auto lighting_params = m_rasterizer.light_model();
|
auto lighting_params = m_rasterizer.light_model();
|
||||||
bool update_lighting_model = false;
|
|
||||||
|
|
||||||
switch (pname) {
|
switch (pname) {
|
||||||
case GL_LIGHT_MODEL_AMBIENT:
|
case GL_LIGHT_MODEL_AMBIENT:
|
||||||
lighting_params.scene_ambient_color = { x, y, z, w };
|
lighting_params.scene_ambient_color = { x, y, z, w };
|
||||||
update_lighting_model = true;
|
|
||||||
break;
|
break;
|
||||||
case GL_LIGHT_MODEL_TWO_SIDE:
|
case GL_LIGHT_MODEL_COLOR_CONTROL: {
|
||||||
VERIFY(y == 0.0f && z == 0.0f && w == 0.0f);
|
GLenum color_control = static_cast<GLenum>(x);
|
||||||
lighting_params.two_sided_lighting = x;
|
RETURN_WITH_ERROR_IF(color_control != GL_SINGLE_COLOR && color_control != GL_SEPARATE_SPECULAR_COLOR, GL_INVALID_ENUM);
|
||||||
update_lighting_model = true;
|
lighting_params.color_control = (color_control == GL_SINGLE_COLOR) ? SoftGPU::ColorControl::SingleColor : SoftGPU::ColorControl::SeparateSpecularColor;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case GL_LIGHT_MODEL_LOCAL_VIEWER:
|
case GL_LIGHT_MODEL_LOCAL_VIEWER:
|
||||||
// 0 means the viewer is at infinity
|
// 0 means the viewer is at infinity
|
||||||
// 1 means they're in local (eye) space
|
// 1 means they're in local (eye) space
|
||||||
lighting_params.viewer_at_infinity = (x != 1.0f);
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
VERIFY_NOT_REACHED();
|
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)
|
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.
|
// 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)
|
// 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;
|
(void)m_lighting_model.two_sided_lighting;
|
||||||
|
|
|
@ -83,7 +83,7 @@ struct RasterizerOptions {
|
||||||
struct LightModelParameters {
|
struct LightModelParameters {
|
||||||
FloatVector4 scene_ambient_color { 0.2f, 0.2f, 0.2f, 1.0f };
|
FloatVector4 scene_ambient_color { 0.2f, 0.2f, 0.2f, 1.0f };
|
||||||
bool viewer_at_infinity { false };
|
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 };
|
bool two_sided_lighting { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,11 @@ enum class BlendFactor {
|
||||||
SrcAlphaSaturate,
|
SrcAlphaSaturate,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class ColorControl {
|
||||||
|
SingleColor,
|
||||||
|
SeparateSpecularColor,
|
||||||
|
};
|
||||||
|
|
||||||
enum class ColorMaterialFace {
|
enum class ColorMaterialFace {
|
||||||
Front,
|
Front,
|
||||||
Back,
|
Back,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue