LibGL: Track multiple current texture coordinates in GLContext
Previously we only had a single current texture coordinate, set by the glTexCoord family of functions. Since we now can have multiple texture coordinates we track a vector of current texture coordinates and set the requested one in glMultiTexCoord(). glTexCoord() Always sets the first texture coordinate.
This commit is contained in:
parent
a2c771a913
commit
9627576d9c
Notes:
sideshowbarker
2024-07-17 20:39:02 +09:00
Author: https://github.com/sunverwerth Commit: https://github.com/SerenityOS/serenity/commit/9627576d9c4 Pull-request: https://github.com/SerenityOS/serenity/pull/11927 Reviewed-by: https://github.com/IdanHo Reviewed-by: https://github.com/Quaker762 ✅ Reviewed-by: https://github.com/gmta ✅
2 changed files with 10 additions and 5 deletions
|
@ -79,6 +79,9 @@ SoftwareGLContext::SoftwareGLContext(Gfx::Bitmap& frontbuffer)
|
|||
|
||||
m_client_side_texture_coord_array_enabled.resize(m_device_info.num_texture_units);
|
||||
m_client_tex_coord_pointer.resize(m_device_info.num_texture_units);
|
||||
m_current_vertex_tex_coord.resize(m_device_info.num_texture_units);
|
||||
for (auto& tex_coord : m_current_vertex_tex_coord)
|
||||
tex_coord = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
|
||||
build_extension_string();
|
||||
}
|
||||
|
@ -619,7 +622,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;
|
||||
for (size_t i = 0; i < m_device_info.num_texture_units; ++i)
|
||||
vertex.tex_coords[i] = m_current_vertex_tex_coord;
|
||||
vertex.tex_coords[i] = m_current_vertex_tex_coord[i];
|
||||
vertex.normal = m_current_vertex_normal;
|
||||
|
||||
m_vertex_list.append(vertex);
|
||||
|
@ -629,14 +632,16 @@ void SoftwareGLContext::gl_tex_coord(GLfloat s, GLfloat t, GLfloat r, GLfloat q)
|
|||
{
|
||||
APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_tex_coord, s, t, r, q);
|
||||
|
||||
m_current_vertex_tex_coord = { s, t, r, q };
|
||||
m_current_vertex_tex_coord[0] = { s, t, r, q };
|
||||
}
|
||||
|
||||
void SoftwareGLContext::gl_multi_tex_coord(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q)
|
||||
{
|
||||
APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_multi_tex_coord, target, s, t, r, q);
|
||||
|
||||
m_current_vertex_tex_coord = { s, t, r, q };
|
||||
RETURN_WITH_ERROR_IF(target < GL_TEXTURE0 || target >= GL_TEXTURE0 + m_device_info.num_texture_units, GL_INVALID_ENUM);
|
||||
|
||||
m_current_vertex_tex_coord[target - GL_TEXTURE0] = { s, t, r, q };
|
||||
}
|
||||
|
||||
void SoftwareGLContext::gl_viewport(GLint x, GLint y, GLsizei width, GLsizei height)
|
||||
|
|
|
@ -204,7 +204,7 @@ private:
|
|||
u8 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, 1.0f };
|
||||
Vector<FloatVector4> m_current_vertex_tex_coord;
|
||||
FloatVector3 m_current_vertex_normal = { 0.0f, 0.0f, 1.0f };
|
||||
|
||||
Vector<SoftGPU::Vertex> m_vertex_list;
|
||||
|
@ -262,7 +262,7 @@ private:
|
|||
// Texture objects
|
||||
TextureNameAllocator m_name_allocator;
|
||||
HashMap<GLuint, RefPtr<Texture>> m_allocated_textures;
|
||||
Vector<TextureUnit, 32> m_texture_units;
|
||||
Vector<TextureUnit> m_texture_units;
|
||||
TextureUnit* m_active_texture_unit;
|
||||
|
||||
// Texture coordinate generation state
|
||||
|
|
Loading…
Add table
Reference in a new issue