diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2011-01-31 14:17:50 +0300 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2011-01-31 14:17:50 +0300 |
commit | 48fc6f569811bc29011d21e82f76c4152692ecf4 (patch) | |
tree | dcd7405cb69bb5a70915f1985b8c301654bdcedf /source/blender/editors/space_node | |
parent | e5cbc0307a3b3a5e5c922bf07eaf71000440b4ab (diff) |
Added transparency feature to node editor backdrop, similar to image editor. Alpha blending can be enabled by a button when "Use Backdrop" is selected.
Diffstat (limited to 'source/blender/editors/space_node')
-rw-r--r-- | source/blender/editors/space_node/drawnode.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 4590cfe7442..a17fceb4fff 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -44,6 +44,7 @@ #include "BKE_context.h" #include "BKE_curve.h" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_library.h" #include "BKE_main.h" @@ -1367,9 +1368,35 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage) } if(ibuf->rect) { - glPixelZoom(snode->zoom, snode->zoom); - glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); - glPixelZoom(1.0f, 1.0f); + if (snode->flag & SNODE_SHOW_ALPHA) { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glPixelZoom(snode->zoom, snode->zoom); + /* swap bytes, so alpha is most significant one, then just draw it as luminance int */ + if(ENDIAN_ORDER == B_ENDIAN) + glPixelStorei(GL_UNPACK_SWAP_BYTES, 1); + + glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, ibuf->rect); + + glPixelStorei(GL_UNPACK_SWAP_BYTES, 0); + glPixelZoom(1.0f, 1.0f); + glDisable(GL_BLEND); + } else if (snode->flag & SNODE_USE_ALPHA) { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glPixelZoom(snode->zoom, snode->zoom); + + glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); + + glPixelZoom(1.0f, 1.0f); + glDisable(GL_BLEND); + } else { + glPixelZoom(snode->zoom, snode->zoom); + + glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); + + glPixelZoom(1.0f, 1.0f); + } } glMatrixMode(GL_PROJECTION); |