diff options
-rw-r--r-- | Userland/Libraries/LibGL/GL/gl.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/GLContext.h | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/GLStruct.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/GLVert.cpp | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/SoftwareGLContext.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/SoftwareGLContext.h | 5 |
6 files changed, 27 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGL/GL/gl.h b/Userland/Libraries/LibGL/GL/gl.h index 396404e6d8..89530e9d7b 100644 --- a/Userland/Libraries/LibGL/GL/gl.h +++ b/Userland/Libraries/LibGL/GL/gl.h @@ -449,6 +449,8 @@ 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); GLAPI void glStencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz); +GLAPI void glNormal3fv(GLfloat const* v); #ifdef __cplusplus } diff --git a/Userland/Libraries/LibGL/GLContext.h b/Userland/Libraries/LibGL/GLContext.h index 8ad450b4ab..e5bb10772e 100644 --- a/Userland/Libraries/LibGL/GLContext.h +++ b/Userland/Libraries/LibGL/GLContext.h @@ -93,6 +93,7 @@ public: virtual void gl_scissor(GLint x, GLint y, GLsizei width, GLsizei height) = 0; virtual void gl_stencil_func_separate(GLenum face, GLenum func, GLint ref, GLuint mask) = 0; virtual void gl_stencil_op_separate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) = 0; + virtual void gl_normal(GLfloat nx, GLfloat ny, GLfloat nz) = 0; virtual void present() = 0; }; diff --git a/Userland/Libraries/LibGL/GLStruct.h b/Userland/Libraries/LibGL/GLStruct.h index 9b7785462f..72bb8cc3c3 100644 --- a/Userland/Libraries/LibGL/GLStruct.h +++ b/Userland/Libraries/LibGL/GLStruct.h @@ -8,6 +8,7 @@ #include "GL/gl.h" #include <LibGfx/Vector2.h> +#include <LibGfx/Vector3.h> #include <LibGfx/Vector4.h> namespace GL { @@ -20,6 +21,7 @@ struct GLVertex { FloatVector4 position; FloatVector4 color; FloatVector2 tex_coord; + FloatVector3 normal; }; struct GLTriangle { diff --git a/Userland/Libraries/LibGL/GLVert.cpp b/Userland/Libraries/LibGL/GLVert.cpp index 74249b9d05..d2a2bc4ba6 100644 --- a/Userland/Libraries/LibGL/GLVert.cpp +++ b/Userland/Libraries/LibGL/GLVert.cpp @@ -169,3 +169,13 @@ void glTranslatef(GLfloat x, GLfloat y, GLfloat z) { g_gl_context->gl_translate(x, y, z); } + +void glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz) +{ + g_gl_context->gl_normal(nx, ny, nz); +} + +void glNormal3fv(GLfloat const* v) +{ + g_gl_context->gl_normal(v[0], v[1], v[2]); +} diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.cpp b/Userland/Libraries/LibGL/SoftwareGLContext.cpp index c220e89efc..6ffe415d08 100644 --- a/Userland/Libraries/LibGL/SoftwareGLContext.cpp +++ b/Userland/Libraries/LibGL/SoftwareGLContext.cpp @@ -514,6 +514,7 @@ void SoftwareGLContext::gl_vertex(GLdouble x, GLdouble y, GLdouble z, GLdouble w vertex.position = { static_cast<float>(x), static_cast<float>(y), static_cast<float>(z), static_cast<float>(w) }; vertex.color = m_current_vertex_color; vertex.tex_coord = { m_current_vertex_tex_coord.x(), m_current_vertex_tex_coord.y() }; + vertex.normal = m_current_vertex_normal; vertex_list.append(vertex); } @@ -2240,6 +2241,13 @@ void SoftwareGLContext::gl_stencil_op_separate(GLenum face, GLenum sfail, GLenum m_stencil_backfacing_op = new_options; } +void SoftwareGLContext::gl_normal(GLfloat nx, GLfloat ny, GLfloat nz) +{ + APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_normal, nx, ny, nz); + + m_current_vertex_normal = { nx, ny, nz }; +} + void SoftwareGLContext::present() { m_rasterizer.blit_to(*m_frontbuffer); diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.h b/Userland/Libraries/LibGL/SoftwareGLContext.h index f5805a3dfa..335ed640e9 100644 --- a/Userland/Libraries/LibGL/SoftwareGLContext.h +++ b/Userland/Libraries/LibGL/SoftwareGLContext.h @@ -104,6 +104,7 @@ public: virtual void gl_scissor(GLint x, GLint y, GLsizei width, GLsizei height) override; virtual void gl_stencil_func_separate(GLenum face, GLenum func, GLint ref, GLuint mask) override; virtual void gl_stencil_op_separate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) override; + virtual void gl_normal(GLfloat nx, GLfloat ny, GLfloat nz) override; virtual void present() override; private: @@ -143,6 +144,7 @@ private: double m_clear_depth = { 1.0 }; FloatVector4 m_current_vertex_color = { 1.0f, 1.0f, 1.0f, 1.0f }; FloatVector4 m_current_vertex_tex_coord = { 0.0f, 0.0f, 0.0f, 0.0f }; + FloatVector3 m_current_vertex_normal = { 0.0f, 0.0f, 1.0f }; Vector<GLVertex, 96> vertex_list; Vector<GLTriangle, 32> triangle_list; @@ -266,7 +268,8 @@ private: decltype(&SoftwareGLContext::gl_polygon_offset), decltype(&SoftwareGLContext::gl_scissor), decltype(&SoftwareGLContext::gl_stencil_func_separate), - decltype(&SoftwareGLContext::gl_stencil_op_separate)>; + decltype(&SoftwareGLContext::gl_stencil_op_separate), + decltype(&SoftwareGLContext::gl_normal)>; using ExtraSavedArguments = Variant< FloatMatrix4x4>; |