|
|
@@ -1053,6 +1053,24 @@ reset() {
|
|
|
break;
|
|
|
#endif
|
|
|
|
|
|
+ case GL_COMPRESSED_R11_EAC:
|
|
|
+ case GL_COMPRESSED_RG11_EAC:
|
|
|
+ _compressed_texture_formats.set_bit(Texture::CM_eac);
|
|
|
+ break;
|
|
|
+
|
|
|
+ case GL_COMPRESSED_RGB8_ETC2:
|
|
|
+ case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
|
|
|
+ case GL_COMPRESSED_RGBA8_ETC2_EAC:
|
|
|
+ _compressed_texture_formats.set_bit(Texture::CM_etc1);
|
|
|
+ _compressed_texture_formats.set_bit(Texture::CM_etc2);
|
|
|
+ break;
|
|
|
+
|
|
|
+#ifdef OPENGLES
|
|
|
+ case GL_ETC1_RGB8_OES:
|
|
|
+ _compressed_texture_formats.set_bit(Texture::CM_etc1);
|
|
|
+ break;
|
|
|
+#endif
|
|
|
+
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
@@ -8066,6 +8084,12 @@ get_texture_target(Texture::TextureType texture_type) const {
|
|
|
return GL_TEXTURE_1D;
|
|
|
#endif
|
|
|
|
|
|
+ case Texture::TT_1d_texture_array:
|
|
|
+ // There are no 1D array textures in OpenGL ES. Fall back to 2D textures.
|
|
|
+#ifndef OPENGLES
|
|
|
+ return GL_TEXTURE_1D_ARRAY;
|
|
|
+#endif
|
|
|
+
|
|
|
case Texture::TT_2d_texture:
|
|
|
return GL_TEXTURE_2D;
|
|
|
|
|
|
@@ -8282,6 +8306,11 @@ get_component_type(Texture::ComponentType component_type) {
|
|
|
return GL_HALF_FLOAT;
|
|
|
#endif
|
|
|
|
|
|
+#ifndef OPENGLES_1
|
|
|
+ case Texture::T_unsigned_int:
|
|
|
+ return GL_UNSIGNED_INT;
|
|
|
+#endif
|
|
|
+
|
|
|
default:
|
|
|
GLCAT.error() << "Invalid Texture::Type value!\n";
|
|
|
return GL_UNSIGNED_BYTE;
|
|
|
@@ -8444,9 +8473,9 @@ get_external_image_format(Texture *tex) const {
|
|
|
|
|
|
case Texture::CM_rgtc:
|
|
|
#ifndef OPENGLES
|
|
|
- if (tex->get_format() == Texture::F_luminance) {
|
|
|
+ if (format == Texture::F_luminance) {
|
|
|
return GL_COMPRESSED_LUMINANCE_LATC1_EXT;
|
|
|
- } else if (tex->get_format() == Texture::F_luminance_alpha) {
|
|
|
+ } else if (format == Texture::F_luminance_alpha) {
|
|
|
return GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT;
|
|
|
} else if (tex->get_num_components() == 1) {
|
|
|
return GL_COMPRESSED_RED_RGTC1;
|
|
|
@@ -8456,6 +8485,41 @@ get_external_image_format(Texture *tex) const {
|
|
|
#endif
|
|
|
break;
|
|
|
|
|
|
+ case Texture::CM_etc1:
|
|
|
+#ifdef OPENGLES
|
|
|
+ return GL_ETC1_RGB8_OES;
|
|
|
+#endif
|
|
|
+ // Fall through - ETC2 is backward compatible
|
|
|
+ case Texture::CM_etc2:
|
|
|
+ if (format == Texture::F_rgbm) {
|
|
|
+ return GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;
|
|
|
+ } else if (format == Texture::F_srgb_alpha) {
|
|
|
+ return GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;
|
|
|
+ } else if (format == Texture::F_srgb) {
|
|
|
+ return GL_COMPRESSED_SRGB8_ETC2;
|
|
|
+ } else if (Texture::has_alpha(format)) {
|
|
|
+ return GL_COMPRESSED_RGBA8_ETC2_EAC;
|
|
|
+ } else {
|
|
|
+ return GL_COMPRESSED_RGB8_ETC2;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ case Texture::CM_eac:
|
|
|
+ if (Texture::is_unsigned(tex->get_component_type())) {
|
|
|
+ if (tex->get_num_components() == 1) {
|
|
|
+ return GL_COMPRESSED_R11_EAC;
|
|
|
+ } else {
|
|
|
+ return GL_COMPRESSED_RG11_EAC;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (tex->get_num_components() == 1) {
|
|
|
+ return GL_COMPRESSED_SIGNED_R11_EAC;
|
|
|
+ } else {
|
|
|
+ return GL_COMPRESSED_SIGNED_RG11_EAC;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
case Texture::CM_default:
|
|
|
case Texture::CM_off:
|
|
|
case Texture::CM_dxt2:
|
|
|
@@ -8565,7 +8629,7 @@ get_external_image_format(Texture *tex) const {
|
|
|
}
|
|
|
GLCAT.error()
|
|
|
<< "Invalid Texture::Format value in get_external_image_format(): "
|
|
|
- << tex->get_format() << "\n";
|
|
|
+ << format << "\n";
|
|
|
return GL_RGB;
|
|
|
}
|
|
|
|
|
|
@@ -8615,10 +8679,14 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
|
|
|
break;
|
|
|
|
|
|
case Texture::F_rgbm:
|
|
|
+ case Texture::F_rgba5:
|
|
|
case Texture::F_rgb10_a2:
|
|
|
if (get_supports_compressed_texture_format(Texture::CM_dxt1) && !is_3d) {
|
|
|
return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
|
|
}
|
|
|
+ if (get_supports_compressed_texture_format(Texture::CM_etc2) && !is_3d) {
|
|
|
+ return GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;
|
|
|
+ }
|
|
|
#ifndef OPENGLES
|
|
|
if (get_supports_compressed_texture_format(Texture::CM_fxt1) && !is_3d) {
|
|
|
return GL_COMPRESSED_RGBA_FXT1_3DFX;
|
|
|
@@ -8633,6 +8701,9 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
|
|
|
return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
|
|
|
}
|
|
|
#endif
|
|
|
+ if (get_supports_compressed_texture_format(Texture::CM_etc2) && !is_3d) {
|
|
|
+ return GL_COMPRESSED_RGBA8_ETC2_EAC;
|
|
|
+ }
|
|
|
#ifndef OPENGLES
|
|
|
if (get_supports_compressed_texture_format(Texture::CM_fxt1) && !is_3d) {
|
|
|
return GL_COMPRESSED_RGBA_FXT1_3DFX;
|
|
|
@@ -8651,6 +8722,9 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
|
|
|
return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
|
|
}
|
|
|
#endif
|
|
|
+ if (get_supports_compressed_texture_format(Texture::CM_etc2) && !is_3d) {
|
|
|
+ return GL_COMPRESSED_RGBA8_ETC2_EAC;
|
|
|
+ }
|
|
|
#ifndef OPENGLES
|
|
|
if (get_supports_compressed_texture_format(Texture::CM_fxt1) && !is_3d) {
|
|
|
return GL_COMPRESSED_RGBA_FXT1_3DFX;
|
|
|
@@ -8661,7 +8735,6 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
|
|
|
|
|
|
case Texture::F_rgb:
|
|
|
case Texture::F_rgb5:
|
|
|
- case Texture::F_rgba5:
|
|
|
case Texture::F_rgb8:
|
|
|
case Texture::F_rgb12:
|
|
|
case Texture::F_rgb332:
|
|
|
@@ -8670,7 +8743,14 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
|
|
|
if (get_supports_compressed_texture_format(Texture::CM_dxt1) && !is_3d) {
|
|
|
return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
|
|
|
}
|
|
|
-#ifndef OPENGLES
|
|
|
+ if (get_supports_compressed_texture_format(Texture::CM_etc2) && !is_3d) {
|
|
|
+ return GL_COMPRESSED_RGB8_ETC2;
|
|
|
+ }
|
|
|
+#ifdef OPENGLES
|
|
|
+ if (get_supports_compressed_texture_format(Texture::CM_etc1) && !is_3d) {
|
|
|
+ return GL_ETC1_RGB8_OES;
|
|
|
+ }
|
|
|
+#else
|
|
|
if (get_supports_compressed_texture_format(Texture::CM_fxt1) && !is_3d) {
|
|
|
return GL_COMPRESSED_RGB_FXT1_3DFX;
|
|
|
}
|
|
|
@@ -8702,6 +8782,13 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
|
|
|
return GL_COMPRESSED_RED_RGTC1;
|
|
|
}
|
|
|
#endif
|
|
|
+ if (get_supports_compressed_texture_format(Texture::CM_eac) && !is_3d) {
|
|
|
+ if (Texture::is_unsigned(tex->get_component_type())) {
|
|
|
+ return GL_COMPRESSED_R11_EAC;
|
|
|
+ } else {
|
|
|
+ return GL_COMPRESSED_SIGNED_R11_EAC;
|
|
|
+ }
|
|
|
+ }
|
|
|
if (get_supports_compressed_texture_format(Texture::CM_dxt1) && !is_3d) {
|
|
|
return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
|
|
|
}
|
|
|
@@ -8721,6 +8808,13 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
|
|
|
return GL_COMPRESSED_RG_RGTC2;
|
|
|
}
|
|
|
#endif
|
|
|
+ if (get_supports_compressed_texture_format(Texture::CM_eac) && !is_3d) {
|
|
|
+ if (Texture::is_unsigned(tex->get_component_type())) {
|
|
|
+ return GL_COMPRESSED_RG11_EAC;
|
|
|
+ } else {
|
|
|
+ return GL_COMPRESSED_SIGNED_RG11_EAC;
|
|
|
+ }
|
|
|
+ }
|
|
|
if (get_supports_compressed_texture_format(Texture::CM_dxt1) && !is_3d) {
|
|
|
return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
|
|
|
}
|
|
|
@@ -8764,12 +8858,18 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
|
|
|
if (get_supports_compressed_texture_format(Texture::CM_dxt1) && !is_3d) {
|
|
|
return GL_COMPRESSED_SRGB_S3TC_DXT1_EXT;
|
|
|
}
|
|
|
+ if (get_supports_compressed_texture_format(Texture::CM_etc2) && !is_3d) {
|
|
|
+ return GL_COMPRESSED_SRGB8_ETC2;
|
|
|
+ }
|
|
|
return GL_COMPRESSED_SRGB;
|
|
|
|
|
|
case Texture::F_srgb_alpha:
|
|
|
if (get_supports_compressed_texture_format(Texture::CM_dxt5) && !is_3d) {
|
|
|
return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
|
|
|
}
|
|
|
+ if (get_supports_compressed_texture_format(Texture::CM_etc2) && !is_3d) {
|
|
|
+ return GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;
|
|
|
+ }
|
|
|
return GL_COMPRESSED_SRGB_ALPHA;
|
|
|
|
|
|
case Texture::F_sluminance:
|
|
|
@@ -8855,9 +8955,9 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
|
|
|
|
|
|
case Texture::CM_rgtc:
|
|
|
#ifndef OPENGLES
|
|
|
- if (tex->get_format() == Texture::F_luminance) {
|
|
|
+ if (format == Texture::F_luminance) {
|
|
|
return GL_COMPRESSED_LUMINANCE_LATC1_EXT;
|
|
|
- } else if (tex->get_format() == Texture::F_luminance_alpha) {
|
|
|
+ } else if (format == Texture::F_luminance_alpha) {
|
|
|
return GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT;
|
|
|
} else if (tex->get_num_components() == 1) {
|
|
|
return GL_COMPRESSED_RED_RGTC1;
|
|
|
@@ -8867,6 +8967,41 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
|
|
|
#endif
|
|
|
break;
|
|
|
|
|
|
+ case Texture::CM_etc1:
|
|
|
+#ifdef OPENGLES
|
|
|
+ return GL_ETC1_RGB8_OES;
|
|
|
+#endif
|
|
|
+ // Fall through - ETC2 is backward compatible
|
|
|
+ case Texture::CM_etc2:
|
|
|
+ if (format == Texture::F_rgbm) {
|
|
|
+ return GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;
|
|
|
+ } else if (format == Texture::F_srgb_alpha) {
|
|
|
+ return GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;
|
|
|
+ } else if (format == Texture::F_srgb) {
|
|
|
+ return GL_COMPRESSED_SRGB8_ETC2;
|
|
|
+ } else if (Texture::has_alpha(format)) {
|
|
|
+ return GL_COMPRESSED_RGBA8_ETC2_EAC;
|
|
|
+ } else {
|
|
|
+ return GL_COMPRESSED_RGB8_ETC2;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ case Texture::CM_eac:
|
|
|
+ if (Texture::is_unsigned(tex->get_component_type())) {
|
|
|
+ if (tex->get_num_components() == 1) {
|
|
|
+ return GL_COMPRESSED_R11_EAC;
|
|
|
+ } else {
|
|
|
+ return GL_COMPRESSED_RG11_EAC;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (tex->get_num_components() == 1) {
|
|
|
+ return GL_COMPRESSED_SIGNED_R11_EAC;
|
|
|
+ } else {
|
|
|
+ return GL_COMPRESSED_SIGNED_RG11_EAC;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
case Texture::CM_default:
|
|
|
case Texture::CM_off:
|
|
|
case Texture::CM_dxt2:
|
|
|
@@ -9197,7 +9332,7 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
|
|
|
default:
|
|
|
GLCAT.error()
|
|
|
<< "Invalid image format in get_internal_image_format(): "
|
|
|
- << (int)tex->get_format() << "\n";
|
|
|
+ << (int)format << "\n";
|
|
|
return force_sized ? GL_RGB8 : GL_RGB;
|
|
|
}
|
|
|
}
|
|
|
@@ -11661,6 +11796,7 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) {
|
|
|
break;
|
|
|
case Texture::TT_2d_texture:
|
|
|
case Texture::TT_cube_map:
|
|
|
+ case Texture::TT_1d_texture_array:
|
|
|
_glTexStorage2D(target, num_levels, internal_format, width, height);
|
|
|
break;
|
|
|
case Texture::TT_3d_texture:
|
|
|
@@ -12119,6 +12255,14 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload,
|
|
|
// fill it in with the correct clear color, which we can then
|
|
|
// upload.
|
|
|
ptimage = tex->make_ram_mipmap_image(n);
|
|
|
+
|
|
|
+ } else if (image_compression != Texture::CM_off) {
|
|
|
+ // We can't upload a NULL compressed texture.
|
|
|
+ if (_supports_texture_max_level) {
|
|
|
+ // Tell the GL we have no more mipmaps for it to use.
|
|
|
+ glTexParameteri(texture_target, GL_TEXTURE_MAX_LEVEL, n - mipmap_bias);
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
image_ptr = ptimage;
|