diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-08-12 15:49:27 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-08-12 15:49:45 +0400 |
commit | ba345bcbb6de5f32ba8ae3e9666077c707d10764 (patch) | |
tree | 3732eee5bcf15bbca42f82d9facb8e58c552b3ee /source/blender/gpu | |
parent | 794277f8b6ca5f48eb994560d201e210e1eabaf1 (diff) |
Fix T41414, T41386.
There were a few issues to fix here:
* We did not really unpremultiply float image dabs prior to sending them
to the GPU. That made float and byte image result different in texture
painting and undoing could change the result.
* To make textures nicely composited over the mesh, I used decal mode in
OpenGL texture environment for the texture unit. This uses the texture's
alpha channel with a nice over operator.
* Texture creation used to override the alpha setting due to the display
restrictions. Not so anymore, people can now create transparent byte
images.
Also, made alpha zero default for new textures now, since it has such a
nice effect here.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 8abe7d5534a..7295f0259c5 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -1039,21 +1039,14 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h) * which is much quicker for painting */ GLint row_length, skip_pixels, skip_rows; - glGetIntegerv(GL_UNPACK_ROW_LENGTH, &row_length); - glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skip_pixels); - glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skip_rows); - /* if color correction is needed, we must update the part that needs updating. */ if (ibuf->rect_float) { - float *buffer = MEM_mallocN(w*h*sizeof(float)*4, "temp_texpaint_float_buf"); + float *buffer = MEM_mallocN(w * h * sizeof(float) * 4, "temp_texpaint_float_buf"); bool is_data = (ima->tpageflag & IMA_GLBIND_IS_DATA) != 0; IMB_partial_rect_from_float(ibuf, buffer, x, y, w, h, is_data); - + if (GPU_check_scaled_image(ibuf, ima, buffer, x, y, w, h)) { MEM_freeN(buffer); - glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length); - glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels); - glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows); BKE_image_release_ibuf(ima, ibuf, NULL); return; } @@ -1078,15 +1071,16 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h) } if (GPU_check_scaled_image(ibuf, ima, NULL, x, y, w, h)) { - glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length); - glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels); - glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows); BKE_image_release_ibuf(ima, ibuf, NULL); return; } glBindTexture(GL_TEXTURE_2D, ima->bindcode); + glGetIntegerv(GL_UNPACK_ROW_LENGTH, &row_length); + glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skip_pixels); + glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skip_rows); + glPixelStorei(GL_UNPACK_ROW_LENGTH, ibuf->x); glPixelStorei(GL_UNPACK_SKIP_PIXELS, x); glPixelStorei(GL_UNPACK_SKIP_ROWS, y); |