diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gles2/rasterizer_gles2.cpp | 19 | ||||
-rw-r--r-- | drivers/gles2/rasterizer_gles2.h | 4 |
2 files changed, 22 insertions, 1 deletions
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index 373de2bb22..20d1ca956a 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -921,6 +921,11 @@ void RasterizerGLES2::texture_allocate(RID p_texture,int p_width, int p_height,I texture->alloc_height = texture->height; }; + if (shrink_textures_x2) { + texture->alloc_height = MAX(1,texture->alloc_height/2); + texture->alloc_width = MAX(1,texture->alloc_width/2); + } + texture->gl_components_cache=components; texture->gl_format_cache=format; @@ -970,8 +975,15 @@ void RasterizerGLES2::texture_set_data(RID p_texture,const Image& p_image,VS::Cu if (texture->alloc_width != img.get_width() || texture->alloc_height != img.get_height()) { - if (img.get_format() <= Image::FORMAT_INDEXED_ALPHA) + + if (texture->alloc_width == img.get_width()/2 && texture->alloc_height == img.get_height()/2) { + + img.shrink_x2(); + } else if (img.get_format() <= Image::FORMAT_INDEXED_ALPHA) { + img.resize(texture->alloc_width, texture->alloc_height, Image::INTERPOLATE_BILINEAR); + + } }; @@ -1452,6 +1464,11 @@ void RasterizerGLES2::texture_debug_usage(List<VS::TextureInfo> *r_info){ } +void RasterizerGLES2::texture_set_shrink_all_x2_on_set_data(bool p_enable) { + + shrink_textures_x2=p_enable; +} + /* SHADER API */ RID RasterizerGLES2::shader_create(VS::ShaderMode p_mode) { diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h index 2a2f587f11..b52918c02f 100644 --- a/drivers/gles2/rasterizer_gles2.h +++ b/drivers/gles2/rasterizer_gles2.h @@ -108,6 +108,8 @@ class RasterizerGLES2 : public Rasterizer { bool use_half_float; bool low_memory_2d; + bool shrink_textures_x2; + 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,GLenum& r_gl_internal_format,int &r_gl_components,bool &r_has_alpha_cache,bool &r_compressed); @@ -1336,6 +1338,8 @@ public: virtual String texture_get_path(RID p_texture) const; virtual void texture_debug_usage(List<VS::TextureInfo> *r_info); + virtual void texture_set_shrink_all_x2_on_set_data(bool p_enable); + GLuint _texture_get_name(RID p_tex); /* SHADER API */ |