mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibGL: Generate texture in glBindTexture if not previously generated
Required by Xash3D, which forgoes glGenTexture and implements its own texture generator. It expects glBindTexture to pick up on this though. The strategy here is to keep texture_object null if we don't find the texture in the allocation textures map, as it will then both generate and set the texture in the allocated textures map using the texture name passed to us, then bind it.
This commit is contained in:
parent
53d6e1600c
commit
f91e41f90c
Notes:
sideshowbarker
2024-07-17 21:01:42 +09:00
Author: https://github.com/Lubrsi Commit: https://github.com/SerenityOS/serenity/commit/f91e41f90c9 Pull-request: https://github.com/SerenityOS/serenity/pull/11824 Reviewed-by: https://github.com/IdanHo Reviewed-by: https://github.com/Quaker762 ✅ Reviewed-by: https://github.com/gmta ✅ Reviewed-by: https://github.com/sunverwerth ✅
1 changed files with 8 additions and 4 deletions
|
@ -1765,11 +1765,15 @@ void SoftwareGLContext::gl_bind_texture(GLenum target, GLuint texture)
|
|||
}
|
||||
|
||||
auto it = m_allocated_textures.find(texture);
|
||||
RefPtr<Texture> texture_object;
|
||||
|
||||
// The texture name does not exist
|
||||
RETURN_WITH_ERROR_IF(it == m_allocated_textures.end(), GL_INVALID_VALUE);
|
||||
|
||||
auto texture_object = it->value;
|
||||
// OpenGL 1.x supports binding texture names that were not previously generated by glGenTextures.
|
||||
// If there is not an allocated texture, meaning it was not previously generated by glGenTextures,
|
||||
// we can keep texture_object null to both allocate and bind the texture with the passed in texture name.
|
||||
// FIXME: Later OpenGL versions such as 4.x enforce that texture names being bound were previously generated
|
||||
// by glGenTextures.
|
||||
if (it != m_allocated_textures.end())
|
||||
texture_object = it->value;
|
||||
|
||||
// Binding a texture to a different target than it was first bound is an invalid operation
|
||||
// FIXME: We only support GL_TEXTURE_2D for now
|
||||
|
|
Loading…
Reference in a new issue