diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gles2/rasterizer_gles2.cpp | 160 | ||||
-rw-r--r-- | drivers/gles2/rasterizer_gles2.h | 3 | ||||
-rw-r--r-- | drivers/png/image_loader_png.cpp | 3 | ||||
-rw-r--r-- | drivers/png/resource_saver_png.cpp | 37 | ||||
-rw-r--r-- | drivers/theoraplayer/video_stream_theoraplayer.cpp | 36 | ||||
-rw-r--r-- | drivers/theoraplayer/video_stream_theoraplayer.h | 5 |
6 files changed, 165 insertions, 79 deletions
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index bb0fd2e593..4044496953 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -360,17 +360,19 @@ void RasterizerGLES2::_draw_primitive(int p_points, const Vector3 *p_vertices, c /* TEXTURE API */ -Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::Format p_format, uint32_t p_flags,GLenum& r_gl_format,int &r_gl_components,bool &r_has_alpha_cache,bool &r_compressed) { +Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::Format p_format, uint32_t p_flags,GLenum& r_gl_format,GLenum& r_gl_internal_format,int &r_gl_components,bool &r_has_alpha_cache,bool &r_compressed) { r_has_alpha_cache=false; r_compressed=false; + r_gl_format=0; Image image=p_image; switch(p_format) { case Image::FORMAT_GRAYSCALE: { r_gl_components=1; - r_gl_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_EXT_SLUMINANCE_NV:GL_LUMINANCE; + r_gl_format=GL_LUMINANCE; + r_gl_internal_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_EXT_SLUMINANCE_NV:GL_LUMINANCE; } break; case Image::FORMAT_INTENSITY: { @@ -378,14 +380,16 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For if (!image.empty()) image.convert(Image::FORMAT_RGBA); r_gl_components=4; - r_gl_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_GL_SRGB_ALPHA_EXT:GL_RGBA; + r_gl_format=GL_RGBA; + r_gl_internal_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_GL_SRGB_ALPHA_EXT:GL_RGBA; r_has_alpha_cache=true; } break; case Image::FORMAT_GRAYSCALE_ALPHA: { //image.convert(Image::FORMAT_RGBA); r_gl_components=2; - r_gl_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_EXT_SLUMINANCE_ALPHA_NV:GL_LUMINANCE_ALPHA; + r_gl_format=GL_LUMINANCE_ALPHA; + r_gl_internal_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_EXT_SLUMINANCE_ALPHA_NV:GL_LUMINANCE_ALPHA; r_has_alpha_cache=true; } break; @@ -394,7 +398,8 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For if (!image.empty()) image.convert(Image::FORMAT_RGB); r_gl_components=3; - r_gl_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_GL_SRGB_EXT:GL_RGB; + r_gl_format=GL_RGB; + r_gl_internal_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_GL_SRGB_EXT:GL_RGB; } break; @@ -407,14 +412,15 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For if (p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { if (srgb_supported) { - r_gl_format=_GL_SRGB_ALPHA_EXT; - } else { r_gl_format=GL_RGBA; + r_gl_internal_format=_GL_SRGB_ALPHA_EXT; + } else { + r_gl_internal_format=GL_RGBA; if (!image.empty()) image.srgb_to_linear(); } } else { - r_gl_format=GL_RGBA; + r_gl_internal_format=GL_RGBA; } r_has_alpha_cache=true; @@ -426,14 +432,15 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For if (p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { if (srgb_supported) { - r_gl_format=_GL_SRGB_EXT; - } else { + r_gl_internal_format=_GL_SRGB_EXT; r_gl_format=GL_RGB; + } else { + r_gl_internal_format=GL_RGB; if (!image.empty()) image.srgb_to_linear(); } } else { - r_gl_format=GL_RGB; + r_gl_internal_format=GL_RGB; } } break; case Image::FORMAT_RGBA: { @@ -442,14 +449,16 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For if (p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { if (srgb_supported) { - r_gl_format=_GL_SRGB_ALPHA_EXT; - } else { + r_gl_internal_format=_GL_SRGB_ALPHA_EXT; r_gl_format=GL_RGBA; + //r_gl_internal_format=GL_RGBA; + } else { + r_gl_internal_format=GL_RGBA; if (!image.empty()) image.srgb_to_linear(); } } else { - r_gl_format=GL_RGBA; + r_gl_internal_format=GL_RGBA; } r_has_alpha_cache=true; @@ -465,21 +474,22 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For if (p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { if (srgb_supported) { - r_gl_format=_GL_SRGB_ALPHA_EXT; - } else { r_gl_format=GL_RGBA; + r_gl_internal_format=_GL_SRGB_ALPHA_EXT; + } else { + r_gl_internal_format=GL_RGBA; if (!image.empty()) image.srgb_to_linear(); } } else { - r_gl_format=GL_RGBA; + r_gl_internal_format=GL_RGBA; } r_has_alpha_cache=true; } else { r_gl_components=1; //doesn't matter much - r_gl_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV:_EXT_COMPRESSED_RGBA_S3TC_DXT1_EXT; + r_gl_internal_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV:_EXT_COMPRESSED_RGBA_S3TC_DXT1_EXT; r_compressed=true; }; @@ -495,20 +505,21 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For if (p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { if (srgb_supported) { - r_gl_format=_GL_SRGB_ALPHA_EXT; - } else { r_gl_format=GL_RGBA; + r_gl_internal_format=_GL_SRGB_ALPHA_EXT; + } else { + r_gl_internal_format=GL_RGBA; if (!image.empty()) image.srgb_to_linear(); } } else { - r_gl_format=GL_RGBA; + r_gl_internal_format=GL_RGBA; } r_has_alpha_cache=true; } else { r_gl_components=1; //doesn't matter much - r_gl_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV:_EXT_COMPRESSED_RGBA_S3TC_DXT3_EXT; + r_gl_internal_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV:_EXT_COMPRESSED_RGBA_S3TC_DXT3_EXT; r_has_alpha_cache=true; r_compressed=true; @@ -526,20 +537,21 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For if (p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { if (srgb_supported) { - r_gl_format=_GL_SRGB_ALPHA_EXT; - } else { r_gl_format=GL_RGBA; + r_gl_internal_format=_GL_SRGB_ALPHA_EXT; + } else { + r_gl_internal_format=GL_RGBA; if (!image.empty()) image.srgb_to_linear(); } } else { - r_gl_format=GL_RGBA; + r_gl_internal_format=GL_RGBA; } r_has_alpha_cache=true; } else { r_gl_components=1; //doesn't matter much - r_gl_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV:_EXT_COMPRESSED_RGBA_S3TC_DXT5_EXT; + r_gl_internal_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV:_EXT_COMPRESSED_RGBA_S3TC_DXT5_EXT; r_has_alpha_cache=true; r_compressed=true; }; @@ -556,20 +568,21 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For if (p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { if (srgb_supported) { - r_gl_format=_GL_SRGB_ALPHA_EXT; - } else { r_gl_format=GL_RGBA; + r_gl_internal_format=_GL_SRGB_ALPHA_EXT; + } else { + r_gl_internal_format=GL_RGBA; if (!image.empty()) image.srgb_to_linear(); } } else { - r_gl_format=GL_RGBA; + r_gl_internal_format=GL_RGBA; } r_has_alpha_cache=true; } else { - r_gl_format=_EXT_COMPRESSED_LUMINANCE_LATC1_EXT; + r_gl_internal_format=_EXT_COMPRESSED_LUMINANCE_LATC1_EXT; r_gl_components=1; //doesn't matter much r_compressed=true; }; @@ -586,19 +599,20 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For if (p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { if (srgb_supported) { - r_gl_format=_GL_SRGB_ALPHA_EXT; - } else { r_gl_format=GL_RGBA; + r_gl_internal_format=_GL_SRGB_ALPHA_EXT; + } else { + r_gl_internal_format=GL_RGBA; if (!image.empty()) image.srgb_to_linear(); } } else { - r_gl_format=GL_RGBA; + r_gl_internal_format=GL_RGBA; } r_has_alpha_cache=true; } else { - r_gl_format=_EXT_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT; + r_gl_internal_format=_EXT_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT; r_gl_components=1; //doesn't matter much r_compressed=true; }; @@ -614,21 +628,22 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For if (p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { if (srgb_supported) { - r_gl_format=_GL_SRGB_ALPHA_EXT; - } else { r_gl_format=GL_RGBA; + r_gl_internal_format=_GL_SRGB_ALPHA_EXT; + } else { + r_gl_internal_format=GL_RGBA; if (!image.empty()) image.srgb_to_linear(); } } else { - r_gl_format=GL_RGBA; + r_gl_internal_format=GL_RGBA; } r_has_alpha_cache=true; } else { - r_gl_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_EXT_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT:_EXT_COMPRESSED_RGB_PVRTC_2BPPV1_IMG; + r_gl_internal_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_EXT_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT:_EXT_COMPRESSED_RGB_PVRTC_2BPPV1_IMG; r_gl_components=1; //doesn't matter much r_compressed=true; @@ -645,22 +660,23 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For if (p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { if (srgb_supported) { - r_gl_format=_GL_SRGB_ALPHA_EXT; - } else { r_gl_format=GL_RGBA; + r_gl_internal_format=_GL_SRGB_ALPHA_EXT; + } else { + r_gl_internal_format=GL_RGBA; if (!image.empty()) image.srgb_to_linear(); } } else { - r_gl_format=GL_RGBA; + r_gl_internal_format=GL_RGBA; } r_has_alpha_cache=true; } else { - r_gl_format=_EXT_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; - r_gl_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_EXT_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT:_EXT_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; + r_gl_internal_format=_EXT_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; + r_gl_internal_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_EXT_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT:_EXT_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; r_gl_components=1; //doesn't matter much r_compressed=true; @@ -677,19 +693,20 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For if (p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { if (srgb_supported) { - r_gl_format=_GL_SRGB_ALPHA_EXT; - } else { r_gl_format=GL_RGBA; + r_gl_internal_format=_GL_SRGB_ALPHA_EXT; + } else { + r_gl_internal_format=GL_RGBA; if (!image.empty()) image.srgb_to_linear(); } } else { - r_gl_format=GL_RGBA; + r_gl_internal_format=GL_RGBA; } r_has_alpha_cache=true; } else { - r_gl_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_EXT_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT:_EXT_COMPRESSED_RGB_PVRTC_4BPPV1_IMG; + r_gl_internal_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_EXT_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT:_EXT_COMPRESSED_RGB_PVRTC_4BPPV1_IMG; r_gl_components=1; //doesn't matter much r_compressed=true; } @@ -705,19 +722,20 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For if (p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { if (srgb_supported) { - r_gl_format=_GL_SRGB_ALPHA_EXT; - } else { r_gl_format=GL_RGBA; + r_gl_internal_format=_GL_SRGB_ALPHA_EXT; + } else { + r_gl_internal_format=GL_RGBA; if (!image.empty()) image.srgb_to_linear(); } } else { - r_gl_format=GL_RGBA; + r_gl_internal_format=GL_RGBA; } r_has_alpha_cache=true; } else { - r_gl_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_EXT_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT:_EXT_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; + r_gl_internal_format=(srgb_supported && p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_EXT_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT:_EXT_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; r_gl_components=1; //doesn't matter much r_compressed=true; } @@ -734,21 +752,22 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For if (p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { if (srgb_supported) { - r_gl_format=_GL_SRGB_EXT; - } else { r_gl_format=GL_RGB; + r_gl_internal_format=_GL_SRGB_EXT; + } else { + r_gl_internal_format=GL_RGB; if (!image.empty()) image.srgb_to_linear(); } } else { - r_gl_format=GL_RGB; + r_gl_internal_format=GL_RGB; } - r_gl_format=GL_RGB; + r_gl_internal_format=GL_RGB; } else { - r_gl_format=_EXT_ETC1_RGB8_OES; + r_gl_internal_format=_EXT_ETC1_RGB8_OES; r_gl_components=1; //doesn't matter much r_compressed=true; } @@ -762,12 +781,12 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For image.decompress(); } r_gl_components=3; - r_gl_format=GL_RGB; + r_gl_internal_format=GL_RGB; } else { - r_gl_format=_EXT_ATC_RGB_AMD; + r_gl_internal_format=_EXT_ATC_RGB_AMD; r_gl_components=1; //doesn't matter much r_compressed=true; } @@ -781,12 +800,12 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For image.decompress(); } r_gl_components=4; - r_gl_format=GL_RGBA; + r_gl_internal_format=GL_RGBA; } else { - r_gl_format=_EXT_ATC_RGBA_EXPLICIT_ALPHA_AMD; + r_gl_internal_format=_EXT_ATC_RGBA_EXPLICIT_ALPHA_AMD; r_gl_components=1; //doesn't matter much r_compressed=true; } @@ -800,12 +819,12 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For image.decompress(); } r_gl_components=4; - r_gl_format=GL_RGBA; + r_gl_internal_format=GL_RGBA; } else { - r_gl_format=_EXT_ATC_RGBA_INTERPOLATED_ALPHA_AMD; + r_gl_internal_format=_EXT_ATC_RGBA_INTERPOLATED_ALPHA_AMD; r_gl_components=1; //doesn't matter much r_compressed=true; } @@ -816,7 +835,7 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For if (!image.empty()) image.convert(Image::FORMAT_RGB); - r_gl_format=GL_RGB; + r_gl_internal_format=GL_RGB; r_gl_components=3; } break; @@ -827,6 +846,10 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For } } + if (r_gl_format==0) { + r_gl_format=r_gl_internal_format; + } + return image; } @@ -858,6 +881,7 @@ void RasterizerGLES2::texture_allocate(RID p_texture,int p_width, int p_height,I bool has_alpha_cache; int components; GLenum format; + GLenum internal_format; bool compressed; int po2_width = nearest_power_of_2(p_width); @@ -876,7 +900,7 @@ void RasterizerGLES2::texture_allocate(RID p_texture,int p_width, int p_height,I texture->flags=p_flags; texture->target = (p_flags & VS::TEXTURE_FLAG_CUBEMAP) ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D; - _get_gl_image_and_format(Image(),texture->format,texture->flags,format,components,has_alpha_cache,compressed); + _get_gl_image_and_format(Image(),texture->format,texture->flags,format,internal_format,components,has_alpha_cache,compressed); bool scale_textures = !compressed && !(p_flags&VS::TEXTURE_FLAG_VIDEO_SURFACE) && (!npo2_textures_available || p_flags&VS::TEXTURE_FLAG_MIPMAPS); @@ -894,6 +918,7 @@ void RasterizerGLES2::texture_allocate(RID p_texture,int p_width, int p_height,I texture->gl_components_cache=components; texture->gl_format_cache=format; + texture->gl_internal_format_cache=internal_format; texture->format_has_alpha=has_alpha_cache; texture->compressed=compressed; texture->has_alpha=false; //by default it doesn't have alpha unless something with alpha is blitteds @@ -908,7 +933,7 @@ void RasterizerGLES2::texture_allocate(RID p_texture,int p_width, int p_height,I if (p_flags&VS::TEXTURE_FLAG_VIDEO_SURFACE) { //prealloc if video - glTexImage2D(texture->target, 0, format, p_width, p_height, 0, format, GL_UNSIGNED_BYTE,NULL); + glTexImage2D(texture->target, 0, internal_format, p_width, p_height, 0, format, GL_UNSIGNED_BYTE,NULL); } texture->active=true; @@ -926,6 +951,7 @@ void RasterizerGLES2::texture_set_data(RID p_texture,const Image& p_image,VS::Cu int components; GLenum format; + GLenum internal_format; bool alpha; bool compressed; @@ -933,7 +959,7 @@ void RasterizerGLES2::texture_set_data(RID p_texture,const Image& p_image,VS::Cu texture->image[p_cube_side]=p_image; } - Image img = _get_gl_image_and_format(p_image, p_image.get_format(),texture->flags,format,components,alpha,compressed); + Image img = _get_gl_image_and_format(p_image, p_image.get_format(),texture->flags,format,internal_format,components,alpha,compressed); if (texture->alloc_width != img.get_width() || texture->alloc_height != img.get_height()) { @@ -1017,7 +1043,7 @@ void RasterizerGLES2::texture_set_data(RID p_texture,const Image& p_image,VS::Cu if (texture->flags&VS::TEXTURE_FLAG_VIDEO_SURFACE) { glTexSubImage2D( blit_target, i, 0,0,w,h,format,GL_UNSIGNED_BYTE,&read[ofs] ); } else { - glTexImage2D(blit_target, i, format, w, h, 0, format, GL_UNSIGNED_BYTE,&read[ofs]); + glTexImage2D(blit_target, i, internal_format, w, h, 0, format, GL_UNSIGNED_BYTE,&read[ofs]); } } diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h index 91395054d9..27f7848b13 100644 --- a/drivers/gles2/rasterizer_gles2.h +++ b/drivers/gles2/rasterizer_gles2.h @@ -106,7 +106,7 @@ class RasterizerGLES2 : public Rasterizer { Vector<float> skel_default; - Image _get_gl_image_and_format(const Image& p_image, Image::Format p_format, uint32_t p_flags,GLenum& r_gl_format,int &r_gl_components,bool &r_has_alpha_cache,bool &r_compressed); + Image _get_gl_image_and_format(const Image& p_image, Image::Format p_format, uint32_t p_flags,GLenum& r_gl_format,GLenum& r_gl_internal_format,int &r_gl_components,bool &r_has_alpha_cache,bool &r_compressed); class RenderTarget; @@ -119,6 +119,7 @@ class RasterizerGLES2 : public Rasterizer { GLenum target; GLenum gl_format_cache; + GLenum gl_internal_format_cache; int gl_components_cache; int data_size; //original data size, useful for retrieving back bool has_alpha; diff --git a/drivers/png/image_loader_png.cpp b/drivers/png/image_loader_png.cpp index 316397ed80..6fc20f36f7 100644 --- a/drivers/png/image_loader_png.cpp +++ b/drivers/png/image_loader_png.cpp @@ -102,6 +102,9 @@ Error ImageLoaderPNG::_load_image(void *rf_up,png_rw_ptr p_func,Image *p_image) png_read_info(png, info); png_get_IHDR(png, info, &width, &height, &depth, &color, NULL, NULL, NULL); + png_textp t; + //https://svn.gov.pt/projects/ccidadao/repository/middleware-offline/trunk/_src/eidmw/FreeImagePTEiD/Source/FreeImage/PluginPNG.cpp + //png_get_text(png,info,) /* printf("Image width:%i\n", width); printf("Image Height:%i\n", height); diff --git a/drivers/png/resource_saver_png.cpp b/drivers/png/resource_saver_png.cpp index a898f6e618..9b394e8a8c 100644 --- a/drivers/png/resource_saver_png.cpp +++ b/drivers/png/resource_saver_png.cpp @@ -30,6 +30,7 @@ #include "scene/resources/texture.h" #include "drivers/png/png.h" #include "os/file_access.h" +#include "globals.h" static void _write_png_data(png_structp png_ptr,png_bytep data, png_size_t p_length) { @@ -165,6 +166,42 @@ Error ResourceSaverPNG::save(const String &p_path,const RES& p_resource,uint32_t memdelete(f); + if (true) { + + bool global_filter = Globals::get_singleton()->get("image_loader/filter"); + bool global_mipmaps = Globals::get_singleton()->get("image_loader/gen_mipmaps"); + bool global_repeat = Globals::get_singleton()->get("image_loader/repeat"); + + String text; + + if (global_filter!=bool(texture->get_flags()&Texture::FLAG_FILTER)) { + text+=bool(texture->get_flags()&Texture::FLAG_FILTER)?"filter=true\n":"filter=false\n"; + } + if (global_mipmaps!=bool(texture->get_flags()&Texture::FLAG_MIPMAPS)) { + text+=bool(texture->get_flags()&Texture::FLAG_FILTER)?"gen_mipmaps=true\n":"gen_mipmaps=false\n"; + } + if (global_repeat!=bool(texture->get_flags()&Texture::FLAG_REPEAT)) { + text+=bool(texture->get_flags()&Texture::FLAG_FILTER)?"repeat=true\n":"repeat=false\n"; + } + if (bool(texture->get_flags()&Texture::FLAG_ANISOTROPIC_FILTER)) { + text+="anisotropic=true\n"; + } + if (bool(texture->get_flags()&Texture::FLAG_CONVERT_TO_LINEAR)) { + text+="tolinear=true\n"; + } + + if (text!="" || FileAccess::exists(p_path+".flags")) { + + f = FileAccess::open(p_path+".flags",FileAccess::WRITE); + if (f) { + + f->store_string(text); + memdelete(f); + } + } + } + + /* cleanup heap allocation */ return OK; diff --git a/drivers/theoraplayer/video_stream_theoraplayer.cpp b/drivers/theoraplayer/video_stream_theoraplayer.cpp index b2ff8062cc..04210f0209 100644 --- a/drivers/theoraplayer/video_stream_theoraplayer.cpp +++ b/drivers/theoraplayer/video_stream_theoraplayer.cpp @@ -306,18 +306,28 @@ int VideoStreamTheoraplayer::get_pending_frame_count() const { if (!clip) return 0; - if (!frame.empty()) - return 1; + TheoraVideoFrame* f = clip->getNextFrame(); + return f ? 1 : 0; +}; + + +void VideoStreamTheoraplayer::pop_frame(Ref<ImageTexture> p_tex) { TheoraVideoFrame* f = clip->getNextFrame(); - if (!f) - return 0; + if (!f) { + return; + }; + +#ifdef GLES2_ENABLED +// RasterizerGLES2* r = RasterizerGLES2::get_singleton(); +// r->_texture_set_data(p_tex, f->mBpp == 3 ? Image::Format_RGB : Image::Format_RGBA, f->mBpp, w, h, f->getBuffer()); + +#endif float w=clip->getWidth(),h=clip->getHeight(); int imgsize = w * h * f->mBpp; int size = f->getStride() * f->getHeight() * f->mBpp; - DVector<uint8_t> data; data.resize(imgsize); DVector<uint8_t>::Write wr = data.write(); uint8_t* ptr = wr.ptr(); @@ -329,24 +339,32 @@ int VideoStreamTheoraplayer::get_pending_frame_count() const { copymem(ptr + dstofs, f->getBuffer() + dstofs, w * f->mBpp); }; */ - frame = Image(); + Image frame = Image(); frame.create(w, h, 0, f->mBpp == 3 ? Image::FORMAT_RGB : Image::FORMAT_RGBA, data); clip->popFrame(); - return 1; + if (p_tex->get_width() == 0) { + p_tex->create(frame.get_width(),frame.get_height(),frame.get_format(),Texture::FLAG_VIDEO_SURFACE|Texture::FLAG_FILTER); + p_tex->set_data(frame); + } else { + + p_tex->set_data(frame); + }; }; +/* Image VideoStreamTheoraplayer::pop_frame() { Image ret = frame; frame = Image(); return ret; }; +*/ Image VideoStreamTheoraplayer::peek_frame() const { - return frame; + return Image(); }; void VideoStreamTheoraplayer::update(float p_time) { @@ -386,7 +404,7 @@ void VideoStreamTheoraplayer::set_file(const String& p_file) { if (p_file.find(".mp4") != -1) { std::string file = p_file.replace("res://", "").utf8().get_data(); - clip = mgr->createVideoClip(file); + clip = mgr->createVideoClip(file, TH_BGRX, 16); memdelete(f); } else { diff --git a/drivers/theoraplayer/video_stream_theoraplayer.h b/drivers/theoraplayer/video_stream_theoraplayer.h index 063bf38953..67a2db710b 100644 --- a/drivers/theoraplayer/video_stream_theoraplayer.h +++ b/drivers/theoraplayer/video_stream_theoraplayer.h @@ -3,6 +3,7 @@ #include "scene/resources/video_stream.h" #include "io/resource_loader.h" +#include "scene/resources/texture.h" class TheoraVideoManager; class TheoraVideoClip; @@ -11,7 +12,7 @@ class VideoStreamTheoraplayer : public VideoStream { OBJ_TYPE(VideoStreamTheoraplayer,VideoStream); - mutable Image frame; + mutable DVector<uint8_t> data; TheoraVideoManager* mgr; TheoraVideoClip* clip; bool started; @@ -37,7 +38,7 @@ public: virtual float get_length() const; virtual int get_pending_frame_count() const; - virtual Image pop_frame(); + virtual void pop_frame(Ref<ImageTexture> p_tex); virtual Image peek_frame() const; void update(float p_time); |