diff options
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_types.h | 10 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_dragdrop.c | 17 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_draw.c | 43 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 35 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_gesture.c | 170 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 55 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 86 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_playanim.c | 6 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_subwindow.c | 81 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 10 | ||||
-rw-r--r-- | source/blender/windowmanager/wm_event_types.h | 13 |
13 files changed, 344 insertions, 186 deletions
diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index 65a8945f82b..a3cfbf00f3d 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -44,6 +44,7 @@ set(INC ../../../intern/guardedalloc ../../../intern/memutil ../../../intern/opennl/extern + ../../../intern/touch ) set(INC_SYS diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index c53c4dca74c..9a3b8513810 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -274,7 +274,7 @@ int WM_gesture_lines_cancel(struct bContext *C, struct wmOperator *op); int WM_gesture_lasso_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event); int WM_gesture_lasso_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event); int WM_gesture_lasso_cancel(struct bContext *C, struct wmOperator *op); -const int (*WM_gesture_lasso_path_to_array(struct bContext *C, struct wmOperator *op, int *mcords_tot))[2]; +int (*WM_gesture_lasso_path_to_array(struct bContext *C, struct wmOperator *op, int *mcords_tot))[2]; int WM_gesture_straightline_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event); int WM_gesture_straightline_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event); int WM_gesture_straightline_cancel(struct bContext *C, struct wmOperator *op); @@ -310,6 +310,7 @@ void wmOrtho2 (float x1, float x2, float y1, float y2); /* utilities */ void WM_framebuffer_index_set(int index); +void WM_set_framebuffer_index_current_color(int index); int WM_framebuffer_to_index(unsigned int col); /* threaded Jobs Manager */ diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 094df73bbd9..04763e44581 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -442,7 +442,7 @@ typedef struct wmEvent { const char *keymap_idname; /* custom data */ - short custom; /* custom data type, stylus, 6dof, see wm_event_types.h */ + short customdatatype; /* custom data type, stylus, 6dof, see wm_event_types.h */ short customdatafree; int pad2; void *customdata; /* ascii, unicode, mouse coords, angles, vectors, dragdrop info */ @@ -483,6 +483,14 @@ typedef struct wmNDOFMotionData { wmProgress progress; /* is this the first event, the last, or one of many in between? */ } wmNDOFMotionData; +typedef struct wmTouchData { + /* 1:1 copy of GHOST_TEventTouchData */ + wmProgress state; + unsigned char index; + int x; + int y; +} wmTouchData; + typedef struct wmTimer { struct wmTimer *next, *prev; diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index 0581000e07c..0b58009ebcc 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -40,7 +40,9 @@ #include "BLI_blenlib.h" -#include "BIF_gl.h" +#include "GPU_compatibility.h" +#include "GPU_colors.h" + #include "BIF_glutil.h" #include "BKE_blender.h" @@ -257,13 +259,12 @@ void wm_drags_check_ops(bContext *C, wmEvent *event) static void wm_drop_operator_draw(const char *name, int x, int y) { int width = UI_GetStringWidth(name); - - glColor4ub(0, 0, 0, 50); - + + gpuCurrentColor4x(CPACK_BLACK, 0.196f); uiSetRoundBox(UI_CNR_ALL | UI_RB_ALPHA); uiRoundBox(x, y, x + width + 8, y + 15, 4); - - glColor4ub(255, 255, 255, 255); + + gpuCurrentColor3x(CPACK_WHITE); UI_DrawString(x + 4, y + 4, name); } @@ -322,7 +323,7 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) if (rect) drag_rect_minmax(rect, x, y, x + drag->sx, y + drag->sy); else { - glColor4f(1.0, 1.0, 1.0, 0.65); /* this blends texture */ + gpuCurrentColor4x(CPACK_WHITE, 0.650f); /* this blends texture */ glaDrawPixelsTexScaled(x, y, drag->imb->x, drag->imb->y, GL_UNSIGNED_BYTE, drag->imb->rect, drag->scale, drag->scale); } } @@ -352,7 +353,7 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) drag_rect_minmax(rect, x, y, x + w, y + 16); } else { - glColor4ub(255, 255, 255, 255); + gpuCurrentColor3x(CPACK_WHITE); UI_DrawString(x, y, wm_drag_name(drag)); } diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 60e3f7d6164..ad19df3aaf6 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -31,7 +31,9 @@ #include <stdlib.h> #include <string.h> -#include <GL/glew.h> + +#include "GPU_compatibility.h" +#include "GPU_colors.h" #include "DNA_listBase.h" #include "DNA_screen_types.h" @@ -45,8 +47,6 @@ #include "BLI_utildefines.h" #include "BLI_math_base.h" -#include "BIF_gl.h" - #include "BKE_context.h" #include "BKE_global.h" @@ -57,6 +57,8 @@ #include "GPU_draw.h" #include "GPU_extensions.h" +#include "BIF_glutil.h" + #include "RE_engine.h" #include "WM_api.h" @@ -519,20 +521,25 @@ static void wm_triple_draw_textures(wmWindow *win, wmDrawTriple *triple) glBindTexture(triple->target, triple->bind[x + y * triple->nx]); - glColor3f(1.0f, 1.0f, 1.0f); - glBegin(GL_QUADS); - glTexCoord2f(halfx, halfy); - glVertex2f(offx, offy); + gpuCurrentColor3x(CPACK_WHITE); + + gpuImmediateFormat_T2_V2(); // DOODLE: triple backbuffer - glTexCoord2f(ratiox + halfx, halfy); - glVertex2f(offx + sizex, offy); + gpuBegin(GL_TRIANGLE_FAN); + gpuTexCoord2f(halfx, halfy); + gpuVertex2f(offx, offy); - glTexCoord2f(ratiox + halfx, ratioy + halfy); - glVertex2f(offx + sizex, offy + sizey); + gpuTexCoord2f(ratiox + halfx, halfy); + gpuVertex2f(offx + sizex, offy); - glTexCoord2f(halfx, ratioy + halfy); - glVertex2f(offx, offy + sizey); - glEnd(); + gpuTexCoord2f(ratiox + halfx, ratioy + halfy); + gpuVertex2f(offx + sizex, offy + sizey); + + gpuTexCoord2f(halfx, ratioy + halfy); + gpuVertex2f(offx, offy + sizey); + gpuEnd(); + + gpuImmediateUnformat(); } } @@ -567,8 +574,8 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win) int copytex = 0, paintcursor = 1; if (win->drawdata) { - glClearColor(0, 0, 0, 0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + gpuSetClearColor(0, 0, 0, 0); + gpuClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); wmSubWindowSet(win, screen->mainwin); @@ -770,6 +777,9 @@ void wm_draw_update(bContext *C) drawmethod = wm_automatic_draw_method(win); +#ifdef GLES + wm_method_draw_full(C, win); +#else if (win->drawfail) wm_method_draw_overlap_all(C, win, 0); else if (drawmethod == USER_DRAW_FULL) @@ -780,6 +790,7 @@ void wm_draw_update(bContext *C) wm_method_draw_overlap_all(C, win, 1); else // if (drawmethod == USER_DRAW_TRIPLE) wm_method_draw_triple(C, win); +#endif win->screen->do_draw_gesture = FALSE; win->screen->do_draw_paintcursor = FALSE; diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 14244de00f6..551f9157dfe 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -41,6 +41,7 @@ #include "MEM_guardedalloc.h" #include "GHOST_C-api.h" +#include "TOUCH_API.h" #include "BLI_blenlib.h" #include "BLI_utildefines.h" @@ -100,7 +101,7 @@ void wm_event_free(wmEvent *event) if (event->customdata) { if (event->customdatafree) { /* note: pointer to listbase struct elsewhere */ - if (event->custom == EVT_DATA_LISTBASE) + if (event->customdatatype == EVT_DATA_LISTBASE) BLI_freelistN(event->customdata); else MEM_freeN(event->customdata); @@ -1810,7 +1811,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers wmDropBox *drop = handler->dropboxes->first; for (; drop; drop = drop->next) { /* other drop custom types allowed */ - if (event->custom == EVT_DATA_LISTBASE) { + if (event->customdatatype == EVT_DATA_LISTBASE) { ListBase *lb = (ListBase *)event->customdata; wmDrag *drag; @@ -1822,7 +1823,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers /* free the drags before calling operator */ BLI_freelistN(event->customdata); event->customdata = NULL; - event->custom = 0; + event->customdatatype = 0; WM_operator_name_call(C, drop->ot->idname, drop->opcontext, drop->ptr); action |= WM_HANDLER_BREAK; @@ -2031,7 +2032,7 @@ static void wm_event_drag_test(wmWindowManager *wm, wmWindow *win, wmEvent *even MEM_freeN(event->customdata); } - event->custom = EVT_DATA_LISTBASE; + event->customdatatype = EVT_DATA_LISTBASE; event->customdata = &wm->drags; event->customdatafree = 1; @@ -2630,7 +2631,7 @@ static void update_tablet_data(wmWindow *win, wmEvent *event) wmtab->Xtilt = td->Xtilt; wmtab->Ytilt = td->Ytilt; - event->custom = EVT_DATA_TABLET; + event->customdatatype = EVT_DATA_TABLET; event->customdata = wmtab; event->customdatafree = 1; } @@ -2674,7 +2675,7 @@ static void attach_ndof_data(wmEvent *event, const GHOST_TEventNDOFMotionData *g data->progress = (wmProgress) ghost->progress; - event->custom = EVT_DATA_NDOF_MOTION; + event->customdatatype = EVT_DATA_NDOF_MOTION; event->customdata = data; event->customdatafree = 1; } @@ -3015,7 +3016,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U case GHOST_kEventTimer: { event.type = TIMER; - event.custom = EVT_DATA_TIMER; + event.customdatatype = EVT_DATA_TIMER; event.customdata = customdata; event.val = 0; event.keymodifier = 0; @@ -3052,7 +3053,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U break; } - event.custom = 0; + event.customdatatype = 0; event.customdata = NULL; wm_event_add(win, &event); @@ -3060,6 +3061,24 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U break; } + case GHOST_kEventTouch: { + GHOST_TEventTouchData *e = customdata; + wmTouchData *data= MEM_mallocN(sizeof(wmTouchData), "customdata Touch"); + + data->state = (wmProgress)e->state; + data->index = (unsigned char)e->index; + data->x = (int)e->x; + data->y = (int)e->y; + + event.type = TOUCH; + event.customdatatype = EVT_DATA_TOUCH; + event.customdata = data; + event.customdatafree = 1; + + wm_event_add(win, &event); + break; + } + case GHOST_kEventUnknown: case GHOST_kNumEventTypes: break; diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index b3ffb80243a..a586c3a4659 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -52,8 +52,9 @@ #include "wm_subwindow.h" #include "wm_draw.h" +#include "GPU_colors.h" +#include "GPU_primitives.h" -#include "BIF_gl.h" #include "BIF_glutil.h" @@ -167,65 +168,74 @@ int wm_gesture_evaluate(wmGesture *gesture) static void wm_gesture_draw_rect(wmGesture *gt) { rcti *rect = (rcti *)gt->customdata; - + glEnable(GL_BLEND); - glColor4f(1.0, 1.0, 1.0, 0.05); - glBegin(GL_QUADS); - glVertex2s(rect->xmax, rect->ymin); - glVertex2s(rect->xmax, rect->ymax); - glVertex2s(rect->xmin, rect->ymax); - glVertex2s(rect->xmin, rect->ymin); - glEnd(); + + gpuCurrentColor4x(CPACK_WHITE, 0.050f); + gpuBegin(GL_TRIANGLE_FAN); + gpuVertex2i(rect->xmax, rect->ymin); + gpuVertex2i(rect->xmax, rect->ymax); + gpuVertex2i(rect->xmin, rect->ymax); + gpuVertex2i(rect->xmin, rect->ymin); + gpuEnd(); + glDisable(GL_BLEND); - + glEnable(GL_LINE_STIPPLE); - glColor3ub(96, 96, 96); + + gpuCurrentGray3f(0.376f); glLineStipple(1, 0xCCCC); - sdrawbox(rect->xmin, rect->ymin, rect->xmax, rect->ymax); - glColor3ub(255, 255, 255); + gpuDrawWireRecti(rect->xmin, rect->ymin, rect->xmax, rect->ymax); + + gpuCurrentColor3x(CPACK_WHITE); glLineStipple(1, 0x3333); - sdrawbox(rect->xmin, rect->ymin, rect->xmax, rect->ymax); + gpuDrawWireRecti(rect->xmin, rect->ymin, rect->xmax, rect->ymax); + glDisable(GL_LINE_STIPPLE); } static void wm_gesture_draw_line(wmGesture *gt) { rcti *rect = (rcti *)gt->customdata; - + glEnable(GL_LINE_STIPPLE); - glColor3ub(96, 96, 96); + glLineStipple(1, 0xAAAA); - sdrawline(rect->xmin, rect->ymin, rect->xmax, rect->ymax); - glColor3ub(255, 255, 255); + gpuCurrentGray3f(0.376f); + gpuDrawLinei(rect->xmin, rect->ymin, rect->xmax, rect->ymax); + glLineStipple(1, 0x5555); - sdrawline(rect->xmin, rect->ymin, rect->xmax, rect->ymax); + gpuCurrentColor3x(CPACK_WHITE); + gpuDrawLinei(rect->xmin, rect->ymin, rect->xmax, rect->ymax); glDisable(GL_LINE_STIPPLE); - } static void wm_gesture_draw_circle(wmGesture *gt) { rcti *rect = (rcti *)gt->customdata; - glTranslatef((float)rect->xmin, (float)rect->ymin, 0.0f); + float x = (float)(rect->xmin); + float y = (float)(rect->ymin); glEnable(GL_BLEND); - glColor4f(1.0, 1.0, 1.0, 0.05); - glutil_draw_filled_arc(0.0, M_PI * 2.0, rect->xmax, 40); + + gpuCurrentColor4x(CPACK_WHITE, 0.050f); + gpuDrawDisk(x, y, rect->xmax, 40); + glDisable(GL_BLEND); - + glEnable(GL_LINE_STIPPLE); - glColor3ub(96, 96, 96); + glLineStipple(1, 0xAAAA); - glutil_draw_lined_arc(0.0, M_PI * 2.0, rect->xmax, 40); - glColor3ub(255, 255, 255); + gpuCurrentGray3f(0.376f); + gpuDrawCircle(x, y, rect->xmax, 40); + glLineStipple(1, 0x5555); - glutil_draw_lined_arc(0.0, M_PI * 2.0, rect->xmax, 40); - + gpuCurrentColor3x(CPACK_WHITE); + gpuDrawCircle(x, y, rect->xmax, 40); + glDisable(GL_LINE_STIPPLE); - glTranslatef(-rect->xmin, -rect->ymin, 0.0f); - } static void draw_filled_lasso(wmGesture *gt) @@ -235,7 +245,7 @@ static void draw_filled_lasso(wmGesture *gt) ScanFillFace *sf_tri; short *lasso = (short *)gt->customdata; int i; - + BLI_scanfill_begin(&sf_ctx); for (i = 0; i < gt->points; i++, lasso += 2) { float co[3]; @@ -250,24 +260,26 @@ static void draw_filled_lasso(wmGesture *gt) sf_vert_last = sf_vert; if (sf_vert_first == NULL) sf_vert_first = sf_vert; } - + /* highly unlikely this will fail, but could crash if (gt->points == 0) */ if (sf_vert_first) { const float zvec[3] = {0.0f, 0.0f, 1.0f}; BLI_scanfill_edge_add(&sf_ctx, sf_vert_first, sf_vert); BLI_scanfill_calc_ex(&sf_ctx, FALSE, zvec); - + glEnable(GL_BLEND); - glColor4f(1.0, 1.0, 1.0, 0.05); - glBegin(GL_TRIANGLES); + + gpuCurrentColor4x(CPACK_WHITE, 0.050f); + gpuBegin(GL_TRIANGLES); for (sf_tri = sf_ctx.fillfacebase.first; sf_tri; sf_tri = sf_tri->next) { - glVertex2fv(sf_tri->v1->co); - glVertex2fv(sf_tri->v2->co); - glVertex2fv(sf_tri->v3->co); + gpuVertex2fv(sf_tri->v1->co); + gpuVertex2fv(sf_tri->v2->co); + gpuVertex2fv(sf_tri->v3->co); } - glEnd(); + gpuEnd(); + glDisable(GL_BLEND); - + BLI_scanfill_end(&sf_ctx); } } @@ -280,43 +292,61 @@ static void wm_gesture_draw_lasso(wmGesture *gt) draw_filled_lasso(gt); glEnable(GL_LINE_STIPPLE); - glColor3ub(96, 96, 96); + glLineStipple(1, 0xAAAA); - glBegin(GL_LINE_STRIP); - for (i = 0; i < gt->points; i++, lasso += 2) - glVertex2sv(lasso); - if (gt->type == WM_GESTURE_LASSO) - glVertex2sv((short *)gt->customdata); - glEnd(); - - glColor3ub(255, 255, 255); + gpuCurrentGray3f(0.376f); + + gpuBegin(GL_LINE_STRIP); + + for (i = 0; i < gt->points; i++, lasso += 2) { + gpuVertex2sv(lasso); + } + + if (gt->type == WM_GESTURE_LASSO) { + gpuVertex2sv((short *)gt->customdata); + } + + gpuEnd(); + glLineStipple(1, 0x5555); - glBegin(GL_LINE_STRIP); + gpuCurrentColor3x(CPACK_WHITE); + + gpuBegin(GL_LINE_STRIP); + lasso = (short *)gt->customdata; - for (i = 0; i < gt->points; i++, lasso += 2) - glVertex2sv(lasso); - if (gt->type == WM_GESTURE_LASSO) - glVertex2sv((short *)gt->customdata); - glEnd(); - + for (i = 0; i < gt->points; i++, lasso += 2) { + gpuVertex2sv(lasso); + } + + if (gt->type == WM_GESTURE_LASSO) { + gpuVertex2sv((short *)gt->customdata); + } + + gpuEnd(); + glDisable(GL_LINE_STIPPLE); - } static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt) { rcti *rect = (rcti *)gt->customdata; - + glEnable(GL_LINE_STIPPLE); - glColor3ub(96, 96, 96); + glLineStipple(1, 0xCCCC); - sdrawline(rect->xmin - win->sizex, rect->ymin, rect->xmin + win->sizex, rect->ymin); - sdrawline(rect->xmin, rect->ymin - win->sizey, rect->xmin, rect->ymin + win->sizey); - - glColor3ub(255, 255, 255); + gpuCurrentGray3f(0.376f); + gpuBegin(GL_LINES); + gpuAppendLinei(rect->xmin - win->sizex, rect->ymin, rect->xmin + win->sizex, rect->ymin); + gpuAppendLinei(rect->xmin, rect->ymin - win->sizey, rect->xmin, rect->ymin + win->sizey); + gpuEnd(); + glLineStipple(1, 0x3333); - sdrawline(rect->xmin - win->sizex, rect->ymin, rect->xmin + win->sizex, rect->ymin); - sdrawline(rect->xmin, rect->ymin - win->sizey, rect->xmin, rect->ymin + win->sizey); + gpuCurrentColor3x(CPACK_WHITE); + gpuBegin(GL_LINES); + gpuAppendLinei(rect->xmin - win->sizex, rect->ymin, rect->xmin + win->sizex, rect->ymin); + gpuAppendLinei(rect->xmin, rect->ymin - win->sizey, rect->xmin, rect->ymin + win->sizey); + gpuEnd(); + glDisable(GL_LINE_STIPPLE); } @@ -324,11 +354,13 @@ static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt) void wm_gesture_draw(wmWindow *win) { wmGesture *gt = (wmGesture *)win->gesture.first; - + + gpuImmediateFormat_V2(); + for (; gt; gt = gt->next) { /* all in subwindow space */ wmSubWindowSet(win, gt->swinid); - + if (gt->type == WM_GESTURE_RECT) wm_gesture_draw_rect(gt); // else if (gt->type == WM_GESTURE_TWEAK) @@ -348,6 +380,8 @@ void wm_gesture_draw(wmWindow *win) else if (gt->type == WM_GESTURE_STRAIGHTLINE) wm_gesture_draw_line(gt); } + + gpuImmediateUnformat(); } void wm_gesture_tag_redraw(bContext *C) diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index c9f0bbffc63..122a494779c 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -109,11 +109,16 @@ #include "GPU_buffers.h" #include "GPU_extensions.h" #include "GPU_draw.h" +#include "GPU_compatibility.h" +#include "GPU_object.h" +#include "GPU_functions.h" #include "BKE_depsgraph.h" #include "BKE_sound.h" #include "COM_compositor.h" +#include "TOUCH_API.h" + static void wm_init_reports(bContext *C) { BKE_reports_init(CTX_wm_reports(C), RPT_STORE); @@ -125,12 +130,31 @@ static void wm_free_reports(bContext *C) int wm_start_with_console = 0; /* used in creator.c */ +static GPUimmediate* immediate; +static GPUindex* gindex; + /* only called once, for startup */ void WM_init(bContext *C, int argc, const char **argv) { if (!G.background) { wm_ghost_init(C); /* note: it assigns C to ghost! */ wm_init_cursor_data(); + + /* begin - init opengl compatibility layer */ + GPU_init_graphics_type(); + GPU_ms_init(); + GPU_init_object_func(); + + immediate = gpuNewImmediate(); + gpuImmediateMakeCurrent(immediate); + gpuImmediateMaxVertexCount(500000); // XXX: temporary! + + gindex = gpuNewIndex(); + gpuImmediateIndex(gindex); + gpuImmediateMaxIndexCount(500000); // XXX: temporary! + + gpuInitializeLighting(); + /* end - init opengl compatibility layer */ } GHOST_CreateSystemPaths(); wm_operatortype_init(); @@ -144,7 +168,7 @@ void WM_init(bContext *C, int argc, const char **argv) ED_file_init(); /* for fsmenu */ ED_node_init_butfuncs(); - + BLF_init(11, U.dpi); /* Please update source/gamengine/GamePlayer/GPG_ghost.cpp if you change this */ BLF_lang_init(); @@ -191,8 +215,6 @@ void WM_init(bContext *C, int argc, const char **argv) clear_matcopybuf(); ED_render_clear_mtex_copybuf(); - // glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); - ED_preview_init_dbase(); WM_read_history(); @@ -211,6 +233,23 @@ void WM_init(bContext *C, int argc, const char **argv) COM_linker_hack = COM_execute; } #endif + +#ifdef WITH_INPUT_TOUCH + { + const struct Listbase *spacetypes; + const struct Listbase *areatypes; + TOUCH_Handle touch_manager; + + touch_manager = TOUCH_InitManager(); + spacetypes = BKE_spacetypes_list(); + + for (SpaceType space = spacetypes.first; space; space = space->next) { + for (ARegionType region = space.regiontypes.first; region; region = region->next) { + TOUCH_RegisterContext(touch_manager, space.name, region.regionid); + } + } + } +#endif } void WM_init_splash(bContext *C) @@ -456,6 +495,16 @@ void WM_exit_ext(bContext *C, const short do_python) if (!G.background) { BKE_undo_save_quit(); /* saves quit.blend if global undo is on */ + + gpuShutdownLighting(); + + gpuDeleteIndex(gindex); + gpuImmediateIndex(NULL); + + gpuImmediateMakeCurrent(NULL); + gpuDeleteImmediate(immediate); + + GPU_ms_exit(); } BKE_reset_undo(); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 054e48f0bfb..962eb55996d 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -76,8 +76,9 @@ #include "BKE_idcode.h" -#include "BIF_gl.h" -#include "BIF_glutil.h" /* for paint cursor */ +#include "GPU_colors.h" +#include "GPU_primitives.h" + #include "BLF_api.h" #include "IMB_colormanagement.h" @@ -2783,7 +2784,7 @@ int WM_gesture_lines_cancel(bContext *C, wmOperator *op) * * caller must free. */ -const int (*WM_gesture_lasso_path_to_array(bContext *UNUSED(C), wmOperator *op, int *mcords_tot))[2] +int (*WM_gesture_lasso_path_to_array(bContext *UNUSED(C), wmOperator *op, int *mcords_tot))[2] { PropertyRNA *prop = RNA_struct_find_property(op->ptr, "path"); int (*mcords)[2] = NULL; @@ -2814,7 +2815,7 @@ const int (*WM_gesture_lasso_path_to_array(bContext *UNUSED(C), wmOperator *op, } /* cast for 'const' */ - return (const int (*)[2])mcords; + return (int (*)[2])mcords; } #if 0 @@ -3044,9 +3045,11 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph float rot; /* set fill color */ - if (rc->fill_col_prop) + if (rc->fill_col_prop) { RNA_property_float_get_array(&rc->fill_col_ptr, rc->fill_col_prop, col); - glColor4f(col[0], col[1], col[2], alpha); + } + + gpuCurrentColor4f(col[0], col[1], col[2], alpha); if (rc->gltex) { glBindTexture(GL_TEXTURE_2D, rc->gltex); @@ -3057,31 +3060,34 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph /* set up rotation if available */ if (rc->rot_prop) { rot = RNA_property_float_get(&rc->rot_ptr, rc->rot_prop); - glPushMatrix(); - glRotatef(RAD2DEGF(rot), 0, 0, 1); + gpuPushMatrix(); + gpuRotateAxis(rot, 'Z'); } /* draw textured quad */ glEnable(GL_TEXTURE_2D); - glBegin(GL_QUADS); - glTexCoord2f(0, 0); - glVertex2f(-radius, -radius); - glTexCoord2f(1, 0); - glVertex2f(radius, -radius); - glTexCoord2f(1, 1); - glVertex2f(radius, radius); - glTexCoord2f(0, 1); - glVertex2f(-radius, radius); - glEnd(); + gpuImmediateFormat_T2_V2(); + gpuBegin(GL_TRIANGLE_FAN); + gpuTexCoord2f(0, 0); + gpuVertex2f(-radius, -radius); + gpuTexCoord2f(1, 0); + gpuVertex2f( radius, -radius); + gpuTexCoord2f(1, 1); + gpuVertex2f( radius, radius); + gpuTexCoord2f(0, 1); + gpuVertex2f(-radius, radius); + gpuEnd(); + gpuImmediateUnformat(); glDisable(GL_TEXTURE_2D); /* undo rotation */ - if (rc->rot_prop) - glPopMatrix(); + if (rc->rot_prop) { + gpuPopMatrix(); + } } else { /* flat color if no texture available */ - glutil_draw_filled_arc(0, M_PI * 2, radius, 40); + gpuSingleDisk(0, 0, radius, 40); } } @@ -3090,7 +3096,7 @@ static void radial_control_paint_cursor(bContext *C, int x, int y, void *customd RadialControl *rc = customdata; ARegion *ar = CTX_wm_region(C); float r1 = 0.0f, r2 = 0.0f, tex_radius, alpha; - float zoom[2], col[3] = {1, 1, 1}; + float zoom[2], col[4] = {1, 1, 1, 0.5f}; switch (rc->subtype) { case PROP_DISTANCE: @@ -3117,7 +3123,7 @@ static void radial_control_paint_cursor(bContext *C, int x, int y, void *customd /* Keep cursor in the original place */ x = rc->initial_mouse[0] - ar->winrct.xmin; y = rc->initial_mouse[1] - ar->winrct.ymin; - glTranslatef((float)x, (float)y, 0.0f); + gpuTranslate((float)x, (float)y, 0.0f); glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); @@ -3125,31 +3131,43 @@ static void radial_control_paint_cursor(bContext *C, int x, int y, void *customd /* apply zoom if available */ if (rc->zoom_prop) { RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom); - glScalef(zoom[0], zoom[1], 1); + gpuScale(zoom[0], zoom[1], 1); } /* draw rotated texture */ radial_control_paint_tex(rc, tex_radius, alpha); /* set line color */ - if (rc->col_prop) + + if (rc->col_prop) { RNA_property_float_get_array(&rc->col_ptr, rc->col_prop, col); - glColor4f(col[0], col[1], col[2], 0.5); + } + + gpuCurrentColor4fv(col); + + gpuImmediateFormat_V2(); // DOODLE: radial control, pair of lines and a pair of circles if (rc->subtype == PROP_ANGLE) { - glPushMatrix(); + gpuPushMatrix(); + /* draw original angle line */ - glRotatef(RAD2DEGF(rc->initial_value), 0, 0, 1); - fdrawline(0.0f, 0.0f, (float)WM_RADIAL_CONTROL_DISPLAY_SIZE, 0.0f); + + gpuRotateAxis(rc->initial_value, 'Z'); + gpuDrawLinef(0, 0, (float)WM_RADIAL_CONTROL_DISPLAY_SIZE, 0); + /* draw new angle line */ - glRotatef(RAD2DEGF(rc->current_value - rc->initial_value), 0, 0, 1); - fdrawline(0.0f, 0.0f, (float)WM_RADIAL_CONTROL_DISPLAY_SIZE, 0.0f); - glPopMatrix(); + + gpuRotateAxis(rc->current_value - rc->initial_value, 'Z'); + gpuDrawLinef(0, 0, (float)WM_RADIAL_CONTROL_DISPLAY_SIZE, 0); + + gpuPopMatrix(); } /* draw circles on top */ - glutil_draw_lined_arc(0.0, (float)(M_PI * 2.0), r1, 40); - glutil_draw_lined_arc(0.0, (float)(M_PI * 2.0), r2, 40); + gpuDrawCircle(0, 0, r1, 40); + gpuDrawCircle(0, 0, r2, 40); + + gpuImmediateUnformat(); glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index 96bbedfee1b..b323f9d70a8 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -62,7 +62,9 @@ #include "BKE_blender.h" #include "BKE_global.h" -#include "BIF_gl.h" +#include "GPU_colors.h" +#include "GPU_compatibility.h" + #include "BIF_glutil.h" #include "DNA_scene_types.h" @@ -256,7 +258,7 @@ static void playanim_toscreen(PlayAnimPict *picture, struct ImBuf *ibuf, int fon int sizex, sizey; float fsizex_inv, fsizey_inv; char str[32 + FILE_MAX]; - cpack(-1); + gpuCurrentColor3x(CPACK_WHITE); BLI_snprintf(str, sizeof(str), "%s | %.2f frames/s", picture->name, fstep / swaptime); playanim_window_get_size(&sizex, &sizey); diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c index 8533494ae96..8a7cd8af34f 100644 --- a/source/blender/windowmanager/intern/wm_subwindow.c +++ b/source/blender/windowmanager/intern/wm_subwindow.c @@ -32,7 +32,6 @@ * \ingroup wm */ - #include <string.h> #include "MEM_guardedalloc.h" @@ -44,12 +43,12 @@ #include "BLI_math.h" #include "BLI_utildefines.h" +#include "BIF_glutil.h" #include "BKE_context.h" #include "BKE_global.h" -#include "BIF_gl.h" - +#include "GPU_compatibility.h" #include "GPU_extensions.h" #include "WM_api.h" @@ -143,8 +142,9 @@ void wm_subwindow_getmatrix(wmWindow *win, int swinid, float mat[][4]) wm_subwindow_getsize(win, swin->swinid, &width, &height); orthographic_m4(mat, -GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS, -100, 100); } - else - glGetFloatv(GL_PROJECTION_MATRIX, (float *)mat); + else { + gpuGetMatrix(GL_PROJECTION_MATRIX, (float *)mat); + } } } @@ -172,7 +172,7 @@ int wm_subwindow_open(wmWindow *win, rcti *winrct) /* extra service */ wm_subwindow_getsize(win, swin->swinid, &width, &height); wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS); - glLoadIdentity(); + gpuLoadIdentity(); return swin->swinid; } @@ -236,41 +236,45 @@ void wm_subwindow_position(wmWindow *win, int swinid, rcti *winrct) /* ----------------- exported in WM_api.h ------------------------------------------------------ */ /* internal state, no threaded opengl! XXX */ -static wmWindow *_curwindow = NULL; -static wmSubWindow *_curswin = NULL; +static wmWindow *_curwindow = NULL; +static wmSubWindow *_curswin = NULL; void wmSubWindowScissorSet(wmWindow *win, int swinid, rcti *srct) { - int width, height; + int x, y, width, height; + _curswin = swin_from_swinid(win, swinid); - + if (_curswin == NULL) { printf("%s %d: doesn't exist\n", __func__, swinid); return; } - + win->curswin = _curswin; + _curwindow = win; - + + x = _curswin->winrct.xmin; + y = _curswin->winrct.ymin; width = BLI_rcti_size_x(&_curswin->winrct) + 1; height = BLI_rcti_size_y(&_curswin->winrct) + 1; - glViewport(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height); + + gpuViewport(x, y, width, height); if (srct) { + x = srct->xmin; + y = srct->ymin; width = BLI_rcti_size_x(srct) + 1; height = BLI_rcti_size_y(srct) + 1; - glScissor(srct->xmin, srct->ymin, width, height); } - else - glScissor(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height); - + + gpuScissor(x, y, width, height); + wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS); - glLoadIdentity(); - glFlush(); + gpuLoadIdentity(); /* reset MODELVIEW */ } - /* enable the WM versions of opengl calls */ void wmSubWindowSet(wmWindow *win, int swinid) { @@ -279,27 +283,29 @@ void wmSubWindowSet(wmWindow *win, int swinid) void wmFrustum(float x1, float x2, float y1, float y2, float n, float f) { - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glFrustum(x1, x2, y1, y2, n, f); - glMatrixMode(GL_MODELVIEW); + gpuMatrixMode(GL_PROJECTION); + gpuLoadFrustum(x1, x2, y1, y2, n, f); + gpuMatrixMode(GL_MODELVIEW); } void wmOrtho(float x1, float x2, float y1, float y2, float n, float f) { - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - glOrtho(x1, x2, y1, y2, n, f); - - glMatrixMode(GL_MODELVIEW); + gpuMatrixMode(GL_PROJECTION); + gpuLoadOrtho(x1, x2, y1, y2, n, f); + gpuMatrixMode(GL_MODELVIEW); } void wmOrtho2(float x1, float x2, float y1, float y2) { - /* prevent opengl from generating errors */ - if (x1 == x2) x2 += 1.0f; - if (y1 == y2) y2 += 1.0f; + /* make sure the window rectangle is not degenerate */ + + if (x1 == x2) { + x2 += 1.0f; + } + + if (y1 == y2) { + y2 += 1.0f; + } wmOrtho(x1, x2, y1, y2, -100, 100); } @@ -374,8 +380,12 @@ unsigned int index_to_framebuffer(int index) void WM_framebuffer_index_set(int index) { - const int col = index_to_framebuffer(index); - cpack(col); + gpuColor3x(index_to_framebuffer(index)); +} + +void WM_set_framebuffer_index_current_color(int index) +{ + gpuCurrentColor3x(index_to_framebuffer(index)); } int WM_framebuffer_to_index(unsigned int col) @@ -399,4 +409,3 @@ int WM_framebuffer_to_index(unsigned int col) /* ********** END MY WINDOW ************** */ - diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 87d80402af6..1da6328d7c8 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -55,7 +55,6 @@ #include "BKE_main.h" -#include "BIF_gl.h" #include "WM_api.h" #include "WM_types.h" @@ -70,6 +69,7 @@ #include "PIL_time.h" +#include "GPU_compatibility.h" #include "GPU_draw.h" #include "GPU_extensions.h" @@ -361,10 +361,10 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win) win->eventstate = MEM_callocN(sizeof(wmEvent), "window event state"); /* until screens get drawn, make it nice gray */ - glClearColor(0.55, 0.55, 0.55, 0.0); + gpuSetClearColor(0.55, 0.55, 0.55, 0.0); /* Crash on OSS ATI: bugs.launchpad.net/ubuntu/+source/mesa/+bug/656100 */ if (!GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) { - glClear(GL_COLOR_BUFFER_BIT); + gpuClear(GL_COLOR_BUFFER_BIT); } wm_window_swap_buffers(win); @@ -871,7 +871,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr /* make blender drop event with custom data pointing to wm drags */ event.type = EVT_DROP; event.val = KM_RELEASE; - event.custom = EVT_DATA_LISTBASE; + event.customdatatype = EVT_DATA_LISTBASE; event.customdata = &wm->drags; event.customdatafree = 1; @@ -946,7 +946,7 @@ static int wm_window_timer(const bContext *C) event.type = wt->event_type; event.val = 0; event.keymodifier = 0; - event.custom = EVT_DATA_TIMER; + event.customdatatype = EVT_DATA_TIMER; event.customdata = wt; wm_event_add(win, &event); diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h index ca0e9659a22..62baa328654 100644 --- a/source/blender/windowmanager/wm_event_types.h +++ b/source/blender/windowmanager/wm_event_types.h @@ -44,6 +44,7 @@ #define EVT_DATA_TIMER 3 #define EVT_DATA_LISTBASE 4 #define EVT_DATA_NDOF_MOTION 5 +#define EVT_DATA_TOUCH 6 /* tablet active, matches GHOST_TTabletMode */ #define EVT_TABLET_NONE 0 @@ -136,6 +137,7 @@ enum { NDOF_LAST }; +#define TOUCH 450 /* SYSTEM : 0x01xx */ #define INPUTCHANGE 0x0103 /* input connected or disconnected */ @@ -303,11 +305,14 @@ enum { /* test whether the event is a NDOF event */ #define ISNDOF(event) (event >= NDOF_MOTION && event < NDOF_LAST) + /* test whether the event is a touch event */ +#define ISTOUCH(event) (event == TOUCH) + /* test whether event type is acceptable as hotkey, excluding modifiers */ -#define ISHOTKEY(event) \ - ((ISKEYBOARD(event) || ISMOUSE(event) || ISNDOF(event)) && \ - (event != ESCKEY) && \ - (event >= LEFTCTRLKEY && event <= LEFTSHIFTKEY) == FALSE && \ +#define ISHOTKEY(event) \ + ((ISKEYBOARD(event) || ISMOUSE(event) || ISNDOF(event) || ISTOUCH(event)) && \ + (event != ESCKEY) && \ + (event >= LEFTCTRLKEY && event <= LEFTSHIFTKEY) == FALSE && \ (event >= UNKNOWNKEY && event <= GRLESSKEY) == FALSE) /* **************** BLENDER GESTURE EVENTS (0x5000) **************** */ |