summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorStephan Unverwerth <s.unverwerth@serenityos.org>2021-08-31 22:08:01 +0200
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-09-02 21:00:24 +0430
commit05a7a4640de685b8951529f971919daaa8561f9b (patch)
treec642ca3116ed8af41df979e96ff4f47372ffb6ad /Userland
parent15299b763cf3c5b8b8cbf508f01eabe08afe6bcd (diff)
downloadserenity-05a7a4640de685b8951529f971919daaa8561f9b.zip
LibGL: Allow numerical internal formats in glTexImage2D
Prior to version 1.1 OpenGL only allowed the numbers 1,2,3 and 4 to be used as internal texture formats. Symbolic constants were introduced first with the EXT_texture extension and then later adopted into the core profile.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibGL/SoftwareGLContext.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.cpp b/Userland/Libraries/LibGL/SoftwareGLContext.cpp
index d19b8726e1..16e0789f84 100644
--- a/Userland/Libraries/LibGL/SoftwareGLContext.cpp
+++ b/Userland/Libraries/LibGL/SoftwareGLContext.cpp
@@ -642,6 +642,16 @@ void SoftwareGLContext::gl_tex_image_2d(GLenum target, GLint level, GLint intern
// Check if there is actually a texture bound
RETURN_WITH_ERROR_IF(target == GL_TEXTURE_2D && m_active_texture_unit->currently_bound_target() != GL_TEXTURE_2D, GL_INVALID_OPERATION);
+ // Internal format can also be a number between 1 and 4. Symbolic formats were only added with EXT_texture, promoted to core in OpenGL 1.1
+ if (internal_format == 1)
+ internal_format = GL_ALPHA;
+ else if (internal_format == 2)
+ internal_format = GL_LUMINANCE_ALPHA;
+ else if (internal_format == 3)
+ internal_format = GL_RGB;
+ else if (internal_format == 4)
+ internal_format = GL_RGBA;
+
// We only support symbolic constants for now
RETURN_WITH_ERROR_IF(!(internal_format == GL_RGB || internal_format == GL_RGBA), GL_INVALID_ENUM);
RETURN_WITH_ERROR_IF(type != GL_UNSIGNED_BYTE, GL_INVALID_VALUE);