1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:57:44 +00:00

LibGL: Support glLightModel inside lists

We now dereference the pointer given to us before adding the arguments
to an active list. This also factors out the switching logic from the
API wrappers, which helps us with a future commit where we autogenerate
all API wrapper functions.
This commit is contained in:
Jelle Raaijmakers 2022-12-09 16:25:15 +01:00 committed by Andreas Kling
parent 403c560a7a
commit a074b7e871
3 changed files with 30 additions and 19 deletions

View file

@ -171,7 +171,7 @@ void GLContext::gl_light_model(GLenum pname, GLfloat x, GLfloat y, GLfloat z, GL
lighting_params.scene_ambient_color = { x, y, z, w };
break;
case GL_LIGHT_MODEL_COLOR_CONTROL: {
GLenum color_control = static_cast<GLenum>(x);
auto 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) ? GPU::ColorControl::SingleColor : GPU::ColorControl::SeparateSpecularColor;
break;
@ -191,6 +191,30 @@ void GLContext::gl_light_model(GLenum pname, GLfloat x, GLfloat y, GLfloat z, GL
m_rasterizer->set_light_model_params(lighting_params);
}
void GLContext::gl_light_modelv(GLenum pname, void const* params, GLenum type)
{
auto invoke_implementation = [&](auto const* params) {
switch (pname) {
case GL_LIGHT_MODEL_AMBIENT:
gl_light_model(pname, params[0], params[1], params[2], params[3]);
return;
default:
gl_light_model(pname, params[0], 0.f, 0.f, 0.f);
return;
}
};
switch (type) {
case GL_FLOAT:
invoke_implementation(reinterpret_cast<GLfloat const*>(params));
break;
case GL_INT:
invoke_implementation(reinterpret_cast<GLint const*>(params));
break;
default:
VERIFY_NOT_REACHED();
}
}
void GLContext::gl_lightf(GLenum light, GLenum pname, GLfloat param)
{
APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_lightf, light, pname, param);