From 51c8bb6077e0b291aa01c1e4338e0c944a45853a Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Wed, 11 Jun 2003 15:43:20 +0000 Subject: [PATCH] - OSX bugfix: drawing selection code for vpaint and faceselect happens in AUX buffers now. It only works nice at OSX (tested, linux and windows do not support it nicely) This fixes the annoying flashing during paint or select --- source/blender/src/drawview.c | 8 +++++++- source/blender/src/editface.c | 17 ++++++++++++++--- source/blender/src/editscreen.c | 5 +++-- source/blender/src/ghostwinlay.c | 9 +++++++-- source/blender/src/swapbuffers.c | 5 +++-- source/blender/src/vpaint.c | 15 ++++++++++++--- 6 files changed, 46 insertions(+), 13 deletions(-) diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index 8b4a6ce3477..e41659ddaf8 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -703,7 +703,9 @@ void backdrawview3d(int test) return; } } - +#ifdef __APPLE__ + glDrawBuffer(GL_AUX0); +#endif if(G.vd->drawtype > OB_WIRE) G.zbuf= TRUE; curarea->win_swap &= ~WIN_BACK_OK; @@ -758,6 +760,10 @@ void backdrawview3d(int test) G.zbuf= FALSE; glDisable(GL_DEPTH_TEST); glEnable(GL_DITHER); + +#ifdef __APPLE__ + glDrawBuffer(GL_BACK); /* we were in aux buffers */ +#endif } diff --git a/source/blender/src/editface.c b/source/blender/src/editface.c index 2e2426f74b4..bf4d030d00b 100644 --- a/source/blender/src/editface.c +++ b/source/blender/src/editface.c @@ -445,8 +445,13 @@ TFace* face_pick(Mesh *me, short x, short y) backdrawview3d(0); } /* Read the pixel under the cursor */ +#ifdef __APPLE__ + glReadBuffer(GL_AUX0); +#endif glReadPixels(x+curarea->winrct.xmin, y+curarea->winrct.ymin, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &col); + glReadBuffer(GL_BACK); + /* Unbelievable! */ if (G.order==B_ENDIAN) { SWITCH_INT(col); @@ -532,9 +537,12 @@ void face_borderselect() val= get_border(&rect, 3); - /* why readbuffer here? shouldn't be necessary */ - glReadBuffer(GL_BACK); - + /* why readbuffer here? shouldn't be necessary (maybe a flush or so) */ + glReadBuffer(GL_BACK); +#ifdef __APPLE__ + glReadBuffer(GL_AUX0); /* apple only */ +#endif + if(val) { selar= MEM_callocN(me->totface+1, "selar"); @@ -571,6 +579,9 @@ void face_borderselect() allqueue(REDRAWVIEW3D, 0); allqueue(REDRAWIMAGE, 0); } +#ifdef __APPLE__ + glReadBuffer(GL_BACK); +#endif } #define TEST_STRUBI 1 diff --git a/source/blender/src/editscreen.c b/source/blender/src/editscreen.c index b5dcc3e701f..4226bf759c5 100644 --- a/source/blender/src/editscreen.c +++ b/source/blender/src/editscreen.c @@ -903,6 +903,7 @@ void screenmain(void) { int has_input= 1; int firsttime = 1; + while (1) { unsigned short event; short val, towin; @@ -917,7 +918,7 @@ void screenmain(void) } window_make_active(mainwin); - + if (event==INPUTCHANGE) { has_input= val; } @@ -1638,7 +1639,7 @@ void add_to_mainqueue(Window *win, void *user_data, short evt, short val, char a statechanged= 1; - if (U.flag&NONUMPAD) { + if (U.flag & NONUMPAD) { evt= convert_for_nonumpad(evt); } diff --git a/source/blender/src/ghostwinlay.c b/source/blender/src/ghostwinlay.c index 9bafb53a190..8d6ce0c995d 100644 --- a/source/blender/src/ghostwinlay.c +++ b/source/blender/src/ghostwinlay.c @@ -485,9 +485,14 @@ static int event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) { /* * XXX quick hack so OSX version works better - * when the window is clicked on (focused). + * when the window is clicked on (focused). + * + * it used to pass on the old win->lmouse value, + * which causes a wrong click in Blender. + * Actually, a 'focus' click should not be passed + * on to blender... (ton) */ - if(1) { + if(1) { /* enables me to add locals */ int cx, cy, wx, wy; GHOST_GetCursorPosition(g_system, &wx, &wy); diff --git a/source/blender/src/swapbuffers.c b/source/blender/src/swapbuffers.c index c0776b1934d..be3523e67ad 100644 --- a/source/blender/src/swapbuffers.c +++ b/source/blender/src/swapbuffers.c @@ -109,13 +109,14 @@ static void screen_swapbuffers_REDRAW(bScreen *sc) sa= sa->next; } if(sa==0) return; - + sa= sc->areabase.first; while(sa) { - swap= sa->win_swap; if( (swap & WIN_BACK_OK) == 0) { + scrarea_do_windraw(sa); + doswap= 1; sa->win_swap= swap | WIN_BACK_OK; } diff --git a/source/blender/src/vpaint.c b/source/blender/src/vpaint.c index c3de918ab00..b865e66e05d 100644 --- a/source/blender/src/vpaint.c +++ b/source/blender/src/vpaint.c @@ -596,8 +596,12 @@ static int sample_backbuf_area(int x, int y) y2= y+Gvp.size; CLAMP(y1, 0, curarea->winy); CLAMP(y2, 0, curarea->winy); - +#ifdef __APPLE__ + glReadBuffer(GL_AUX0); +#endif glReadPixels(x1+curarea->winrct.xmin, y1+curarea->winrct.ymin, x2-x1+1, y2-y1+1, GL_RGBA, GL_UNSIGNED_BYTE, rect); + glReadBuffer(GL_BACK); + if(G.order==B_ENDIAN) IMB_convert_rgba_to_abgr( (int)(4*Gvp.size*Gvp.size), rect); rt= rect; @@ -632,8 +636,13 @@ static unsigned int sample_backbuf(int x, int y) x+= curarea->winrct.xmin; y+= curarea->winrct.ymin; - + +#ifdef __APPLE__ + glReadBuffer(GL_AUX0); +#endif glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &col); + glReadBuffer(GL_BACK); + if(G.order==B_ENDIAN) SWITCH_INT(col); return framebuffer_to_index(col); @@ -1074,8 +1083,8 @@ void vertex_paint() scrarea_do_windraw(curarea); screen_swapbuffers(); - backdrawview3d(0); draw_sel_circle(mval, 0, Gvp.size, Gvp.size, 0); + backdrawview3d(0); mvalo[0]= mval[0]; mvalo[1]= mval[1];