mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:47:44 +00: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
6 changed files with 6 additions and 6 deletions
|
@ -20,7 +20,7 @@ struct GLColor {
|
||||||
struct GLVertex {
|
struct GLVertex {
|
||||||
FloatVector4 position;
|
FloatVector4 position;
|
||||||
FloatVector4 color;
|
FloatVector4 color;
|
||||||
FloatVector2 tex_coord;
|
FloatVector4 tex_coord;
|
||||||
FloatVector3 normal;
|
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.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;
|
||||||
vertex.normal = m_current_vertex_normal;
|
vertex.normal = m_current_vertex_normal;
|
||||||
|
|
||||||
vertex_list.append(vertex);
|
vertex_list.append(vertex);
|
||||||
|
|
|
@ -171,7 +171,7 @@ private:
|
||||||
GLint m_clear_stencil { 0 };
|
GLint m_clear_stencil { 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, 1.0f };
|
||||||
FloatVector3 m_current_vertex_normal = { 0.0f, 0.0f, 1.0f };
|
FloatVector3 m_current_vertex_normal = { 0.0f, 0.0f, 1.0f };
|
||||||
|
|
||||||
Vector<GLVertex, 96> vertex_list;
|
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)
|
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;
|
FloatVector4 fragment = color;
|
||||||
|
|
||||||
for (auto const& texture_unit : bound_texture_units) {
|
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
|
// FIXME: Calculate the correct mipmap level here, need to receive uv derivatives for that
|
||||||
unsigned lod = 0;
|
unsigned lod = 0;
|
||||||
|
|
|
@ -31,7 +31,7 @@ public:
|
||||||
void set_wrap_s_mode(GLint value) { m_wrap_s_mode = value; }
|
void set_wrap_s_mode(GLint value) { m_wrap_s_mode = value; }
|
||||||
void set_wrap_t_mode(GLint value) { m_wrap_t_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:
|
private:
|
||||||
Texture2D const& m_texture;
|
Texture2D const& m_texture;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue