mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
LibGL: Implement glLightModelf
and glLightModelfv
This commit is contained in:
parent
0453cad46c
commit
c2960e68a8
5 changed files with 49 additions and 1 deletions
|
@ -169,6 +169,9 @@ extern "C" {
|
|||
#define GL_RGBA 0x1908
|
||||
|
||||
// Lighting related defines
|
||||
#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52
|
||||
#define GL_LIGHT_MODEL_AMBIENT 0x0B53
|
||||
|
||||
#define GL_FLAT 0x1D00
|
||||
#define GL_SMOOTH 0x1D01
|
||||
#define GL_AMBIENT 0x1200
|
||||
|
@ -458,6 +461,8 @@ GLAPI void glPixelStorei(GLenum pname, GLint param);
|
|||
GLAPI void glScissor(GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
GLAPI void glLightf(GLenum light, GLenum pname, GLfloat param);
|
||||
GLAPI void glLightfv(GLenum light, GLenum pname, GLfloat* param);
|
||||
GLAPI void glLightModelf(GLenum pname, GLfloat param);
|
||||
GLAPI void glLightModelfv(GLenum pname, GLfloat const* params);
|
||||
GLAPI void glStencilFunc(GLenum func, GLint ref, GLuint mask);
|
||||
GLAPI void glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask);
|
||||
GLAPI void glStencilOp(GLenum sfail, GLenum dpfail, GLenum dppass);
|
||||
|
|
|
@ -101,6 +101,7 @@ public:
|
|||
virtual void gl_line_width(GLfloat width) = 0;
|
||||
virtual void gl_push_attrib(GLbitfield mask) = 0;
|
||||
virtual void gl_pop_attrib() = 0;
|
||||
virtual void gl_light_model(GLenum pname, GLfloat x, GLfloat y, GLfloat z, GLfloat w) = 0;
|
||||
|
||||
virtual void present() = 0;
|
||||
};
|
||||
|
|
|
@ -23,6 +23,22 @@ void glLightfv(GLenum light, GLenum pname, GLfloat* param)
|
|||
dbgln_if(GL_DEBUG, "glLightfv({}, {}, {}): unimplemented", light, pname, param);
|
||||
}
|
||||
|
||||
void glLightModelf(GLenum pname, GLfloat param)
|
||||
{
|
||||
g_gl_context->gl_light_model(pname, param, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
void glLightModelfv(GLenum pname, GLfloat const* params)
|
||||
{
|
||||
switch (pname) {
|
||||
case GL_LIGHT_MODEL_AMBIENT:
|
||||
g_gl_context->gl_light_model(pname, params[0], 0.0f, 0.0f, 0.0f);
|
||||
break;
|
||||
default:
|
||||
g_gl_context->gl_light_model(pname, params[0], params[1], params[2], params[3]);
|
||||
}
|
||||
}
|
||||
|
||||
void glMaterialf(GLenum face, GLenum pname, GLfloat param)
|
||||
{
|
||||
VERIFY(face == GL_SHININESS);
|
||||
|
|
|
@ -2345,6 +2345,27 @@ void SoftwareGLContext::gl_pop_attrib()
|
|||
dbgln_if(GL_DEBUG, "SoftwareGLContext FIXME: implement gl_pop_attrib()");
|
||||
}
|
||||
|
||||
void SoftwareGLContext::gl_light_model(GLenum pname, GLfloat x, GLfloat y, GLfloat z, GLfloat 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_AMBIENT
|
||||
|| pname == GL_LIGHT_MODEL_TWO_SIDE),
|
||||
GL_INVALID_ENUM);
|
||||
|
||||
switch (pname) {
|
||||
case GL_LIGHT_MODEL_AMBIENT:
|
||||
m_light_model_ambient = { x, y, z, w };
|
||||
break;
|
||||
case GL_LIGHT_MODEL_TWO_SIDE:
|
||||
VERIFY(y == 0.0f && z == 0.0f && w == 0.0f);
|
||||
m_light_model_two_side = x;
|
||||
break;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
void SoftwareGLContext::present()
|
||||
{
|
||||
m_rasterizer.blit_to(*m_frontbuffer);
|
||||
|
|
|
@ -112,6 +112,7 @@ public:
|
|||
virtual void gl_line_width(GLfloat width) override;
|
||||
virtual void gl_push_attrib(GLbitfield mask) override;
|
||||
virtual void gl_pop_attrib() override;
|
||||
virtual void gl_light_model(GLenum pname, GLfloat x, GLfloat y, GLfloat z, GLfloat w) override;
|
||||
virtual void present() override;
|
||||
|
||||
private:
|
||||
|
@ -284,7 +285,8 @@ private:
|
|||
decltype(&SoftwareGLContext::gl_materialv),
|
||||
decltype(&SoftwareGLContext::gl_line_width),
|
||||
decltype(&SoftwareGLContext::gl_push_attrib),
|
||||
decltype(&SoftwareGLContext::gl_pop_attrib)>;
|
||||
decltype(&SoftwareGLContext::gl_pop_attrib),
|
||||
decltype(&SoftwareGLContext::gl_light_model)>;
|
||||
|
||||
using ExtraSavedArguments = Variant<
|
||||
FloatMatrix4x4>;
|
||||
|
@ -333,6 +335,9 @@ private:
|
|||
RasterPosition m_current_raster_position;
|
||||
|
||||
float m_line_width { 1.0f };
|
||||
|
||||
FloatVector4 m_light_model_ambient { 0.2f, 0.2f, 0.2f, 1.0f };
|
||||
GLfloat m_light_model_two_side { 0.0f };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue