mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 17:44:56 +09:00
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}`.
This commit is contained in:
parent
86b249f02f
commit
4703e8cbcf
Notes:
sideshowbarker
2024-07-17 22:28:34 +09:00
Author: https://github.com/gmta
Commit: 4703e8cbcf
Pull-request: https://github.com/SerenityOS/serenity/pull/11337
Reviewed-by: https://github.com/sunverwerth ✅
6 changed files with 6 additions and 6 deletions
|
@ -20,7 +20,7 @@ struct GLColor {
|
|||
struct GLVertex {
|
||||
FloatVector4 position;
|
||||
FloatVector4 color;
|
||||
FloatVector2 tex_coord;
|
||||
FloatVector4 tex_coord;
|
||||
FloatVector3 normal;
|
||||
};
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue