From 2b352211f48e033dd0af84b903c4c5a997c9320b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 30 Jan 2010 09:24:50 +0000 Subject: Fix #19875: drawing smoke on graphics cards that do not support non-power-of-two textures lead to artifacts due to uninitialized memory if the domain had a non-power-of-two size. --- source/blender/gpu/intern/gpu_extensions.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index 5deef4a5200..48ef5fdb0aa 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -372,6 +372,13 @@ GPUTexture *GPU_texture_create_3D(int w, int h, int depth, float *fpixels) GPU_print_error("3D glTexImage3D"); if (fpixels) { + if(!GPU_non_power_of_two_support() && (w != tex->w || h != tex->h || depth != tex->depth)) { + /* clear first to avoid unitialized pixels */ + float *zero= MEM_callocN(sizeof(float)*tex->w*tex->h*tex->depth, "zero"); + glTexSubImage3D(tex->target, 0, 0, 0, 0, tex->w, tex->h, tex->depth, format, type, zero); + MEM_freeN(zero); + } + glTexSubImage3D(tex->target, 0, 0, 0, 0, w, h, depth, format, type, fpixels); GPU_print_error("3D glTexSubImage3D"); } -- cgit v1.2.3