@@ -48,6 +48,8 @@ GlParams gl_tex_params(gl_engine::Texture::Format format)
4848 return { GLint (gl_engine::Texture::compressed_texture_format ()), 0 , 0 , 0 , 0 , true };
4949 case F::RGBA8:
5050 return { GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, 4 , 1 , true };
51+ case F::SRGBA8:
52+ return { GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, 4 , 1 , true };
5153 case F::RGBA8UI:
5254 return { GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, 4 , 1 };
5355 case F::RGBA32F:
@@ -135,12 +137,13 @@ void gl_engine::Texture::upload(const nucleus::utils::ColourTexture& texture)
135137 f->glPixelStorei (GL_UNPACK_ALIGNMENT, 1 );
136138 const auto width = GLsizei (texture.width ());
137139 const auto height = GLsizei (texture.height ());
140+ const auto p = gl_tex_params (m_format);
138141 if (m_format == Format::CompressedRGBA8) {
139142 assert (m_min_filter != Filter::MipMapLinear);
140143 const auto format = gl_engine::Texture::compressed_texture_format ();
141144 f->glCompressedTexImage2D (GLenum (m_target), 0 , format, width, height, 0 , GLsizei (texture.n_bytes ()), texture.data ());
142- } else if (m_format == Format::RGBA8) {
143- f->glTexImage2D (GLenum (m_target), 0 , GL_RGBA8 , width, height, 0 , GL_RGBA, GL_UNSIGNED_BYTE , texture.data ());
145+ } else if (m_format == Format::RGBA8 || m_format == Format::SRGBA8 ) {
146+ f->glTexImage2D (GLenum (m_target), 0 , p. internal_format , width, height, 0 , p. format , p. type , texture.data ());
144147 if (m_min_filter == Filter::MipMapLinear)
145148 f->glGenerateMipmap (GLenum (m_target));
146149 } else {
@@ -163,7 +166,7 @@ void gl_engine::Texture::upload(const nucleus::utils::ColourTexture& texture, un
163166 if (m_format == Format::CompressedRGBA8) {
164167 const auto format = gl_engine::Texture::compressed_texture_format ();
165168 f->glCompressedTexSubImage3D (GLenum (m_target), 0 , 0 , 0 , GLint (array_index), width, height, 1 , format, GLsizei (texture.n_bytes ()), texture.data ());
166- } else if (m_format == Format::RGBA8) {
169+ } else if (m_format == Format::RGBA8 || m_format == Format::SRGBA8 ) {
167170 f->glTexSubImage3D (GLenum (m_target), 0 , 0 , 0 , GLint (array_index), width, height, 1 , GL_RGBA, GL_UNSIGNED_BYTE, texture.data ());
168171 } else {
169172 assert (false );
@@ -188,7 +191,7 @@ void gl_engine::Texture::upload(const nucleus::utils::MipmappedColourTexture& mi
188191 const auto format = gl_engine::Texture::compressed_texture_format ();
189192 f->glCompressedTexSubImage3D (
190193 GLenum (m_target), mip_level, 0 , 0 , GLint (array_index), width, height, 1 , format, GLsizei (texture.n_bytes ()), texture.data ());
191- } else if (m_format == Format::RGBA8) {
194+ } else if (m_format == Format::RGBA8 || m_format == Format::SRGBA8 ) {
192195 f->glTexSubImage3D (GLenum (m_target), mip_level, 0 , 0 , GLint (array_index), width, height, 1 , GL_RGBA, GL_UNSIGNED_BYTE, texture.data ());
193196 } else {
194197 assert (false );
@@ -274,18 +277,18 @@ GLenum gl_engine::Texture::compressed_texture_format()
274277 const ext = gl.getExtension (" WEBGL_compressed_texture_etc" );
275278 if (ext === null)
276279 return 0 ;
277- return ext.COMPRESSED_RGB8_ETC2 ;
280+ return ext.COMPRESSED_SRGB8_ETC2 ;
278281 });
279282 // qDebug() << "gl_engine::Texture::compressed_texture_format: gl_texture_format from js: " << gl_texture_format;
280283 // clang-format on
281284 if (gl_texture_format == 0 ) {
282- gl_texture_format = GL_COMPRESSED_RGB_S3TC_DXT1_EXT ; // not on mobile
285+ gl_texture_format = GL_COMPRESSED_SRGB_S3TC_DXT1_EXT ; // not on mobile
283286 }
284287 return gl_texture_format;
285288#elif defined(__ANDROID__)
286- return GL_COMPRESSED_RGB8_ETC2 ;
289+ return GL_COMPRESSED_SRGB8_ETC2 ;
287290#else
288- return GL_COMPRESSED_RGB_S3TC_DXT1_EXT ;
291+ return GL_COMPRESSED_SRGB_S3TC_DXT1_EXT ;
289292#endif
290293}
291294
0 commit comments