1
0
Fork 0
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:
Jelle Raaijmakers 2021-12-21 00:46:21 +01:00 committed by Brian Gianforcaro
parent 86b249f02f
commit 4703e8cbcf
Notes: sideshowbarker 2024-07-17 22:28:34 +09:00
6 changed files with 6 additions and 6 deletions

View file

@ -20,7 +20,7 @@ struct GLColor {
struct GLVertex {
FloatVector4 position;
FloatVector4 color;
FloatVector2 tex_coord;
FloatVector4 tex_coord;
FloatVector3 normal;
};

View file

@ -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);

View file

@ -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;

View file

@ -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) {

View file

@ -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;

View file

@ -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;