summaryrefslogtreecommitdiff
path: root/drivers/gles3/rasterizer_storage_gles3.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gles3/rasterizer_storage_gles3.cpp')
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp
index eca916854a..9edc37fe3b 100644
--- a/drivers/gles3/rasterizer_storage_gles3.cpp
+++ b/drivers/gles3/rasterizer_storage_gles3.cpp
@@ -826,15 +826,20 @@ Image RasterizerStorageGLES3::texture_get_data(RID p_texture,VS::CubeMapSide p_c
DVector<uint8_t> data;
- int data_size = Image::get_image_data_size(texture->width,texture->height,texture->format,texture->mipmaps>1?-1:0);
+ int data_size = Image::get_image_data_size(texture->alloc_width,texture->alloc_height,texture->format,texture->mipmaps>1?-1:0);
- data.resize(data_size);
+ data.resize(data_size*2); //add some memory at the end, just in case for buggy drivers
DVector<uint8_t>::Write wb = data.write();
glActiveTexture(GL_TEXTURE0);
glBindTexture(texture->target,texture->tex_id);
+ glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
+
+ print_line("GET FORMAT: "+Image::get_format_name(texture->format)+" mipmaps: "+itos(texture->mipmaps));
+
+
for(int i=0;i<texture->mipmaps;i++) {
int ofs=0;
@@ -848,7 +853,9 @@ Image RasterizerStorageGLES3::texture_get_data(RID p_texture,VS::CubeMapSide p_c
glGetCompressedTexImage(texture->target,i,&wb[ofs]);
} else {
+
glPixelStorei(GL_PACK_ALIGNMENT, 1);
+
glGetTexImage(texture->target,i,texture->gl_format_cache,texture->gl_type_cache,&wb[ofs]);
}
}
@@ -856,6 +863,8 @@ Image RasterizerStorageGLES3::texture_get_data(RID p_texture,VS::CubeMapSide p_c
wb=DVector<uint8_t>::Write();
+ data.resize(data_size);
+
Image img(texture->alloc_width,texture->alloc_height,texture->mipmaps>1?true:false,texture->format,data);
return img;