diff options
author | Jelle Raaijmakers <jelle@gmta.nl> | 2021-12-21 00:46:21 +0100 |
---|---|---|
committer | Brian Gianforcaro <b.gianfo@gmail.com> | 2021-12-21 12:58:58 -0800 |
commit | 4703e8cbcf16f9448b6e1a0c2e00dd824349d281 (patch) | |
tree | b134999f9b1dfc571a4fba1e6178bd06d511bf24 | |
parent | 86b249f02fa2293341c0da9c590df6271050cd1d (diff) | |
download | serenity-4703e8cbcf16f9448b6e1a0c2e00dd824349d281.zip |
LibGL: Make texture coordinates a `FloatVector4`
In OpenGL, texture coordinates can have up to 4 values. This change
will help with easy application of texture coordinate matrix
transformations in the future.
Additionally, correct the initial value for texture coordinates to
`{ 0.f, 0.f, 0.f, 1.f}`.
-rw-r--r-- | Userland/Libraries/LibGL/GLStruct.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/SoftwareGLContext.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/SoftwareGLContext.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/SoftwareRasterizer.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/Tex/Sampler2D.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/Tex/Sampler2D.h | 2 |
6 files changed, 6 insertions, 6 deletions
diff --git a/Userland/Libraries/LibGL/GLStruct.h b/Userland/Libraries/LibGL/GLStruct.h index 72bb8cc3c3..a7434fba1b 100644 --- a/Userland/Libraries/LibGL/GLStruct.h +++ b/Userland/Libraries/LibGL/GLStruct.h @@ -20,7 +20,7 @@ struct GLColor { struct GLVertex { FloatVector4 position; FloatVector4 color; - FloatVector2 tex_coord; + FloatVector4 tex_coord; FloatVector3 normal; }; diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.cpp b/Userland/Libraries/LibGL/SoftwareGLContext.cpp index 82d5259a7a..e382bff19d 100644 --- a/Userland/Libraries/LibGL/SoftwareGLContext.cpp +++ b/Userland/Libraries/LibGL/SoftwareGLContext.cpp @@ -608,7 +608,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.tex_coord = m_current_vertex_tex_coord; vertex.normal = m_current_vertex_normal; vertex_list.append(vertex); diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.h b/Userland/Libraries/LibGL/SoftwareGLContext.h index d6b744cefc..7a4d9806da 100644 --- a/Userland/Libraries/LibGL/SoftwareGLContext.h +++ b/Userland/Libraries/LibGL/SoftwareGLContext.h @@ -171,7 +171,7 @@ private: GLint m_clear_stencil { 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 }; + FloatVector4 m_current_vertex_tex_coord = { 0.0f, 0.0f, 0.0f, 1.0f }; FloatVector3 m_current_vertex_normal = { 0.0f, 0.0f, 1.0f }; Vector<GLVertex, 96> vertex_list; diff --git a/Userland/Libraries/LibGL/SoftwareRasterizer.cpp b/Userland/Libraries/LibGL/SoftwareRasterizer.cpp index 5e82478ad9..aa175786e9 100644 --- a/Userland/Libraries/LibGL/SoftwareRasterizer.cpp +++ b/Userland/Libraries/LibGL/SoftwareRasterizer.cpp @@ -496,7 +496,7 @@ SoftwareRasterizer::SoftwareRasterizer(const Gfx::IntSize& min_size) void SoftwareRasterizer::submit_triangle(GLTriangle const& triangle, TextureUnit::BoundList const& bound_texture_units) { - rasterize_triangle(m_options, *m_render_target, *m_depth_buffer, triangle, [this, &bound_texture_units](const FloatVector2& uv, const FloatVector4& color, float z) -> FloatVector4 { + rasterize_triangle(m_options, *m_render_target, *m_depth_buffer, triangle, [this, &bound_texture_units](FloatVector4 const& uv, FloatVector4 const& color, float z) -> FloatVector4 { FloatVector4 fragment = color; for (auto const& texture_unit : bound_texture_units) { diff --git a/Userland/Libraries/LibGL/Tex/Sampler2D.cpp b/Userland/Libraries/LibGL/Tex/Sampler2D.cpp index 579285f29a..be9886bfe2 100644 --- a/Userland/Libraries/LibGL/Tex/Sampler2D.cpp +++ b/Userland/Libraries/LibGL/Tex/Sampler2D.cpp @@ -50,7 +50,7 @@ static constexpr float wrap(float value, GLint mode, int num_texels) } } -FloatVector4 Sampler2D::sample(FloatVector2 const& uv) const +FloatVector4 Sampler2D::sample(FloatVector4 const& uv) const { // FIXME: Calculate the correct mipmap level here, need to receive uv derivatives for that unsigned lod = 0; diff --git a/Userland/Libraries/LibGL/Tex/Sampler2D.h b/Userland/Libraries/LibGL/Tex/Sampler2D.h index 0de0dec1af..eea80abb1d 100644 --- a/Userland/Libraries/LibGL/Tex/Sampler2D.h +++ b/Userland/Libraries/LibGL/Tex/Sampler2D.h @@ -31,7 +31,7 @@ public: void set_wrap_s_mode(GLint value) { m_wrap_s_mode = value; } void set_wrap_t_mode(GLint value) { m_wrap_t_mode = value; } - FloatVector4 sample(FloatVector2 const& uv) const; + FloatVector4 sample(FloatVector4 const& uv) const; private: Texture2D const& m_texture; |