Siggraph show commit!
authorTon Roosendaal <ton@blender.org>
Mon, 31 Jul 2006 19:23:42 +0000 (19:23 +0000)
committerTon Roosendaal <ton@blender.org>
Mon, 31 Jul 2006 19:23:42 +0000 (19:23 +0000)
- pending commit for OSX intel systems, with intel graphics. These now call
  an extra swapbuffers after glFlush(). Code is ifdeffed, and doesnt affect
  other systems.

- show-off commit: option to have transparent nodes over the composite
  result. Only draws Image for active Viewer Node now, and image doesnt
  translate nor zoom (which isnt bad though).
  Set in themes the alpha color of "node backdrop" to make nodes
  transparent.

18 files changed:
source/blender/include/BIF_glutil.h
source/blender/include/BIF_screen.h
source/blender/makesdna/DNA_space_types.h
source/blender/src/drawnode.c
source/blender/src/drawobject.c
source/blender/src/drawtext.c
source/blender/src/editmesh_loop.c
source/blender/src/editmesh_mods.c
source/blender/src/editmesh_tools.c
source/blender/src/editscreen.c
source/blender/src/editsima.c
source/blender/src/editview.c
source/blender/src/glutil.c
source/blender/src/header_node.c
source/blender/src/interface.c
source/blender/src/previewrender.c
source/blender/src/space.c
source/blender/src/transform.c

index 48d4d903d286ebcf7d62962dff68c9da3c7785f0..db2b55aab8632e2415d7db34bd014409e962b15b 100644 (file)
@@ -198,12 +198,14 @@ void gla2DGetMap(gla2DDrawInfo *di, struct rctf *rect);
 void gla2DSetMap(gla2DDrawInfo *di, struct rctf *rect);
 
 
-/* use this for platform hacks. for now glPointSize is solved here */
+/* use this for platform hacks. glPointSize is solved here */
 void bglBegin(int mode);
 void bglEnd(void);
 void bglVertex3fv(float *vec);
 void bglVertex3f(float x, float y, float z);
 void bglVertex2fv(float *vec);
+/* intel gfx cards frontbuffer problem */
+void bglFlush(void);
 
 void set_inverted_drawing(int enable);
 
index c76f961014a17f082a4e81e56a1215fd9cfb1ba6..e97d10b2455c4f5f99a31276adac276c843a5414 100644 (file)
@@ -125,12 +125,6 @@ int do_screenhandlers(struct bScreen *sc);
 int has_screenhandler(struct bScreen *sc, short eventcode);
 
        /***/
-       
-/**
- * Draw @a text in the header of each info window
- * of the given screen.
- */
-void screen_draw_info_text(struct bScreen *sc, char *text);
 
 /* return all layers of all 3d windows in a screen */
 unsigned int screen_view3d_layers(void);
index 105218a0cab38d63a72c1720cb21797d89cfcc4c..98ca418cddea5d046d189f47d5a10478975f9da8 100644 (file)
@@ -323,6 +323,7 @@ typedef struct SpaceNode {
 
 /* snode->flag */
 #define SNODE_DO_PREVIEW       1
+#define SNODE_BACKDRAW         2
 
 #
 #
index 0fc2b207f5b6d1ccfd1e24acfe5b7de73a102f3e..81b2433ee8ea5d8f709811563203e352e2c6e857 100644 (file)
@@ -37,6 +37,7 @@
 #include "DNA_action_types.h"
 #include "DNA_ipo_types.h"
 #include "DNA_ID.h"
+#include "DNA_image_types.h"
 #include "DNA_material_types.h"
 #include "DNA_node_types.h"
 #include "DNA_object_types.h"
@@ -76,6 +77,7 @@
 #include "MEM_guardedalloc.h"
 
 #include "RE_pipeline.h"
+#include "IMB_imbuf_types.h"
 
 #include "blendef.h"
 #include "butspace.h"
@@ -1117,6 +1119,33 @@ static void draw_nodespace_grid(SpaceNode *snode)
        glEnd();
 }
 
+static void draw_nodespace_back(ScrArea *sa, SpaceNode *snode)
+{
+       Image *ima;
+       
+       draw_nodespace_grid(snode);
+       
+       if(snode->flag & SNODE_BACKDRAW) {
+               ima= (Image *)find_id("IM", "Viewer Node");
+               if(ima && ima->ibuf) {
+                       /* somehow the offset has to be calculated inverse */
+                       
+                       glaDefine2DArea(&sa->winrct);
+                       /* ortho at pixel level curarea */
+                       myortho2(-0.375, sa->winx-0.375, -0.375, sa->winy-0.375);
+
+                       if(ima->ibuf->rect)
+                               glaDrawPixelsSafe((sa->winx-ima->ibuf->x)/2, (sa->winy-ima->ibuf->y)/2, ima->ibuf->x, ima->ibuf->y, ima->ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ima->ibuf->rect);
+                       else
+                               glaDrawPixelsSafe((sa->winx-ima->ibuf->x)/2, (sa->winy-ima->ibuf->y)/2, ima->ibuf->x, ima->ibuf->y, ima->ibuf->x, GL_RGBA, GL_FLOAT, ima->ibuf->rect_float);
+                       
+                       /* sort this out, this should not be needed */
+                       myortho2(snode->v2d.cur.xmin, snode->v2d.cur.xmax, snode->v2d.cur.ymin, snode->v2d.cur.ymax);
+                       bwin_clear_viewmat(sa->win);    /* clear buttons view */
+                       glLoadIdentity();
+               }
+       }
+}
 
 static void nodeshadow(rctf *rct, float radius, float aspect, int select)
 {
@@ -1545,9 +1574,11 @@ static void node_draw_basis(ScrArea *sa, SpaceNode *snode, bNode *node)
        snode_drawstring(snode, node->name, (int)(iconofs - rct->xmin-18.0f));
                                         
        /* body */
-       BIF_ThemeColor(TH_NODE);        
+       BIF_ThemeColor4(TH_NODE);
+       glEnable(GL_BLEND);
        uiSetRoundBox(8);
        uiRoundBox(rct->xmin, rct->ymin, rct->xmax, rct->ymax-NODE_DY, BASIS_RAD);
+       glDisable(GL_BLEND);
        
        /* scaling indicator */
        node_scaling_widget(TH_NODE, snode->aspect, rct->xmax-BASIS_RAD*snode->aspect, rct->ymin, rct->xmax, rct->ymin+BASIS_RAD*snode->aspect);
@@ -1958,7 +1989,7 @@ void drawnodespace(ScrArea *sa, void *spacedata)
        snode->curfont= uiSetCurFont_ext(snode->aspect);
 
        /* backdrop */
-       draw_nodespace_grid(snode);
+       draw_nodespace_back(sa, snode);
        
        /* nodes */
        snode_set_context(snode);
index 9d990f97d16bb3ce67e6835ccba57165ab318eeb..53337651249c1fab91d7d35e5957b1509c787b48 100644 (file)
@@ -4069,7 +4069,7 @@ void draw_object_ext(Base *base)
        
        G.f &= ~G_DRAW_EXT;
 
-       glFlush();              /* reveil frontbuffer drawing */
+       bglFlush();             /* reveil frontbuffer drawing */
        glDrawBuffer(GL_BACK);
        
        if(G.vd->zbuf) {
index 5025b08de1eee84dcc125b77ca5e99fc98fa5806..c2c6aa89e7d36bb9435299d6da4d70ad0df1aa6d 100644 (file)
@@ -64,6 +64,7 @@
 #include "BKE_main.h"
 
 #include "BIF_gl.h"
+#include "BIF_glutil.h"
 #include "BIF_keyval.h"
 #include "BIF_interface.h"
 #include "BIF_drawtext.h"
@@ -820,6 +821,7 @@ static void do_textscroll(SpaceText *st, int mode)
 
        glDrawBuffer(GL_FRONT);
        uiEmboss(st->txtbar.xmin, st->txtbar.ymin, st->txtbar.xmax, st->txtbar.ymax, st->flags & ST_SCROLL_SELECT);
+       bglFlush();
        glDrawBuffer(GL_BACK);
 
        getmouseco_areawin(mval);
@@ -857,6 +859,7 @@ static void do_textscroll(SpaceText *st, int mode)
 
        glDrawBuffer(GL_FRONT);
        uiEmboss(st->txtbar.xmin, st->txtbar.ymin, st->txtbar.xmax, st->txtbar.ymax, st->flags & ST_SCROLL_SELECT);
+       bglFlush();
        glDrawBuffer(GL_BACK);
 }
 
index 609b68b5cf5b6a88c660152291d4e58fd21cff19..8a88e40cb78c7139269f4ee51a8b84ac0796bb70 100644 (file)
@@ -506,7 +506,7 @@ static CutCurve *get_mouse_trail(int *len, char mode)
                if( event==ESCKEY || event==RIGHTMOUSE ) {
                        if (curve) MEM_freeN(curve);
                        *len=0;
-                       glFlush();
+                       bglFlush();
                        glDrawBuffer(GL_BACK);
                        return(NULL);
                        break;
@@ -586,7 +586,7 @@ static CutCurve *get_mouse_trail(int *len, char mode)
                }
        }
 
-       glFlush();
+       bglFlush();
        glDrawBuffer(GL_BACK);
        persp(PERSP_VIEW);
 
index ba6dce0001f5966c4500e46fd0233195c9fe7269..57b481e31914afd61280dfb5178df62d7e9bb10e 100644 (file)
@@ -696,7 +696,7 @@ static void unified_select_draw(EditVert *eve, EditEdge *eed, EditFace *efa)
        glPointSize(1.0);
        glPopMatrix();
 
-       glFlush();
+       bglFlush();
        glDrawBuffer(GL_BACK);
 
        if(G.vd->flag & V3D_CLIPPING)
index d7bcf39a1cfc68c64c69623069bc359e5d41e1e7..3ce7ef4cd1601e95d8400ef63e9da1ad8591ce64 100644 (file)
@@ -75,6 +75,7 @@ editmesh_tool.c: UI called tools for editmesh, geometry changes here, otherwise
 #include "BIF_cursors.h"
 #include "BIF_editmesh.h"
 #include "BIF_gl.h"
+#include "BIF_glutil.h"
 #include "BIF_graphics.h"
 #include "BIF_interface.h"
 #include "BIF_mywindow.h"
@@ -4583,7 +4584,7 @@ void bevel_menu()
                        setlinestyle(0);
                        
                        persp(PERSP_VIEW);
-                       glFlush(); // flush display for frontbuffer
+                       bglFlush(); // flush display for frontbuffer
                        glDrawBuffer(GL_BACK);
                }
                while(qtest()) {
index 7ae0bdfac5e89a1df6097bcaeeecb4b5ccf6ec9d..ca5037f59863824ae7a3ff1a3c80ffd2dbde3987 100644 (file)
@@ -712,7 +712,7 @@ void splash(void *data, int datasize, char *string)
                        BMF_DrawString(font, string);
                }
 
-               glFlush();
+               bglFlush();
                glDrawBuffer(GL_BACK);
                
                IMB_freeImBuf(bbuf);
@@ -2750,7 +2750,7 @@ static void joinarea_interactive(ScrArea *area, ScrEdge *onedge)
                scrarea_draw_shape_dark(scr,'d');
        else if(scr==down)
                scrarea_draw_shape_dark(scr,'u');
-       glFlush();
+       bglFlush();
 
        /* "never ending loop" of interactive selection */
        while(!ok) {
@@ -2793,7 +2793,7 @@ static void joinarea_interactive(ScrArea *area, ScrEdge *onedge)
                /* cancel joining of joining */
                if(val && (event==ESCKEY || event==RIGHTMOUSE)) ok= -1;
 
-               glFlush();
+               bglFlush();
        }
 
        glReadBuffer(GL_BACK);
@@ -3074,12 +3074,12 @@ static void splitarea_interactive(ScrArea *area, ScrEdge *onedge)
                if(val && (event==ESCKEY || event==RIGHTMOUSE)) {
                        ok= -1;
                }
-               glFlush();
+               bglFlush();
        }
 
        if (!first) {
                scrarea_draw_splitpoint(sa, dir, fac);
-               glFlush();
+               bglFlush();
        }
        glReadBuffer(GL_BACK);
        glDrawBuffer(GL_BACK);
@@ -3390,7 +3390,7 @@ static void moveareas(ScrEdge *edge)
                        delta= (dir=='h')?(mval[1]-mvalo[1]):(mval[0]-mvalo[0]);
                        delta= CLAMPIS(delta, -smaller, bigger);
                        draw_front_xor_dirdist_line(dir, edge_position+delta, edge_start, edge_end);
-                       glFlush();
+                       bglFlush();
                } 
                else if (event==LEFTMOUSE) {
                        doit= 1;
@@ -3405,7 +3405,7 @@ static void moveareas(ScrEdge *edge)
                
        }
        draw_front_xor_dirdist_line(dir, edge_position+delta, edge_start, edge_end);
-       glFlush();
+       bglFlush();
        glReadBuffer(GL_BACK);
        glDrawBuffer(GL_BACK);
 
@@ -3638,47 +3638,6 @@ void initscreen(void)
        default_twosplit();
 }
 
-/***/
-
-void screen_draw_info_text(bScreen *sc, char *text) {
-       Window *oldactwin= winlay_get_active_window();
-       ScrArea *sa;
-       
-               /*
-                * Because this is called from within rendering
-                * internals it is possible our window is not
-                * active.
-                */
-       window_make_active(mainwin);
-       
-       for (sa= sc->areabase.first; sa; sa= sa->next) {
-               if (sa->spacetype==SPACE_INFO) {
-                       int x= sa->headbutlen - 28;
-                       int y= 6;
-                       
-                       areawinset(sa->headwin);
-                       glDrawBuffer(GL_FRONT);
-
-                       cpack(0xA08060);
-                       glRecti(x-11,  y-6,  x+55,  y+13);
-                       
-                       cpack(0x909090);
-                       glRecti(x+55,  y-6,  x+1280,  y+14);
-                       
-                       cpack(0x0);
-                       glRasterPos2i(x,  y);
-                       BMF_DrawString(G.fonts, text);
-                       
-                       glFlush();
-                       glDrawBuffer(GL_BACK);
-                       
-                       sa->head_swap= WIN_FRONT_OK;
-               }
-       }
-       
-       if (oldactwin && oldactwin!=mainwin) window_make_active(oldactwin);
-}
-
 static int curcursor;
 
 int get_cursor(void) {
index 6785a0e607fc243976f12c56c4f8880aa3d8f19f..25454eece409413851bc5e119d6c52b2a6f392d9 100644 (file)
@@ -68,6 +68,7 @@
 #include "BKE_utildefines.h"
 
 #include "BIF_gl.h"
+#include "BIF_glutil.h"
 #include "BIF_interface.h"
 #include "BIF_screen.h"
 #include "BIF_drawimage.h"
@@ -911,6 +912,7 @@ void uvedit_selectionCB(short selecting, Object *editobj, short *mval, float rad
                else { /* force_draw() is no good here... */
                        glDrawBuffer(GL_FRONT);
                        draw_tfaces();
+                       bglFlush();
                        glDrawBuffer(GL_BACK);
                }
        }       
index c5bf0e9c48738a25c174cdbc42d8120eca335a5d..19a644c5c7bcdc5961046448d842a684b150d6d4 100644 (file)
@@ -766,7 +766,7 @@ int gesture(void)
                                if(i) {
                                        if(lasso) draw_lasso_select(mcords, i, 0);
                                        else sdrawXORline(mcords[i-1][0], mcords[i-1][1], mcords[i][0], mcords[i][1]);
-                                       glFlush();
+                                       bglFlush();
                                }
                                i++;
                        }
@@ -1777,7 +1777,7 @@ void borderselect(void)
                        }
                }
                /* frontbuffer flush */
-               glFlush();
+               bglFlush();
 
                MEM_freeN(vbuffer);
                
index ef6728c1a0a32f791b2db43c5c75cf6e8388dae0..dced81579c3ec31336ab852a7e0ed432f8c81af6 100644 (file)
@@ -32,6 +32,7 @@
  * ***** END GPL/BL DUAL LICENSE BLOCK *****
  */
 
+#include <stdio.h>
 #include <math.h>
 
 #include "MEM_guardedalloc.h"
@@ -46,6 +47,7 @@
 
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
+#include "BIF_mywindow.h"
 
        /* Invert line handling */
        
@@ -621,6 +623,24 @@ void bglPolygonOffset(float dist)
        }
 }
 
+static int is_a_really_crappy_intel_card(void)
+{
+       static int well_is_it= -1;
+
+               /* Do you understand the implication? Do you? */
+       if (well_is_it==-1)
+               well_is_it= (strcmp((char*) glGetString(GL_VENDOR), "Intel Inc.") == 0);
+
+       return well_is_it;
+}
 
+void bglFlush(void) 
+{
+       glFlush();
+#ifdef __APPLE__
+       if(is_a_really_crappy_intel_card())
+               myswapbuffers(); //hack to get mac intel graphics to show frontbuffer
+#endif
+}
 
 
index 91e421736f218d1fef6071a2cd28ed6c5c57f156..d639d9b0beae4b179eac6af3f2bfde1c2409228b 100644 (file)
@@ -602,6 +602,8 @@ void node_buttons(ScrArea *sa)
                xco+= 80;
                uiDefButBitS(block, TOG, R_COMP_FREE, B_NOP, "Free Unused", xco+5,0,80,19, &G.scene->r.scemode, 0.0f, 0.0f, 0, 0, "Free Nodes that are not used while composite");
                xco+= 80;
+               uiDefButBitS(block, TOG, SNODE_BACKDRAW, B_NOP, "Backdrop", xco+5,0,80,19, &snode->flag, 0.0f, 0.0f, 0, 0, "Use active Viewer Node output as backdrop");
+               xco+= 80;
        }
        
        /* always as last  */
index b456e1d315c748fab1332c6a908e4e2e5bb5f8a9..3a4a15a723a20df985148b3bde9b46304a3ab727 100644 (file)
@@ -300,18 +300,6 @@ static uiOverDraw *ui_begin_overdraw(int minx, int miny, int maxx, int maxy)
        return od;
 }
 
-#ifdef __APPLE__
-static int is_a_really_crappy_intel_card(void) {
-       static int well_is_it= -1;
-
-               /* Do you understand the implication? Do you? */
-       if (well_is_it==-1)
-               well_is_it= (strcmp((char*) glGetString(GL_VENDOR), "Intel Inc.") == 0);
-
-       return well_is_it;
-}
-#endif
-
 static void ui_flush_overdraw(uiOverDraw *od)
 {
 
@@ -322,11 +310,7 @@ static void ui_flush_overdraw(uiOverDraw *od)
        glRasterPos2s(od->x, od->y);
        myglCopyPixels(od->x, od->y, od->sx, od->sy, GL_COLOR);
        glEnable(GL_DITHER);
-       glFlush();
-#ifdef __APPLE__
-       if (is_a_really_crappy_intel_card())
-               myswapbuffers(); //hack to get mac intel graphics to show menus
-#endif
+       bglFlush();
        glDrawBuffer(GL_BACK);
 }
 
@@ -371,7 +355,7 @@ static void ui_end_overdraw(uiOverDraw *od)
        glRasterPos2s(od->x, od->y);
        glDrawPixels(od->sx, od->sy, GL_RGBA, GL_UNSIGNED_BYTE, od->rect);
 
-       glFlush();
+       bglFlush();
        glDrawBuffer(GL_BACK);
        glEnable(GL_DITHER);
        
@@ -394,7 +378,7 @@ void ui_block_flush_back(uiBlock *block)
 
        /* exception, when we cannot use backbuffer for draw... */
        if(block->flag & UI_BLOCK_FRONTBUFFER) {
-               glFlush();
+               bglFlush();
                glDrawBuffer(GL_BACK);
                block->needflush= 0;
                return;
@@ -423,7 +407,7 @@ void ui_block_flush_back(uiBlock *block)
                myglCopyPixels(minx, miny, sizex, sizey, GL_COLOR);
 #endif
                glEnable(GL_DITHER);
-               glFlush();
+               bglFlush();
                glDrawBuffer(GL_BACK);
 
                mywinset(block->win);
@@ -4051,7 +4035,7 @@ static void ui_do_active_linklines(uiBlock *block, short *mval)
                        }
                        but= but->next;
                }
-               glFlush();
+               bglFlush();
                glDrawBuffer(GL_BACK);
        }
 }
index 5bf0a2954033e3b137135049a1a32c0b72a4e82a..a6e0d2ef27e571937b51df06d47293300009bf3c 100644 (file)
@@ -382,7 +382,7 @@ static void previewrender_progress(RenderResult *rr, volatile rcti *renrect)
        
        glDrawBuffer(GL_FRONT);
        glaDrawPixelsSafe_to32(ofsx, ofsy, rr->rectx, rr->recty, rr->rectx, rl->rectf);
-       glFlush();
+       bglFlush();
        glDrawBuffer(GL_BACK);
 }
 
@@ -626,7 +626,7 @@ static void view3d_previewrender_progress(RenderResult *rr, volatile rcti *renre
        glDrawBuffer(GL_FRONT);
        glaDefine2DArea(&curarea->winrct);
        glaDrawPixelsSafe_to32(ofsx, ofsy, rr->rectx, rr->recty, rr->rectx, rl->rectf);
-       glFlush();
+       bglFlush();
        glDrawBuffer(GL_BACK);
 
 }
index aa3536ec2baf35904ff5668e2243b1eda1b08497..91d67ceb5d0f278e25fe3c75394f106534a1bdcc 100644 (file)
@@ -2421,7 +2421,7 @@ static void info_user_themebuts(uiBlock *block, short y1, short y2, short y3)
        }
        else {
                uiBlockBeginAlign(block);
-               if ELEM7(th_curcol, TH_PANEL, TH_LAMP, TH_FACE, TH_FACE_SELECT, TH_MENU_BACK, TH_MENU_HILITE, TH_MENU_ITEM) {
+               if ELEM8(th_curcol, TH_PANEL, TH_LAMP, TH_FACE, TH_FACE_SELECT, TH_MENU_BACK, TH_MENU_HILITE, TH_MENU_ITEM, TH_NODE) {
                        uiDefButC(block, NUMSLI, B_UPDATE_THEME,"A ",   465,y3+25,200,20,  col+3, 0.0, 255.0, B_THEMECOL, 0, "");
                }
                uiDefButC(block, NUMSLI, B_UPDATE_THEME,"R ",   465,y3,200,20,  col, 0.0, 255.0, B_THEMECOL, 0, "");
index f450628b64027ebe25680e468644c45fa7690342..76e6c7eaf51c12e70952c7ea73bf4a4173156617 100755 (executable)
@@ -64,6 +64,7 @@
 
 #include "BIF_editview.h"              /* arrows_move_cursor   */
 #include "BIF_gl.h"
+#include "BIF_glutil.h"
 #include "BIF_mywindow.h"
 #include "BIF_resources.h"
 #include "BIF_screen.h"
@@ -135,7 +136,7 @@ static void helpline(TransInfo *t, float *vec)
                setlinestyle(0);
                
                persp(PERSP_VIEW);
-               glFlush(); // flush display for frontbuffer
+               bglFlush(); // flush display for frontbuffer
                glDrawBuffer(GL_BACK);
        }
 }