diff options
-rw-r--r-- | source/blender/editors/interface/interface.c | 12 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d.c | 16 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 5 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_node/drawnode.c | 12 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawarmature.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 81 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawvolume.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/space_view3d.c | 7 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 32 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_view.c | 11 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_manipulator.c | 24 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_view3d_types.h | 12 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 13 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_gesture.c | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_subwindow.c | 160 |
16 files changed, 145 insertions, 257 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index ac85e865b19..7d9d78f5b20 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -746,8 +746,11 @@ void uiDrawBlock(const bContext *C, uiBlock *block) ui_but_to_pixelrect(&rect, ar, block, NULL); /* pixel space for AA widgets */ - wmPushMatrix(); - wmLoadIdentity(); + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); wmOrtho2(-0.01f, ar->winx-0.01f, -0.01f, ar->winy-0.01f); @@ -765,7 +768,10 @@ void uiDrawBlock(const bContext *C, uiBlock *block) } /* restore matrix */ - wmPopMatrix(); + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); ui_draw_links(block); } diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 12265715415..4a648e6051b 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -995,7 +995,7 @@ void UI_view2d_view_ortho(const bContext *C, View2D *v2d) wmOrtho2(curmasked.xmin-xofs, curmasked.xmax-xofs, curmasked.ymin-yofs, curmasked.ymax-yofs); /* XXX is this necessary? */ - wmLoadIdentity(); + glLoadIdentity(); } /* Set view matrices to only use one axis of 'cur' only @@ -1024,7 +1024,7 @@ void UI_view2d_view_orthoSpecial(const bContext *C, View2D *v2d, short xaxis) wmOrtho2(-xofs, ar->winx-xofs, curmasked.ymin-yofs, curmasked.ymax-yofs); /* XXX is this necessary? */ - wmLoadIdentity(); + glLoadIdentity(); } @@ -1036,7 +1036,7 @@ void UI_view2d_view_restore(const bContext *C) int height= ar->winrct.ymax-ar->winrct.ymin+1; wmOrtho2(0.0f, (float)width, 0.0f, (float)height); - wmLoadIdentity(); + glLoadIdentity(); // ED_region_pixelspace(CTX_wm_region(C)); } @@ -2040,7 +2040,10 @@ void UI_view2d_text_cache_draw(ARegion *ar) { View2DString *v2s; - // wmPushMatrix(); + // glMatrixMode(GL_PROJECTION); + // glPushMatrix(); + // glMatrixMode(GL_MODELVIEW); + // glPushMatrix(); ED_region_pixelspace(ar); for(v2s= strings.first; v2s; v2s= v2s->next) { @@ -2062,7 +2065,10 @@ void UI_view2d_text_cache_draw(ARegion *ar) } } - // wmPopMatrix(); + // glMatrixMode(GL_PROJECTION); + // glPopMatrix(); + // glMatrixMode(GL_MODELVIEW); + // glPopMatrix(); if(strings.first) BLI_freelistN(&strings); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 93f6542f9cb..f83af1d5167 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -106,7 +106,7 @@ void ED_region_pixelspace(ARegion *ar) int height= ar->winrct.ymax-ar->winrct.ymin+1; wmOrtho2(-0.375, (float)width-0.375, -0.375, (float)height-0.375); - wmLoadIdentity(); + glLoadIdentity(); } /* only exported for WM */ @@ -932,9 +932,8 @@ void ED_region_init(bContext *C, ARegion *ar) ar->winy= ar->winrct.ymax - ar->winrct.ymin + 1; /* UI convention */ - wmLoadIdentity(); wmOrtho2(-0.01f, ar->winx-0.01f, -0.01f, ar->winy-0.01f); - + glLoadIdentity(); } void ED_region_toggle_hidden(bContext *C, ARegion *ar) diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index b818de56aa3..7ad65a1cbfc 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -1474,9 +1474,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P view3d_operator_needs_opengl(C); /* load projection matrix */ - wmMultMatrix(ob->obmat); - wmGetSingleMatrix(mat); - wmLoadMatrix(vc->rv3d->viewmat); + mul_m4_m4m4(mat, ob->obmat, vc->rv3d->persmat); flip = RNA_boolean_get(itemptr, "flip"); pressure = RNA_float_get(itemptr, "pressure"); @@ -1904,9 +1902,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P view3d_operator_needs_opengl(C); /* load projection matrix */ - wmMultMatrix(ob->obmat); - wmGetSingleMatrix(mat); - wmLoadMatrix(vc->rv3d->viewmat); + mul_m4_m4m4(mat, ob->obmat, vc->rv3d->persmat); mval[0]-= vc->ar->winrct.xmin; mval[1]-= vc->ar->winrct.ymin; diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index fe5c7bca3a6..b914411aeeb 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1271,8 +1271,11 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage) if(ibuf) { float x, y; - wmPushMatrix(); - + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + /* somehow the offset has to be calculated inverse */ glaDefine2DArea(&ar->winrct); @@ -1293,7 +1296,10 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage) if(ibuf->rect) glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); - wmPopMatrix(); + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); } BKE_image_release_ibuf(ima, lock); diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index e7eff234b6e..64cb4c901f9 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -1581,7 +1581,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, /* precalc inverse matrix for drawing screen aligned */ if (arm->drawtype==ARM_ENVELOPE) { /* precalc inverse matrix for drawing screen aligned */ - wmGetMatrix(smat); + copy_m4_m4(smat, rv3d->viewmatob); mul_mat3_m4_fl(smat, 1.0f/len_v3(ob->obmat[0])); invert_m4_m4(imat, smat); @@ -1941,7 +1941,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt) /* envelope (deform distance) */ if(arm->drawtype==ARM_ENVELOPE) { /* precalc inverse matrix for drawing screen aligned */ - wmGetMatrix(smat); + copy_m4_m4(smat, rv3d->viewmatob); mul_mat3_m4_fl(smat, 1.0f/len_v3(ob->obmat[0])); invert_m4_m4(imat, smat); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index cca8dc134e9..5c5f0dbc897 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -554,7 +554,10 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa for(a=0; a<6; a++) glDisable(GL_CLIP_PLANE0+a); - wmPushMatrix(); + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); ED_region_pixelspace(ar); if(depth_write) { @@ -574,7 +577,10 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa } else glDepthMask(1); - wmPopMatrix(); + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); if(rv3d->rflag & RV3D_CLIPPING) for(a=0; a<6; a++) @@ -851,7 +857,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, /* we first draw only the screen aligned & fixed scale stuff */ glPushMatrix(); - wmLoadMatrix(rv3d->viewmat); + glLoadMatrixf(rv3d->viewmat); /* lets calculate the scale: */ pixsize= rv3d->persmat[0][3]*ob->obmat[3][0]+ rv3d->persmat[1][3]*ob->obmat[3][1]+ rv3d->persmat[2][3]*ob->obmat[3][2]+ rv3d->persmat[3][3]; @@ -1065,7 +1071,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, } /* and back to viewspace */ - wmLoadMatrix(rv3d->viewmat); + glLoadMatrixf(rv3d->viewmat); VECCOPY(vec, ob->obmat[3]); setlinestyle(0); @@ -1136,7 +1142,7 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob /* a standing up pyramid with (0,0,0) as top */ Camera *cam; World *wrld; - float vec[8][4], tmat[4][4], fac, facx, facy, depth; + float nobmat[4][4], vec[8][4], fac, facx, facy, depth; int i; if(G.f & G_RENDER_SHADOW) @@ -1216,13 +1222,13 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob if(flag==0) { if(cam->flag & (CAM_SHOWLIMITS+CAM_SHOWMIST)) { - wmLoadMatrix(rv3d->viewmat); - copy_m4_m4(vec, ob->obmat); - normalize_m4(vec); - wmMultMatrix(vec); + /* draw in normalized object matrix space */ + copy_m4_m4(nobmat, ob->obmat); + normalize_m4(nobmat); - swap_m4m4(rv3d->persmat, tmat); - wmGetSingleMatrix(rv3d->persmat); + glPushMatrix(); + glLoadMatrixf(rv3d->viewmat); + glMultMatrixf(nobmat); if(cam->flag & CAM_SHOWLIMITS) { draw_limit_line(cam->clipsta, cam->clipend, 0x77FFFF); @@ -1234,7 +1240,7 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob if(cam->flag & CAM_SHOWMIST) if(wrld) draw_limit_line(wrld->miststa, wrld->miststa+wrld->mistdist, 0xFFFFFF); - swap_m4m4(rv3d->persmat, tmat); + glPopMatrix(); } } } @@ -3355,7 +3361,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv if( (base->flag & OB_FROMDUPLI) && (ob->flag & OB_FROMGROUP) ) { float mat[4][4]; mul_m4_m4m4(mat, psys->imat, ob->obmat); - wmMultMatrix(mat); + glMultMatrixf(mat); } totpart=psys->totpart; @@ -3856,7 +3862,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv } if( (base->flag & OB_FROMDUPLI) && (ob->flag & OB_FROMGROUP) ) - wmLoadMatrix(rv3d->viewmat); + glLoadMatrixf(rv3d->viewmat); } static void draw_update_ptcache_edit(Scene *scene, Object *ob, PTCacheEdit *edit) @@ -4692,7 +4698,7 @@ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, Object *ob= base->object; MetaBall *mb; MetaElem *ml; - float imat[4][4], tmat[4][4]; + float imat[4][4]; int code= 1; mb= ob->data; @@ -4717,8 +4723,7 @@ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, } else UI_ThemeColor(TH_WIRE); - wmGetMatrix(tmat); - invert_m4_m4(imat, tmat); + invert_m4_m4(imat, rv3d->viewmatob); normalize_v3(imat[0]); normalize_v3(imat[1]); @@ -4753,7 +4758,7 @@ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, return 0; } -static void draw_forcefield(Scene *scene, Object *ob) +static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) { PartDeflect *pd= ob->pd; float imat[4][4], tmat[4][4]; @@ -4776,8 +4781,7 @@ static void draw_forcefield(Scene *scene, Object *ob) else size = 1.0; /* calculus here, is reused in PFIELD_FORCE */ - wmGetMatrix(tmat); - invert_m4_m4(imat, tmat); + invert_m4_m4(imat, rv3d->viewmatob); // normalize_v3(imat[0]); // we don't do this because field doesnt scale either... apart from wind! // normalize_v3(imat[1]); @@ -5586,7 +5590,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) break; case OB_LAMP: drawlamp(scene, v3d, rv3d, base, dt, flag); - if(dtx || (base->flag & SELECT)) wmMultMatrix(ob->obmat); + if(dtx || (base->flag & SELECT)) glMultMatrixf(ob->obmat); break; case OB_CAMERA: drawcamera(scene, v3d, rv3d, ob, flag); @@ -5609,17 +5613,17 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if ((sb= ob->soft)){ if(sb->solverflags & SBSO_ESTIMATEIPO){ - wmLoadMatrix(rv3d->viewmat); + glLoadMatrixf(rv3d->viewmat); copy_m3_m3(msc,sb->lscale); copy_m3_m3(mrt,sb->lrot); mul_m3_m3m3(mtr,mrt,msc); ob_draw_RE_motion(sb->lcom,mtr,tipw,tiph,drawsize); - wmMultMatrix(ob->obmat); + glMultMatrixf(ob->obmat); } } } - if(ob->pd && ob->pd->forcefield) draw_forcefield(scene, ob); + if(ob->pd && ob->pd->forcefield) draw_forcefield(scene, ob, rv3d); /* code for new particle system */ if( (warning_recursive==0) && @@ -5633,7 +5637,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if(col || (ob->flag & SELECT)) cpack(0xFFFFFF); /* for visibility, also while wpaint */ //glDepthMask(GL_FALSE); - wmLoadMatrix(rv3d->viewmat); + glLoadMatrixf(rv3d->viewmat); view3d_cached_text_draw_begin(); @@ -5648,7 +5652,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) view3d_cached_text_draw_end(v3d, ar, 0, NULL); - wmMultMatrix(ob->obmat); + glMultMatrixf(ob->obmat); //glDepthMask(GL_TRUE); if(col) cpack(col); @@ -5663,9 +5667,9 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if(ob->mode & OB_MODE_PARTICLE_EDIT && ob==OBACT) { PTCacheEdit *edit = PE_get_current(scene, ob); if(edit) { - wmLoadMatrix(rv3d->viewmat); + glLoadMatrixf(rv3d->viewmat); draw_ptcache_edit(scene, v3d, rv3d, ob, edit, dt); - wmMultMatrix(ob->obmat); + glMultMatrixf(ob->obmat); } } } @@ -5683,7 +5687,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) { size_t i; - wmLoadMatrix(rv3d->viewmat); + glLoadMatrixf(rv3d->viewmat); if(col || (ob->flag & SELECT)) cpack(0xFFFFFF); glDepthMask(GL_FALSE); @@ -5701,7 +5705,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) bglEnd(); glPointSize(1.0); - wmMultMatrix(ob->obmat); + glMultMatrixf(ob->obmat); glDisable(GL_BLEND); glDepthMask(GL_TRUE); if(col) cpack(col); @@ -5725,8 +5729,8 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) int x, y, z; float *density = smoke_get_density(smd->domain->fluid); - wmLoadMatrix(rv3d->viewmat); - // wmMultMatrix(ob->obmat); + glLoadMatrixf(rv3d->viewmat); + // glMultMatrixf(ob->obmat); if(col || (ob->flag & SELECT)) cpack(0xFFFFFF); glDepthMask(GL_FALSE); @@ -5759,7 +5763,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) bglEnd(); glPointSize(1.0); - wmMultMatrix(ob->obmat); + glMultMatrixf(ob->obmat); glDisable(GL_BLEND); glDepthMask(GL_TRUE); if(col) cpack(col); @@ -5809,11 +5813,10 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if(dt<OB_SHADED) { if((ob->gameflag & OB_DYNAMIC) || ((ob->gameflag & OB_BOUNDS) && (ob->boundtype == OB_BOUND_SPHERE))) { - float tmat[4][4], imat[4][4], vec[3]; + float imat[4][4], vec[3]; vec[0]= vec[1]= vec[2]= 0.0; - wmGetMatrix(tmat); - invert_m4_m4(imat, tmat); + invert_m4_m4(imat, rv3d->viewmatob); setlinestyle(2); drawcircball(GL_LINE_LOOP, vec, ob->inertia, imat); @@ -5824,7 +5827,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) /* return warning, this is cached text draw */ view3d_cached_text_draw_end(v3d, ar, 1, NULL); - wmLoadMatrix(rv3d->viewmat); + glLoadMatrixf(rv3d->viewmat); if(zbufoff) glDisable(GL_DEPTH_TEST); @@ -6043,7 +6046,7 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec { ToolSettings *ts= scene->toolsettings; - wmMultMatrix(ob->obmat); + glMultMatrixf(ob->obmat); glClearDepth(1.0); glClear(GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); @@ -6092,7 +6095,7 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec break; } - wmLoadMatrix(rv3d->viewmat); + glLoadMatrixf(rv3d->viewmat); } diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c index 168e1f8592d..3e4748d4807 100644 --- a/source/blender/editors/space_view3d/drawvolume.c +++ b/source/blender/editors/space_view3d/drawvolume.c @@ -346,8 +346,8 @@ void draw_volume(Scene *scene, ARegion *ar, View3D *v3d, Base *base, GPUTexture glGetBooleanv(GL_BLEND, (GLboolean *)&gl_blend); glGetBooleanv(GL_DEPTH_TEST, (GLboolean *)&gl_depth); - wmLoadMatrix(rv3d->viewmat); - // wmMultMatrix(ob->obmat); + glLoadMatrixf(rv3d->viewmat); + // glMultMatrixf(ob->obmat); glDepthMask(GL_FALSE); glDisable(GL_DEPTH_TEST); diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index a65521cd0fb..6b653ccba89 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -172,10 +172,11 @@ RegionView3D *ED_view3d_context_rv3d(bContext *C) */ void ED_view3d_init_mats_rv3d(struct Object *ob, struct RegionView3D *rv3d) { - wmMultMatrix(ob->obmat); /* local viewmat and persmat, to calculate projections */ - wmGetMatrix(rv3d->viewmatob); - wmGetSingleMatrix(rv3d->persmatob); + mul_m4_m4m4(rv3d->viewmatob, ob->obmat, rv3d->viewmat); + mul_m4_m4m4(rv3d->persmatob, ob->obmat, rv3d->persmat); + + glLoadMatrixf(rv3d->viewmatob); /* initializes object space clipping, speeds up clip tests */ ED_view3d_local_clipping(rv3d, ob->obmat); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 04b7d22d928..525842b2a8f 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1395,15 +1395,15 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d) if(v3d->zbuf) glDisable(GL_DEPTH_TEST); glDepthMask(0); + glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - /* need to use wm push/pop matrix because ED_region_pixelspace - uses the wm functions too, otherwise gets out of sync */ - wmPushMatrix(); + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); ED_region_pixelspace(ar); - glEnable(GL_BLEND); - glPixelZoom(zoomx, zoomy); glColor4f(1.0, 1.0, 1.0, 1.0-bgpic->blend); glaDrawPixelsTex(x1, y1, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, ibuf->rect); @@ -1411,7 +1411,10 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d) glPixelZoom(1.0, 1.0); glPixelTransferf(GL_ALPHA_SCALE, 1.0f); - wmPopMatrix(); + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); glDisable(GL_BLEND); @@ -1556,10 +1559,10 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas } } if(use_displist) { - wmMultMatrix(dob->mat); + glMultMatrixf(dob->mat); if(boundbox_clip(rv3d, dob->mat, &bb)) glCallList(displist); - wmLoadMatrix(rv3d->viewmat); + glLoadMatrixf(rv3d->viewmat); } else { copy_m4_m4(dob->ob->obmat, dob->mat); @@ -1638,7 +1641,7 @@ void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d) glClear(GL_DEPTH_BUFFER_BIT); - wmLoadMatrix(rv3d->viewmat); + glLoadMatrixf(rv3d->viewmat); v3d->zbuf= TRUE; glEnable(GL_DEPTH_TEST); @@ -1674,7 +1677,7 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (* func)(void *)) glClear(GL_DEPTH_BUFFER_BIT); - wmLoadMatrix(rv3d->viewmat); + glLoadMatrixf(rv3d->viewmat); // persp(PERSP_STORE); // store correct view for persp(PERSP_VIEW) calls if(rv3d->rflag & RV3D_CLIPPING) { @@ -1910,10 +1913,9 @@ static void view3d_main_area_setup_view(Scene *scene, View3D *v3d, ARegion *ar, /* set for opengl */ glMatrixMode(GL_PROJECTION); - wmLoadMatrix(rv3d->winmat); - + glLoadMatrixf(rv3d->winmat); glMatrixMode(GL_MODELVIEW); - wmLoadMatrix(rv3d->viewmat); + glLoadMatrixf(rv3d->viewmat); } void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, int winy, float viewmat[][4], float winmat[][4]) @@ -2071,9 +2073,9 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) drawgrid(&scene->unit, ar, v3d, &grid_unit); /* XXX make function? replaces persp(1) */ glMatrixMode(GL_PROJECTION); - wmLoadMatrix(rv3d->winmat); + glLoadMatrixf(rv3d->winmat); glMatrixMode(GL_MODELVIEW); - wmLoadMatrix(rv3d->viewmat); + glLoadMatrixf(rv3d->viewmat); if(v3d->flag & V3D_DISPBGPICS) { draw_bgpic(scene, ar, v3d); diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index c4f5f37c5e5..f74978fd317 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -104,9 +104,9 @@ void view3d_operator_needs_opengl(const bContext *C) wmSubWindowSet(CTX_wm_window(C), ar->swinid); glMatrixMode(GL_PROJECTION); - wmLoadMatrix(rv3d->winmat); + glLoadMatrixf(rv3d->winmat); glMatrixMode(GL_MODELVIEW); - wmLoadMatrix(rv3d->viewmat); + glLoadMatrixf(rv3d->viewmat); } } @@ -1074,13 +1074,10 @@ void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect) /* rect: for pick else wmFrustum(x1, x2, y1, y2, clipsta, clipend); } - /* not sure what this was for? (ton) */ - glMatrixMode(GL_PROJECTION); - wmGetMatrix(rv3d->winmat); - glMatrixMode(GL_MODELVIEW); + /* update matrix in 3d view region */ + glGetFloatv(GL_PROJECTION_MATRIX, (float*)rv3d->winmat); } - static void obmat_to_viewmat(View3D *v3d, RegionView3D *rv3d, Object *ob, short smooth) { float bmat[4][4]; diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index 205d6f3479f..a75b64f5e43 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -767,7 +767,7 @@ static void preOrthoFront(int ortho, float twmat[][4], int axis) copy_m4_m4(omat, twmat); orthogonalize_m4(omat, axis); glPushMatrix(); - wmMultMatrix(omat); + glMultMatrixf(omat); glFrontFace( is_mat4_flipped(omat)?GL_CW:GL_CCW); } } @@ -864,14 +864,14 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, copy_m4_m4(matt, rv3d->twmat); // to copy the parts outside of [3][3] // XXX mul_m4_m3m4(matt, t->mat, rv3d->twmat); if (ortho) { - wmMultMatrix(matt); + glMultMatrixf(matt); glFrontFace( is_mat4_flipped(matt)?GL_CW:GL_CCW); } } else { if (ortho) { glFrontFace( is_mat4_flipped(rv3d->twmat)?GL_CW:GL_CCW); - wmMultMatrix(rv3d->twmat); + glMultMatrixf(rv3d->twmat); } } @@ -1028,7 +1028,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, } /* restore */ - wmLoadMatrix(rv3d->viewmat); + glLoadMatrixf(rv3d->viewmat); gluDeleteQuadric(qobj); if(v3d->zbuf) glEnable(GL_DEPTH_TEST); @@ -1130,11 +1130,11 @@ static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving, copy_m4_m4(matt, rv3d->twmat); // to copy the parts outside of [3][3] // XXX mul_m4_m3m4(matt, t->mat, rv3d->twmat); - wmMultMatrix(matt); + glMultMatrixf(matt); glFrontFace( is_mat4_flipped(matt)?GL_CW:GL_CCW); } else { - wmMultMatrix(rv3d->twmat); + glMultMatrixf(rv3d->twmat); glFrontFace( is_mat4_flipped(rv3d->twmat)?GL_CW:GL_CCW); } @@ -1179,7 +1179,7 @@ static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving, } /* restore */ - wmLoadMatrix(rv3d->viewmat); + glLoadMatrixf(rv3d->viewmat); if(v3d->zbuf) glEnable(GL_DEPTH_TEST); glFrontFace(GL_CCW); @@ -1240,7 +1240,7 @@ static void draw_manipulator_translate(View3D *v3d, RegionView3D *rv3d, int movi glPopMatrix(); /* and now apply matrix, we move to local matrix drawing */ - wmMultMatrix(rv3d->twmat); + glMultMatrixf(rv3d->twmat); /* axis */ glLoadName(-1); @@ -1281,7 +1281,7 @@ static void draw_manipulator_translate(View3D *v3d, RegionView3D *rv3d, int movi } gluDeleteQuadric(qobj); - wmLoadMatrix(rv3d->viewmat); + glLoadMatrixf(rv3d->viewmat); if(v3d->zbuf) glEnable(GL_DEPTH_TEST); @@ -1336,10 +1336,10 @@ static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int mov // XXX if (t->flag & T_USES_MANIPULATOR) { // XXX mul_m4_m3m4(matt, t->mat, rv3d->twmat); // XXX } - wmMultMatrix(matt); + glMultMatrixf(matt); } else { - wmMultMatrix(rv3d->twmat); + glMultMatrixf(rv3d->twmat); } glFrontFace( is_mat4_flipped(rv3d->twmat)?GL_CW:GL_CCW); @@ -1383,7 +1383,7 @@ static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int mov /* restore */ gluDeleteQuadric(qobj); - wmLoadMatrix(rv3d->viewmat); + glLoadMatrixf(rv3d->viewmat); if(v3d->zbuf) glEnable(GL_DEPTH_TEST); diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 6546ec5747a..6a7f41c891e 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -77,13 +77,13 @@ typedef struct BGpic { typedef struct RegionView3D { - float winmat[4][4]; - float viewmat[4][4]; - float viewinv[4][4]; - float persmat[4][4]; - float persinv[4][4]; + float winmat[4][4]; /* GL_PROJECTION matrix */ + float viewmat[4][4]; /* GL_MODELVIEW matrix */ + float viewinv[4][4]; /* inverse of viewmat */ + float persmat[4][4]; /* viewmat*winmat */ + float persinv[4][4]; /* inverse of persmat */ - /* local viewmat/persmat, multiplied with object matrix, while drawing */ + /* viewmat/persmat multiplied with object matrix, while drawing and selection */ float viewmatob[4][4]; float persmatob[4][4]; diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index e7521db462d..f59ad924cf8 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -278,23 +278,14 @@ struct wmDropBox *WM_dropbox_add(ListBase *lb, const char *idname, int (*poll)(s void (*copy)(struct wmDrag *, struct wmDropBox *)); ListBase *WM_dropboxmap_find(char *idname, int spaceid, int regionid); - /* OpenGL wrappers, mimicking opengl syntax */ + /* Set a subwindow active in pixelspace view, with optional scissor subset */ void wmSubWindowSet (struct wmWindow *win, int swinid); void wmSubWindowScissorSet (struct wmWindow *win, int swinid, struct rcti *srct); -void wmLoadMatrix (float mat[][4]); -void wmGetMatrix (float mat[][4]); -void wmMultMatrix (float mat[][4]); -void wmGetSingleMatrix (float mat[][4]); -void wmScale (float x, float y, float z); -void wmLoadIdentity (void); /* note: old name clear_view_mat */ -void wmPushMatrix (void); /* one level only */ -void wmPopMatrix (void); /* one level only */ - + /* OpenGL utilities with safety check + working in modelview matrix mode */ void wmFrustum (float x1, float x2, float y1, float y2, float n, float f); void wmOrtho (float x1, float x2, float y1, float y2, float n, float f); void wmOrtho2 (float x1, float x2, float y1, float y2); -void wmOrthoPixelSpace (void); /* utilities */ void WM_set_framebuffer_index_color(int index); diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index 47d8c8d9831..e9f32f6526e 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -318,7 +318,6 @@ void wm_gesture_draw(wmWindow *win) for(; gt; gt= gt->next) { /* all in subwindow space */ wmSubWindowSet(win, gt->swinid); - wmOrthoPixelSpace(); if(gt->type==WM_GESTURE_RECT) wm_gesture_draw_rect(win, gt); diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c index 68f53a8367f..349cc26b618 100644 --- a/source/blender/windowmanager/intern/wm_subwindow.c +++ b/source/blender/windowmanager/intern/wm_subwindow.c @@ -66,9 +66,6 @@ typedef struct wmSubWindow { rcti winrct; int swinid; - - float viewmat[4][4], winmat[4][4]; - float viewmat1[4][4], winmat1[4][4]; } wmSubWindow; @@ -132,8 +129,15 @@ void wm_subwindow_getmatrix(wmWindow *win, int swinid, float mat[][4]) { wmSubWindow *swin= swin_from_swinid(win, swinid); - if(swin) - mul_m4_m4m4(mat, swin->viewmat, swin->winmat); + if(swin) { + /* used by UI, should find a better way to get the matrix there */ + float viewmat[4][4], winmat[4][4]; + + glGetFloatv(GL_MODELVIEW_MATRIX, (float*)winmat); + glGetFloatv(GL_PROJECTION_MATRIX, (float*)viewmat); + + mul_m4_m4m4(mat, viewmat, winmat); + } } /* always sets pixel-precise 2D window/view matrices */ @@ -155,16 +159,13 @@ int wm_subwindow_open(wmWindow *win, rcti *winrct) swin->swinid= freewinid; swin->winrct= *winrct; - unit_m4(swin->viewmat); - unit_m4(swin->winmat); - /* and we appy it all right away */ wmSubWindowSet(win, swin->swinid); /* extra service */ wm_subwindow_getsize(win, swin->swinid, &width, &height); wmOrtho2(-0.375, (float)width-0.375, -0.375, (float)height-0.375); - wmLoadIdentity(); + glLoadIdentity(); return swin->swinid; } @@ -257,11 +258,9 @@ void wmSubWindowScissorSet(wmWindow *win, int swinid, rcti *srct) else glScissor(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height); - glMatrixMode(GL_PROJECTION); - glLoadMatrixf(&_curswin->winmat[0][0]); - glMatrixMode(GL_MODELVIEW); - glLoadMatrixf(&_curswin->viewmat[0][0]); - + wmOrtho2(-0.375, (float)width-0.375, -0.375, (float)height-0.375); + glLoadIdentity(); + glFlush(); } @@ -272,129 +271,22 @@ void wmSubWindowSet(wmWindow *win, int swinid) wmSubWindowScissorSet(win, swinid, NULL); } -void wmLoadMatrix(float mat[][4]) -{ - if(_curswin==NULL) return; - - glLoadMatrixf(mat); - - if (glaGetOneInteger(GL_MATRIX_MODE)==GL_MODELVIEW) - copy_m4_m4(_curswin->viewmat, mat); - else - copy_m4_m4(_curswin->winmat, mat); -} - -void wmGetMatrix(float mat[][4]) -{ - if(_curswin==NULL) return; - - if (glaGetOneInteger(GL_MATRIX_MODE)==GL_MODELVIEW) { - copy_m4_m4(mat, _curswin->viewmat); - } else { - copy_m4_m4(mat, _curswin->winmat); - } -} - -void wmMultMatrix(float mat[][4]) -{ - if(_curswin==NULL) return; - - glMultMatrixf((float*) mat); - - if (glaGetOneInteger(GL_MATRIX_MODE)==GL_MODELVIEW) - glGetFloatv(GL_MODELVIEW_MATRIX, (float *)_curswin->viewmat); - else - glGetFloatv(GL_MODELVIEW_MATRIX, (float *)_curswin->winmat); -} - -static int debugpush= 0; - -void wmPushMatrix(void) -{ - if(_curswin==NULL) return; - - if(debugpush) - printf("wmPushMatrix error already pushed\n"); - debugpush= 1; - - copy_m4_m4(_curswin->viewmat1, _curswin->viewmat); - copy_m4_m4(_curswin->winmat1, _curswin->winmat); -} - -void wmPopMatrix(void) +void wmFrustum(float x1, float x2, float y1, float y2, float n, float f) { - if(_curswin==NULL) return; - - if(debugpush==0) - printf("wmPopMatrix error nothing popped\n"); - debugpush= 0; - - copy_m4_m4(_curswin->viewmat, _curswin->viewmat1); - copy_m4_m4(_curswin->winmat, _curswin->winmat1); - glMatrixMode(GL_PROJECTION); - glLoadMatrixf(&_curswin->winmat[0][0]); + glLoadIdentity(); + glFrustum(x1, x2, y1, y2, n, f); glMatrixMode(GL_MODELVIEW); - glLoadMatrixf(&_curswin->viewmat[0][0]); - -} - -void wmGetSingleMatrix(float mat[][4]) -{ - if(_curswin) - mul_m4_m4m4(mat, _curswin->viewmat, _curswin->winmat); -} - -void wmScale(float x, float y, float z) -{ - if(_curswin==NULL) return; - - glScalef(x, y, z); - - if (glaGetOneInteger(GL_MATRIX_MODE)==GL_MODELVIEW) - glGetFloatv(GL_MODELVIEW_MATRIX, (float *)_curswin->viewmat); - else - glGetFloatv(GL_MODELVIEW_MATRIX, (float *)_curswin->winmat); - } -void wmLoadIdentity(void) +void wmOrtho(float x1, float x2, float y1, float y2, float n, float f) { - if(_curswin==NULL) return; - - if (glaGetOneInteger(GL_MATRIX_MODE)==GL_MODELVIEW) - unit_m4(_curswin->viewmat); - else - unit_m4(_curswin->winmat); - + glMatrixMode(GL_PROJECTION); glLoadIdentity(); -} -void wmFrustum(float x1, float x2, float y1, float y2, float n, float f) -{ - if(_curswin) { + glOrtho(x1, x2, y1, y2, n, f); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glFrustum(x1, x2, y1, y2, n, f); - - glGetFloatv(GL_PROJECTION_MATRIX, (float *)_curswin->winmat); - glMatrixMode(GL_MODELVIEW); - } -} - -void wmOrtho(float x1, float x2, float y1, float y2, float n, float f) -{ - if(_curswin) { - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - glOrtho(x1, x2, y1, y2, n, f); - - glGetFloatv(GL_PROJECTION_MATRIX, (float *)_curswin->winmat); - glMatrixMode(GL_MODELVIEW); - } + glMatrixMode(GL_MODELVIEW); } void wmOrtho2(float x1, float x2, float y1, float y2) @@ -402,18 +294,8 @@ void wmOrtho2(float x1, float x2, float y1, float y2) /* prevent opengl from generating errors */ if(x1==x2) x2+=1.0; if(y1==y2) y2+=1.0; - wmOrtho(x1, x2, y1, y2, -100, 100); -} -void wmOrthoPixelSpace(void) -{ - if(_curswin) { - int width, height; - - wm_subwindow_getsize(_curwindow, _curswin->swinid, &width, &height); - wmOrtho2(-0.375, (float)width-0.375, -0.375, (float)height-0.375); - wmLoadIdentity(); - } + wmOrtho(x1, x2, y1, y2, -100, 100); } /* *************************** Framebuffer color depth, for selection codes ********************** */ |