mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:27:43 +00:00
LibGL: Implement glNormal3f
and glNormal3fv
This commit is contained in:
parent
ea6bcda79c
commit
78d0674228
6 changed files with 27 additions and 1 deletions
|
@ -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 glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask);
|
||||||
GLAPI void glStencilOp(GLenum sfail, GLenum dpfail, GLenum dppass);
|
GLAPI void glStencilOp(GLenum sfail, GLenum dpfail, GLenum dppass);
|
||||||
GLAPI void glStencilOpSeparate(GLenum face, 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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,7 @@ public:
|
||||||
virtual void gl_scissor(GLint x, GLint y, GLsizei width, GLsizei height) = 0;
|
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_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_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;
|
virtual void present() = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include "GL/gl.h"
|
#include "GL/gl.h"
|
||||||
#include <LibGfx/Vector2.h>
|
#include <LibGfx/Vector2.h>
|
||||||
|
#include <LibGfx/Vector3.h>
|
||||||
#include <LibGfx/Vector4.h>
|
#include <LibGfx/Vector4.h>
|
||||||
|
|
||||||
namespace GL {
|
namespace GL {
|
||||||
|
@ -20,6 +21,7 @@ struct GLVertex {
|
||||||
FloatVector4 position;
|
FloatVector4 position;
|
||||||
FloatVector4 color;
|
FloatVector4 color;
|
||||||
FloatVector2 tex_coord;
|
FloatVector2 tex_coord;
|
||||||
|
FloatVector3 normal;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GLTriangle {
|
struct GLTriangle {
|
||||||
|
|
|
@ -169,3 +169,13 @@ void glTranslatef(GLfloat x, GLfloat y, GLfloat z)
|
||||||
{
|
{
|
||||||
g_gl_context->gl_translate(x, y, 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]);
|
||||||
|
}
|
||||||
|
|
|
@ -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.position = { static_cast<float>(x), static_cast<float>(y), static_cast<float>(z), static_cast<float>(w) };
|
||||||
vertex.color = m_current_vertex_color;
|
vertex.color = m_current_vertex_color;
|
||||||
vertex.tex_coord = { m_current_vertex_tex_coord.x(), m_current_vertex_tex_coord.y() };
|
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);
|
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;
|
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()
|
void SoftwareGLContext::present()
|
||||||
{
|
{
|
||||||
m_rasterizer.blit_to(*m_frontbuffer);
|
m_rasterizer.blit_to(*m_frontbuffer);
|
||||||
|
|
|
@ -104,6 +104,7 @@ public:
|
||||||
virtual void gl_scissor(GLint x, GLint y, GLsizei width, GLsizei height) override;
|
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_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_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;
|
virtual void present() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -143,6 +144,7 @@ private:
|
||||||
double m_clear_depth = { 1.0 };
|
double m_clear_depth = { 1.0 };
|
||||||
FloatVector4 m_current_vertex_color = { 1.0f, 1.0f, 1.0f, 1.0f };
|
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 };
|
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<GLVertex, 96> vertex_list;
|
||||||
Vector<GLTriangle, 32> triangle_list;
|
Vector<GLTriangle, 32> triangle_list;
|
||||||
|
@ -266,7 +268,8 @@ private:
|
||||||
decltype(&SoftwareGLContext::gl_polygon_offset),
|
decltype(&SoftwareGLContext::gl_polygon_offset),
|
||||||
decltype(&SoftwareGLContext::gl_scissor),
|
decltype(&SoftwareGLContext::gl_scissor),
|
||||||
decltype(&SoftwareGLContext::gl_stencil_func_separate),
|
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<
|
using ExtraSavedArguments = Variant<
|
||||||
FloatMatrix4x4>;
|
FloatMatrix4x4>;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue