From 4b043994e8795f37e9227362fe24fd66d45c6b39 Mon Sep 17 00:00:00 2001 From: Mike Erwin Date: Sat, 15 Apr 2017 01:29:25 -0400 Subject: GPU Matrix API: clean up after 2D-3D unification See GPU_matrix.h & gpu_matrix.c for the important changes. Other files are mostly just updated to use the latest API. - remove unused functions, defines, enums, comments - remove "3D" from function names - init to Identity transform (otherwise empty stack) - gpuMatrixReset lets outside code return to initial state Part of T49450 Follow up to D2626 and 49fc9cff3b90 --- source/blender/blenfont/intern/blf.c | 6 +- source/blender/draw/intern/draw_manager.c | 8 +- source/blender/draw/intern/draw_view.c | 4 +- source/blender/editors/curve/editcurve_paint.c | 2 +- source/blender/editors/mask/mask_draw.c | 4 +- source/blender/editors/mesh/editmesh_knife.c | 2 +- source/blender/editors/mesh/editmesh_loopcut.c | 2 +- source/blender/editors/screen/glutil.c | 22 ++--- source/blender/editors/sculpt_paint/paint_utils.c | 4 +- source/blender/editors/space_clip/clip_draw.c | 12 +-- source/blender/editors/space_clip/space_clip.c | 2 +- source/blender/editors/space_view3d/drawanimviz.c | 2 +- source/blender/editors/space_view3d/drawarmature.c | 26 +++--- source/blender/editors/space_view3d/drawobject.c | 54 ++++++------ source/blender/editors/space_view3d/drawsimdebug.c | 2 +- source/blender/editors/space_view3d/space_view3d.c | 2 +- source/blender/editors/space_view3d/view3d_draw.c | 12 +-- .../editors/space_view3d/view3d_draw_legacy.c | 8 +- .../blender/editors/space_view3d/view3d_select.c | 4 +- source/blender/editors/space_view3d/view3d_view.c | 6 +- source/blender/editors/transform/transform.c | 4 +- .../blender/editors/transform/transform_generics.c | 2 +- source/blender/gpu/GPU_matrix.h | 76 ++++------------- source/blender/gpu/intern/gpu_draw.c | 2 +- source/blender/gpu/intern/gpu_matrix.c | 96 ++++++++-------------- source/blender/windowmanager/intern/wm_subwindow.c | 2 +- .../intern/manipulator_library/arrow_manipulator.c | 4 +- .../intern/manipulator_library/dial_manipulator.c | 2 +- .../manipulator_library/primitive_manipulator.c | 4 +- 29 files changed, 147 insertions(+), 229 deletions(-) diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 663be49c71e..e6dffedc5d9 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -555,15 +555,15 @@ static void blf_draw_gl__start(FontBLF *font) gpuPushMatrix(); if (font->flags & BLF_MATRIX) - gpuMultMatrix3D(font->m); + gpuMultMatrix(font->m); gpuTranslate3fv(font->pos); if (font->flags & BLF_ASPECT) gpuScale3fv(font->aspect); - if (font->flags & BLF_ROTATION) /* radians -> degrees */ - gpuRotateAxis(RAD2DEG(font->angle), 'Z'); /* TODO: use gpuRotate2D here? */ + if (font->flags & BLF_ROTATION) + gpuRotate2D(RAD2DEG(font->angle)); #ifndef BLF_STANDALONE VertexFormat *format = immVertexFormat(); diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 65daf347443..b0864f5ed9a 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1157,8 +1157,8 @@ void DRW_draw_callbacks_pre_scene(void) struct ARegion *ar = CTX_wm_region(DST.context); RegionView3D *rv3d = CTX_wm_region_view3d(DST.context); - gpuLoadProjectionMatrix3D(rv3d->winmat); - gpuLoadMatrix3D(rv3d->viewmat); + gpuLoadProjectionMatrix(rv3d->winmat); + gpuLoadMatrix(rv3d->viewmat); ED_region_draw_cb_draw(DST.context, ar, REGION_DRAW_PRE_VIEW); } @@ -1168,8 +1168,8 @@ void DRW_draw_callbacks_post_scene(void) struct ARegion *ar = CTX_wm_region(DST.context); RegionView3D *rv3d = CTX_wm_region_view3d(DST.context); - gpuLoadProjectionMatrix3D(rv3d->winmat); - gpuLoadMatrix3D(rv3d->viewmat); + gpuLoadProjectionMatrix(rv3d->winmat); + gpuLoadMatrix(rv3d->viewmat); ED_region_draw_cb_draw(DST.context, ar, REGION_DRAW_POST_VIEW); } diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c index f5ddd05e915..66542e221b1 100644 --- a/source/blender/draw/intern/draw_view.c +++ b/source/blender/draw/intern/draw_view.c @@ -534,8 +534,8 @@ void DRW_draw_grid(void) *(&grid_unit) = NULL; /* drawgrid need this to detect/affect smallest valid unit... */ drawgrid(&scene->unit, ar, v3d, &grid_unit); - gpuLoadProjectionMatrix3D(rv3d->winmat); - gpuLoadMatrix3D(rv3d->viewmat); + gpuLoadProjectionMatrix(rv3d->winmat); + gpuLoadMatrix(rv3d->viewmat); } else { glDepthMask(GL_TRUE); diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c index eb6e3074cab..804d5573993 100644 --- a/source/blender/editors/curve/editcurve_paint.c +++ b/source/blender/editors/curve/editcurve_paint.c @@ -476,7 +476,7 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS /* scale to edit-mode space */ gpuPushMatrix(); - gpuMultMatrix3D(obedit->obmat); + gpuMultMatrix(obedit->obmat); BLI_mempool_iternew(cdd->stroke_elem_pool, &iter); for (selem = BLI_mempool_iterstep(&iter); selem; selem = BLI_mempool_iterstep(&iter)) { diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index c4f62fdaf97..228a4db74e1 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -767,7 +767,7 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar, gpuTranslate2f(x, y); gpuScale2f(zoomx, zoomy); if (stabmat) { - gpuMultMatrix3D(stabmat); /* XXX make this a 2D matrix */ + gpuMultMatrix(stabmat); } IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR); GPU_shader_uniform_vector(state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, red); @@ -786,7 +786,7 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar, gpuPushMatrix(); if (stabmat) { - gpuMultMatrix3D(stabmat); /* XXX make this a 2D matrix */ + gpuMultMatrix(stabmat); } gpuTranslate2f(x + xofs, y + yofs); diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 1afa676a0f9..3fe7c1d1c99 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -1042,7 +1042,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) glPolygonOffset(1.0f, 1.0f); gpuPushMatrix(); - gpuMultMatrix3D(kcd->ob->obmat); + gpuMultMatrix(kcd->ob->obmat); unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT); diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index c6a3e29bad1..e7a6689b57c 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -106,7 +106,7 @@ static void ringsel_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) glDisable(GL_DEPTH_TEST); gpuPushMatrix(); - gpuMultMatrix3D(lcd->ob->obmat); + gpuMultMatrix(lcd->ob->obmat); unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT); diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index a54bd8a290a..43f77a7d5b5 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -367,18 +367,8 @@ void glaDefine2DArea(rcti *screen_rect) * Programming Guide, Appendix H, Correctness Tips. */ -#if 1 /* new style */ gpuOrtho2D(GLA_PIXEL_OFS, sc_w + GLA_PIXEL_OFS, GLA_PIXEL_OFS, sc_h + GLA_PIXEL_OFS); gpuLoadIdentity(); -#else /* original */ - glMatrixMode(GL_PROJECTION); - gpuLoadIdentity(); - glOrtho(0.0, sc_w, 0.0, sc_h, -1, 1); - gpuTranslate2f(GLA_PIXEL_OFS, GLA_PIXEL_OFS); - - glMatrixMode(GL_MODELVIEW); - gpuLoadIdentity(); -#endif } /* TODO(merwin): put the following 2D code to use, or build new 2D code inspired & informd by it */ @@ -436,8 +426,8 @@ gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect) glGetIntegerv(GL_VIEWPORT, (GLint *)di->orig_vp); glGetIntegerv(GL_SCISSOR_BOX, (GLint *)di->orig_sc); - gpuGetProjectionMatrix3D(di->orig_projmat); - gpuGetModelViewMatrix3D(di->orig_viewmat); + gpuGetProjectionMatrix(di->orig_projmat); + gpuGetModelViewMatrix(di->orig_viewmat); di->screen_rect = *screen_rect; if (world_rect) { @@ -488,8 +478,8 @@ void glaEnd2DDraw(gla2DDrawInfo *di) { glViewport(di->orig_vp[0], di->orig_vp[1], di->orig_vp[2], di->orig_vp[3]); glScissor(di->orig_vp[0], di->orig_vp[1], di->orig_vp[2], di->orig_vp[3]); - gpuLoadProjectionMatrix3D(di->orig_projmat); - gpuLoadMatrix3D(di->orig_viewmat); + gpuLoadProjectionMatrix(di->orig_projmat); + gpuLoadMatrix(di->orig_viewmat); MEM_freeN(di); } @@ -513,7 +503,7 @@ void bglPolygonOffset(float viewdist, float dist) // glPolygonOffset(-1.0, -1.0); /* hack below is to mimic polygon offset */ - gpuGetProjectionMatrix3D((float (*)[4])winmat); + gpuGetProjectionMatrix(winmat); /* dist is from camera to center point */ @@ -550,7 +540,7 @@ void bglPolygonOffset(float viewdist, float dist) offset = 0.0; } - gpuLoadProjectionMatrix3D((const float (*)[4])winmat); + gpuLoadProjectionMatrix(winmat); } /* **** Color management helper functions for GLSL display/transform ***** */ diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 7c3aca80ada..e36cc275ba9 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -284,8 +284,8 @@ static void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, c /* get the needed opengl matrices */ glGetIntegerv(GL_VIEWPORT, view); - gpuGetModelViewMatrix3D(matrix); - gpuGetProjectionMatrix3D(proj); + gpuGetModelViewMatrix(matrix); + gpuGetProjectionMatrix(proj); view[0] = view[1] = 0; mul_m4_m4m4(matrix, matrix, ob->obmat); mul_m4_m4m4(matrix, proj, matrix); diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 0986a4bc4a7..dfedfa5bc12 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -357,7 +357,7 @@ static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int gpuTranslate2f(x, y); gpuScale2f(zoomx, zoomy); - gpuMultMatrix3D(sc->stabmat); /* XXX can we make stabmat a 2D matrix? --merwin */ + gpuMultMatrix(sc->stabmat); unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT); @@ -1079,7 +1079,7 @@ static void draw_plane_marker_image(Scene *scene, plane_marker->corners, perspective_matrix); - homogeneous_2d_to_gl_matrix(perspective_matrix, gl_matrix); /* XXX update for new 2D matrix API --merwin */ + homogeneous_2d_to_gl_matrix(perspective_matrix, gl_matrix); if (plane_track->image_opacity != 1.0f || ibuf->planes == 32) { transparent = true; @@ -1098,7 +1098,7 @@ static void draw_plane_marker_image(Scene *scene, GL_UNSIGNED_BYTE, display_buffer); gpuPushMatrix(); - gpuMultMatrix3D(gl_matrix); /* XXX update for new 2D matrix API --merwin */ + gpuMultMatrix(gl_matrix); VertexFormat *imm_format = immVertexFormat(); unsigned int pos = VertexFormat_add_attrib(imm_format, "pos", COMP_F32, 2, KEEP_FLOAT); @@ -1296,7 +1296,7 @@ static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *ar, Movie gpuPushMatrix(); gpuScale2f(zoomx, zoomy); - gpuMultMatrix3D(sc->stabmat); /* XXX would like 2D stabmat --merwin */ + gpuMultMatrix(sc->stabmat); gpuScale2f(width, height); act_track = BKE_tracking_track_get_active(tracking); @@ -1544,7 +1544,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, gpuPushMatrix(); gpuTranslate2f(x, y); gpuScale2f(zoomx, zoomy); - gpuMultMatrix3D(sc->stabmat); /* XXX make 2D */ + gpuMultMatrix(sc->stabmat); gpuScale2f(width, height); unsigned int position = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT); @@ -1821,7 +1821,7 @@ void clip_draw_grease_pencil(bContext *C, int onlyv2d) */ if ((sc->flag & SC_MANUAL_CALIBRATION) == 0 || is_track_source) { gpuPushMatrix(); - gpuMultMatrix3D(sc->unistabmat); /* XXX make 2D */ + gpuMultMatrix(sc->unistabmat); if (is_track_source) { MovieTrackingTrack *track = BKE_tracking_track_get_active(&sc->clip->tracking); diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 9f35fff5e78..a480338798d 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -1216,7 +1216,7 @@ static void clip_main_region_draw(const bContext *C, ARegion *ar) gpuPushMatrix(); gpuTranslate2f(x, y); gpuScale2f(zoomx, zoomy); - gpuMultMatrix3D(sc->stabmat); /* XXX make this a 2D matrix */ + gpuMultMatrix(sc->stabmat); gpuScale2f(width, height); ED_image_draw_cursor(ar, sc->cursor); gpuPopMatrix(); diff --git a/source/blender/editors/space_view3d/drawanimviz.c b/source/blender/editors/space_view3d/drawanimviz.c index 0f5262f0307..c2db34d8d1a 100644 --- a/source/blender/editors/space_view3d/drawanimviz.c +++ b/source/blender/editors/space_view3d/drawanimviz.c @@ -73,7 +73,7 @@ void draw_motion_paths_init(View3D *v3d, ARegion *ar) if (v3d->zbuf) glDisable(GL_DEPTH_TEST); gpuPushMatrix(); - gpuLoadMatrix3D(rv3d->viewmat); + gpuLoadMatrix(rv3d->viewmat); } /* set color diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index a3ce33bd71d..8b2de77a528 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -1357,7 +1357,7 @@ static void draw_b_bone_boxes(const short dt, bPoseChannel *pchan, EditBone *ebo for (a = 0; a < segments; a++) { gpuPushMatrix(); - gpuMultMatrix3D(bbone[a].mat); + gpuMultMatrix(bbone[a].mat); if (dt == OB_SOLID) drawsolidcube_size(xwidth, dlen, zwidth); else drawcube_size(xwidth, dlen, zwidth); gpuPopMatrix(); @@ -1464,7 +1464,7 @@ static void draw_wire_bone_segments(bPoseChannel *pchan, Mat4 *bbones, float len for (a = 0; a < segments; a++, bbone++) { gpuPushMatrix(); - gpuMultMatrix3D(bbone->mat); + gpuMultMatrix(bbone->mat); immBegin(PRIM_LINES, 2); immVertex3f(pos, 0.0f, 0.0f, 0.0f); @@ -1817,11 +1817,11 @@ static void draw_pose_dofs(Object *ob) if (pchan->parent) { copy_m4_m4(mat, pchan->parent->pose_mat); mat[3][0] = mat[3][1] = mat[3][2] = 0.0f; - gpuMultMatrix3D(mat); + gpuMultMatrix(mat); } copy_m4_m3(mat, pchan->bone->bone_mat); - gpuMultMatrix3D(mat); + gpuMultMatrix(mat); scale = bone->length * pchan->size[1]; gpuScaleUniform(scale); @@ -2010,10 +2010,10 @@ static void draw_pose_bones(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion * gpuPushMatrix(); if (use_custom && pchan->custom_tx) { - gpuMultMatrix3D(pchan->custom_tx->pose_mat); + gpuMultMatrix(pchan->custom_tx->pose_mat); } else { - gpuMultMatrix3D(pchan->pose_mat); + gpuMultMatrix(pchan->pose_mat); } /* catch exception for bone with hidden parent */ @@ -2114,10 +2114,10 @@ static void draw_pose_bones(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion * gpuPushMatrix(); if (pchan->custom_tx) { - gpuMultMatrix3D(pchan->custom_tx->pose_mat); + gpuMultMatrix(pchan->custom_tx->pose_mat); } else { - gpuMultMatrix3D(pchan->pose_mat); + gpuMultMatrix(pchan->pose_mat); } /* prepare colors */ @@ -2248,7 +2248,7 @@ static void draw_pose_bones(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion * gpuPushMatrix(); if (arm->drawtype != ARM_ENVELOPE) - gpuMultMatrix3D(pchan->pose_mat); + gpuMultMatrix(pchan->pose_mat); /* catch exception for bone with hidden parent */ flag = bone->flag; @@ -2349,7 +2349,7 @@ static void draw_pose_bones(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion * gpuPushMatrix(); copy_m4_m4(bmat, pchan->pose_mat); bone_matrix_translate_y(bmat, pchan->bone->length); - gpuMultMatrix3D(bmat); + gpuMultMatrix(bmat); float viewmat_pchan[4][4]; mul_m4_m4m4(viewmat_pchan, rv3d->viewmatob, bmat); @@ -2423,7 +2423,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt) if ((eBone->flag & BONE_HIDDEN_A) == 0) { gpuPushMatrix(); get_matrix_editbone(eBone, bmat); - gpuMultMatrix3D(bmat); + gpuMultMatrix(bmat); /* catch exception for bone with hidden parent */ flag = eBone->flag; @@ -2485,7 +2485,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt) else { gpuPushMatrix(); get_matrix_editbone(eBone, bmat); - gpuMultMatrix3D(bmat); + gpuMultMatrix(bmat); if (arm->drawtype == ARM_LINE) draw_line_bone(arm->flag, flag, 0, index, NULL, eBone); @@ -2562,7 +2562,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt) gpuPushMatrix(); get_matrix_editbone(eBone, bmat); bone_matrix_translate_y(bmat, eBone->length); - gpuMultMatrix3D(bmat); + gpuMultMatrix(bmat); float viewmat_ebone[4][4]; mul_m4_m4m4(viewmat_ebone, rv3d->viewmatob, bmat); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 5b7234ce5c1..91ee3ccd4ca 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -925,7 +925,7 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, bool depth_write, flo } float original_proj[4][4]; - gpuGetProjectionMatrix3D(original_proj); + gpuGetProjectionMatrix(original_proj); wmOrtho2_region_pixelspace(ar); gpuPushMatrix(); @@ -964,7 +964,7 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, bool depth_write, flo } gpuPopMatrix(); - gpuLoadProjectionMatrix3D(original_proj); /* TODO: make this more 2D friendly */ + gpuLoadProjectionMatrix(original_proj); if (rv3d->rflag & RV3D_CLIPPING) { ED_view3d_clipping_enable(); @@ -1244,7 +1244,7 @@ void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base, /* we first draw only the screen aligned & fixed scale stuff */ gpuPushMatrix(); - gpuLoadMatrix3D(rv3d->viewmat); + gpuLoadMatrix(rv3d->viewmat); /* lets calculate the scale: */ const float lampsize_px = U.obcenter_dia; @@ -1565,7 +1565,7 @@ void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base, /* and back to viewspace */ gpuPushMatrix(); - gpuLoadMatrix3D(rv3d->viewmat); + gpuLoadMatrix(rv3d->viewmat); copy_v3_v3(vec, ob->obmat[3]); setlinestyle(0); @@ -1674,8 +1674,8 @@ static void draw_viewport_object_reconstruction( * from current ogl matrix */ invert_m4_m4(imat, base->object->obmat); - gpuMultMatrix3D(imat); - gpuMultMatrix3D(mat); + gpuMultMatrix(imat); + gpuMultMatrix(mat); } else { float obmat[4][4]; @@ -1684,7 +1684,7 @@ static void draw_viewport_object_reconstruction( BKE_tracking_camera_get_reconstructed_interpolate(tracking, tracking_object, framenr, obmat); invert_m4_m4(imat, obmat); - gpuMultMatrix3D(imat); + gpuMultMatrix(imat); } for (track = tracksbase->first; track; track = track->next) { @@ -1950,9 +1950,9 @@ static void drawcamera_stereo3d( ob = BKE_camera_multiview_render(scene, ob, names[i]); cam_lr[i] = ob->data; - gpuLoadMatrix3D(rv3d->viewmat); + gpuLoadMatrix(rv3d->viewmat); BKE_camera_multiview_model_matrix(&scene->r, ob, names[i], obmat); - gpuMultMatrix3D(obmat); + gpuMultMatrix(obmat); copy_m3_m3(vec_lr[i], vec); copy_v3_v3(vec_lr[i][3], vec[3]); @@ -1987,7 +1987,7 @@ static void drawcamera_stereo3d( } /* the remaining drawing takes place in the view space */ - gpuLoadMatrix3D(rv3d->viewmat); + gpuLoadMatrix(rv3d->viewmat); if (is_stereo3d_cameras) { /* draw connecting lines */ @@ -2165,9 +2165,9 @@ void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, bool is_left = v3d->multiview_eye == STEREO_LEFT_ID; gpuPushMatrix(); - gpuLoadMatrix3D(rv3d->viewmat); + gpuLoadMatrix(rv3d->viewmat); BKE_camera_multiview_model_matrix(&scene->r, ob, is_left ? STEREO_LEFT_NAME : STEREO_RIGHT_NAME, obmat); - gpuMultMatrix3D(obmat); + gpuMultMatrix(obmat); drawcamera_frame(vec, false, pos); gpuPopMatrix(); @@ -2224,8 +2224,8 @@ void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, copy_m4_m4(nobmat, ob->obmat); normalize_m4(nobmat); - gpuLoadMatrix3D(rv3d->viewmat); - gpuMultMatrix3D(nobmat); + gpuLoadMatrix(rv3d->viewmat); + gpuMultMatrix(nobmat); if (cam->flag & CAM_SHOWLIMITS) { const unsigned char col[3] = {128, 128, 60}, col_hi[3] = {255, 255, 120}; @@ -5955,7 +5955,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv if ((ob->flag & OB_FROMGROUP) != 0) { float mat[4][4]; mul_m4_m4m4(mat, ob->obmat, psys->imat); - gpuMultMatrix3D(mat); + gpuMultMatrix(mat); } /* needed for text display */ @@ -6545,7 +6545,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv } if ((ob->flag & OB_FROMGROUP) != 0) { - gpuLoadMatrix3D(rv3d->viewmat); + gpuLoadMatrix(rv3d->viewmat); } } @@ -8862,12 +8862,12 @@ afterdraw: if ((sb = ob->soft)) { if (sb->solverflags & SBSO_ESTIMATEIPO) { - gpuLoadMatrix3D(rv3d->viewmat); + gpuLoadMatrix(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); - gpuMultMatrix3D(ob->obmat); + gpuMultMatrix(ob->obmat); } } } @@ -8892,7 +8892,7 @@ afterdraw: } //glDepthMask(GL_FALSE); - gpuLoadMatrix3D(rv3d->viewmat); + gpuLoadMatrix(rv3d->viewmat); view3d_cached_text_draw_begin(); @@ -8909,7 +8909,7 @@ afterdraw: invert_m4_m4(ob->imat, ob->obmat); view3d_cached_text_draw_end(v3d, ar, 0, NULL); - gpuMultMatrix3D(ob->obmat); + gpuMultMatrix(ob->obmat); //glDepthMask(GL_TRUE); if (col) cpack(col); @@ -8923,10 +8923,10 @@ afterdraw: if (ob->mode & OB_MODE_PARTICLE_EDIT && is_obact) { PTCacheEdit *edit = PE_create_current(scene, ob); if (edit) { - gpuLoadMatrix3D(rv3d->viewmat); + gpuLoadMatrix(rv3d->viewmat); draw_update_ptcache_edit(scene, sl, ob, edit); draw_ptcache_edit(scene, v3d, edit); - gpuMultMatrix3D(ob->obmat); + gpuMultMatrix(ob->obmat); } } } @@ -8937,8 +8937,8 @@ afterdraw: const bool show_smoke = (CFRA >= sds->point_cache[0]->startframe); float viewnormal[3]; - gpuLoadMatrix3D(rv3d->viewmat); - gpuMultMatrix3D(ob->obmat); + gpuLoadMatrix(rv3d->viewmat); + gpuMultMatrix(ob->obmat); if (!render_override) { BoundBox bb; @@ -9105,7 +9105,7 @@ afterdraw: /* return warning, clear temp flag */ v3d->flag2 &= ~V3D_SHOW_SOLID_MATCAP; - gpuLoadMatrix3D(rv3d->viewmat); + gpuLoadMatrix(rv3d->viewmat); if (zbufoff) { glDisable(GL_DEPTH_TEST); @@ -9560,7 +9560,7 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec { ToolSettings *ts = scene->toolsettings; - gpuMultMatrix3D(ob->obmat); + gpuMultMatrix(ob->obmat); glClearDepth(1.0); glClear(GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); @@ -9620,7 +9620,7 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec break; } - gpuLoadMatrix3D(rv3d->viewmat); + gpuLoadMatrix(rv3d->viewmat); } diff --git a/source/blender/editors/space_view3d/drawsimdebug.c b/source/blender/editors/space_view3d/drawsimdebug.c index c38b1ada29e..e06336c621b 100644 --- a/source/blender/editors/space_view3d/drawsimdebug.c +++ b/source/blender/editors/space_view3d/drawsimdebug.c @@ -199,7 +199,7 @@ void draw_sim_debug_data(Scene *UNUSED(scene), View3D *v3d, ARegion *ar) invert_m4_m4(imat, rv3d->viewmatob); gpuPushMatrix(); - gpuLoadMatrix3D(rv3d->viewmat); + gpuLoadMatrix(rv3d->viewmat); view3d_cached_text_draw_begin(); draw_sim_debug_elements(_sim_debug_data, imat); diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 334ea1fe952..023c9fcd4e6 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -253,7 +253,7 @@ void ED_view3d_init_mats_rv3d_gl(struct Object *ob, struct RegionView3D *rv3d) /* we have to multiply instead of loading viewmatob to make * it work with duplis using displists, otherwise it will * override the dupli-matrix */ - gpuMultMatrix3D(ob->obmat); + gpuMultMatrix(ob->obmat); } #ifdef DEBUG diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index c9f70945866..802c3f9b96b 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -209,8 +209,8 @@ static void view3d_main_region_setup_view(Scene *scene, View3D *v3d, ARegion *ar ED_view3d_update_viewmat(scene, v3d, ar, viewmat, winmat); /* set for opengl */ - gpuLoadProjectionMatrix3D(rv3d->winmat); - gpuLoadMatrix3D(rv3d->viewmat); + gpuLoadProjectionMatrix(rv3d->winmat); + gpuLoadMatrix(rv3d->viewmat); } static bool view3d_stereo3d_active(const bContext *C, Scene *scene, View3D *v3d, RegionView3D *rv3d) @@ -773,7 +773,7 @@ static bool view3d_draw_render_draw(const bContext *C, Scene *scene, /* rendered draw */ gpuPushMatrix(); float original_proj[4][4]; - gpuGetProjectionMatrix3D(original_proj); + gpuGetProjectionMatrix(original_proj); ED_region_pixelspace(ar); if (clip_border) { @@ -801,7 +801,7 @@ static bool view3d_draw_render_draw(const bContext *C, Scene *scene, glScissor(scissor[0], scissor[1], scissor[2], scissor[3]); } - gpuLoadProjectionMatrix3D(original_proj); + gpuLoadProjectionMatrix(original_proj); gpuPopMatrix(); return true; @@ -1475,8 +1475,8 @@ static void view3d_draw_grid(const bContext *C, ARegion *ar) *(&grid_unit) = NULL; /* drawgrid need this to detect/affect smallest valid unit... */ drawgrid(&scene->unit, ar, v3d, &grid_unit); - gpuLoadProjectionMatrix3D(rv3d->winmat); - gpuLoadMatrix3D(rv3d->viewmat); + gpuLoadProjectionMatrix(rv3d->winmat); + gpuLoadMatrix(rv3d->viewmat); } else { drawfloor(scene, v3d, &grid_unit, false); diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c index db6657de18b..e01ac976f95 100644 --- a/source/blender/editors/space_view3d/view3d_draw_legacy.c +++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c @@ -1193,7 +1193,7 @@ void ED_view3d_draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d) glClear(GL_DEPTH_BUFFER_BIT); - gpuLoadMatrix3D(rv3d->viewmat); + gpuLoadMatrix(rv3d->viewmat); v3d->zbuf = true; glEnable(GL_DEPTH_TEST); @@ -1232,7 +1232,7 @@ void ED_view3d_draw_depth(Scene *scene, ARegion *ar, View3D *v3d, bool alphaover glClear(GL_DEPTH_BUFFER_BIT); - gpuLoadMatrix3D(rv3d->viewmat); + gpuLoadMatrix(rv3d->viewmat); if (rv3d->rflag & RV3D_CLIPPING) { ED_view3d_clipping_set(rv3d); @@ -1588,8 +1588,8 @@ static void view3d_draw_objects( ED_region_pixelspace(ar); *grid_unit = NULL; /* drawgrid need this to detect/affect smallest valid unit... */ VP_legacy_drawgrid(&scene->unit, ar, v3d, grid_unit); - gpuLoadProjectionMatrix3D(rv3d->winmat); - gpuLoadMatrix3D(rv3d->viewmat); + gpuLoadProjectionMatrix(rv3d->winmat); + gpuLoadMatrix(rv3d->viewmat); } else if (!draw_grids_after) { VP_legacy_drawfloor(scene, v3d, grid_unit, true); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index c53efd02b92..4e527a93ed3 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -474,7 +474,7 @@ static void do_lasso_select_mesh(ViewContext *vc, const int mcords[][2], short m /* for non zbuf projections, don't change the GL state */ ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); - gpuLoadMatrix3D(vc->rv3d->viewmat); + gpuLoadMatrix(vc->rv3d->viewmat); bbsel = EDBM_backbuf_border_mask_init(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax); if (ts->selectmode & SCE_SELECT_VERTEX) { @@ -1846,7 +1846,7 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, bool select, bool ext /* for non zbuf projections, don't change the GL state */ ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); - gpuLoadMatrix3D(vc->rv3d->viewmat); + gpuLoadMatrix(vc->rv3d->viewmat); bbsel = EDBM_backbuf_border_init(vc, rect->xmin, rect->ymin, rect->xmax, rect->ymax); if (ts->selectmode & SCE_SELECT_VERTEX) { diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 08f8516593f..e83927b074b 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -96,8 +96,8 @@ void view3d_region_operator_needs_opengl(wmWindow *win, ARegion *ar) RegionView3D *rv3d = ar->regiondata; wmSubWindowSet(win, ar->swinid); - gpuLoadProjectionMatrix3D(rv3d->winmat); - gpuLoadMatrix3D(rv3d->viewmat); + gpuLoadProjectionMatrix(rv3d->winmat); + gpuLoadMatrix(rv3d->viewmat); } } @@ -935,7 +935,7 @@ void view3d_winmatrix_set(ARegion *ar, const View3D *v3d, const rcti *rect) } /* update matrix in 3d view region */ - gpuGetProjectionMatrix3D(rv3d->winmat); + gpuGetProjectionMatrix(rv3d->winmat); } static void obmat_to_viewmat(RegionView3D *rv3d, Object *ob) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index c479203bbeb..06a052ad711 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -6858,7 +6858,7 @@ static void drawEdgeSlide(TransInfo *t) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gpuPushMatrix(); - gpuMultMatrix3D(t->obedit->obmat); + gpuMultMatrix(t->obedit->obmat); unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT); @@ -7470,7 +7470,7 @@ static void drawVertSlide(TransInfo *t) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gpuPushMatrix(); - gpuMultMatrix3D(t->obedit->obmat); + gpuMultMatrix(t->obedit->obmat); glLineWidth(line_size); diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index d9dc6bf0dfd..0009ae13117 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1036,7 +1036,7 @@ void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis gpuPushMatrix(); - // if (t->obedit) gpuLoadMatrix3D(t->obedit->obmat); // sets opengl viewing + // if (t->obedit) gpuLoadMatrix(t->obedit->obmat); // sets opengl viewing copy_v3_v3(v3, dir); mul_v3_fl(v3, v3d->far); diff --git a/source/blender/gpu/GPU_matrix.h b/source/blender/gpu/GPU_matrix.h index 4a47f55a6c6..866fde696bb 100644 --- a/source/blender/gpu/GPU_matrix.h +++ b/source/blender/gpu/GPU_matrix.h @@ -49,25 +49,8 @@ extern "C" { #define SUPPORT_LEGACY_MATRIX 1 #endif -/* implement 2D parts with 4x4 matrices, even though 3x3 feels better - * this is a compromise to get core profile up & running sooner - * external API stays (almost) the same - */ -#define MATRIX_2D_4x4 1 - - -void gpuMatrixInit(void); /* called by system -- make private? */ - - -/* MatrixMode is conceptually different from GL_MATRIX_MODE */ -typedef enum { - MATRIX_MODE_INACTIVE, - MATRIX_MODE_2D, - MATRIX_MODE_3D -} MatrixMode; - -MatrixMode gpuMatrixMode(void); +void gpuMatrixReset(void); /* to Identity transform & empty stack */ /* ModelView Matrix (2D or 3D) */ @@ -81,9 +64,8 @@ void gpuScaleUniform(float factor); /* 3D ModelView Matrix */ -void gpuLoadMatrix3D(const float m[4][4]); -void gpuMultMatrix3D(const float m[4][4]); -//const float *gpuGetMatrix3D(float m[4][4]); +void gpuLoadMatrix(const float m[4][4]); +void gpuMultMatrix(const float m[4][4]); void gpuTranslate3f(float x, float y, float z); void gpuTranslate3fv(const float vec[3]); @@ -99,7 +81,7 @@ void gpuLookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, /* 2D ModelView Matrix */ -void gpuMultMatrix2D(const float m[4][4]); +void gpuMultMatrix(const float m[4][4]); void gpuTranslate2f(float x, float y); void gpuTranslate2fv(const float vec[2]); @@ -110,7 +92,7 @@ void gpuRotate2D(float deg); /* 3D Projection Matrix */ -void gpuLoadProjectionMatrix3D(const float m[4][4]); +void gpuLoadProjectionMatrix(const float m[4][4]); void gpuOrtho(float left, float right, float bottom, float top, float near, float far); void gpuFrustum(float left, float right, float bottom, float top, float near, float far); @@ -127,9 +109,9 @@ void gpuOrtho2D(float left, float right, float bottom, float top); /* functions to get matrix values */ -const float *gpuGetModelViewMatrix3D(float m[4][4]); -const float *gpuGetProjectionMatrix3D(float m[4][4]); -const float *gpuGetModelViewProjectionMatrix3D(float m[4][4]); +const float *gpuGetModelViewMatrix(float m[4][4]); +const float *gpuGetProjectionMatrix(float m[4][4]); +const float *gpuGetModelViewProjectionMatrix(float m[4][4]); const float *gpuGetNormalMatrix(float m[3][3]); const float *gpuGetNormalMatrixInverse(float m[3][3]); @@ -146,43 +128,13 @@ bool gpuMatricesDirty(void); /* since last bind */ #ifndef SUPPRESS_GENERIC_MATRIX_API /* make matrix inputs generic, to avoid warnings */ -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) -# define gpuMultMatrix3D(x) \ - gpuMultMatrix3D(_Generic((x), \ - float *: (const float (*)[4])(x), \ - float [16]: (const float (*)[4])(x), \ - float (*)[4]: (const float (*)[4])(x), \ - float [4][4]: (const float (*)[4])(x), \ - const float *: (const float (*)[4])(x), \ - const float [16]: (const float (*)[4])(x), \ - const float (*)[4]: (const float (*)[4])(x), \ - const float [4][4]: (const float (*)[4])(x)) \ -) -# define gpuLoadMatrix3D(x) \ - gpuLoadMatrix3D(_Generic((x), \ - float *: (const float (*)[4])(x), \ - float [16]: (const float (*)[4])(x), \ - float (*)[4]: (const float (*)[4])(x), \ - float [4][4]: (const float (*)[4])(x), \ - const float *: (const float (*)[4])(x), \ - const float [16]: (const float (*)[4])(x), \ - const float (*)[4]: (const float (*)[4])(x), \ - const float [4][4]: (const float (*)[4])(x)) \ -) -/* TODO: finish this in a simpler way --^ */ -#else -# define gpuMultMatrix3D(x) gpuMultMatrix3D((const float (*)[4])(x)) -# define gpuLoadMatrix3D(x) gpuLoadMatrix3D((const float (*)[4])(x)) - -# define gpuLoadProjectionMatrix3D(x) gpuLoadProjectionMatrix3D((const float (*)[4])(x)) - -# define gpuMultMatrix2D(x) gpuMultMatrix2D((const float (*)[4])(x)) - -# define gpuGetModelViewMatrix3D(x) gpuGetModelViewMatrix3D((float (*)[4])(x)) -# define gpuGetProjectionMatrix3D(x) gpuGetProjectionMatrix3D((float (*)[4])(x)) -# define gpuGetModelViewProjectionMatrix3D(x) gpuGetModelViewProjectionMatrix3D((float (*)[4])(x)) +# define gpuMultMatrix(x) gpuMultMatrix((const float (*)[4])(x)) +# define gpuLoadMatrix(x) gpuLoadMatrix((const float (*)[4])(x)) +# define gpuLoadProjectionMatrix(x) gpuLoadProjectionMatrix((const float (*)[4])(x)) +# define gpuGetModelViewMatrix(x) gpuGetModelViewMatrix((float (*)[4])(x)) +# define gpuGetProjectionMatrix(x) gpuGetProjectionMatrix((float (*)[4])(x)) +# define gpuGetModelViewProjectionMatrix(x) gpuGetModelViewProjectionMatrix((float (*)[4])(x)) # define gpuGetNormalMatrix(x) gpuGetNormalMatrix((float (*)[3])(x)) # define gpuGetNormalMatrixInverse(x) gpuGetNormalMatrixInverse((float (*)[3])(x)) -#endif /* C11 */ #endif /* SUPPRESS_GENERIC_MATRIX_API */ #endif /* GPU_MATRIX_H */ diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 3ef0a02718d..055a18ef343 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -2174,7 +2174,7 @@ int GPU_scene_object_lights(Scene *scene, Object *ob, int lay, float viewmat[4][ /* setup lamp transform */ gpuPushMatrix(); - gpuLoadMatrix3D(viewmat); + gpuLoadMatrix(viewmat); /* setup light */ GPULightData light = {0}; diff --git a/source/blender/gpu/intern/gpu_matrix.c b/source/blender/gpu/intern/gpu_matrix.c index 5a327630572..1ea6dcb0e83 100644 --- a/source/blender/gpu/intern/gpu_matrix.c +++ b/source/blender/gpu/intern/gpu_matrix.c @@ -48,7 +48,7 @@ typedef struct { Mat4 ModelViewStack[MATRIX_STACK_DEPTH]; Mat4 ProjectionMatrix; - unsigned top; /* of current stack (would have to replicate if gpuResume2D/3D are implemented) */ + unsigned top; /* of ModelView stack */ bool dirty; @@ -65,10 +65,11 @@ typedef struct { {0.0f, 0.0f, 1.0f, 0.0f}, \ {0.0f, 0.0f, 0.0f, 1.0f}} -/* TODO(merwin): make part of GPUContext, alongside immediate mode & state tracker */ static MatrixState state = { .ModelViewStack = {MATRIX_4X4_IDENTITY}, .ProjectionMatrix = MATRIX_4X4_IDENTITY, + .top = 0, + .dirty = true }; #undef MATRIX_4X4_IDENTITY @@ -76,9 +77,12 @@ static MatrixState state = { #define ModelView state.ModelViewStack[state.top] #define Projection state.ProjectionMatrix -void gpuMatrixInit(void) +void gpuMatrixReset(void) { - memset(&state, 0, sizeof(MatrixState)); + state.top = 0; + unit_m4(ModelView); + unit_m4(Projection); + state.dirty = true; } #ifdef WITH_GPU_SAFETY @@ -135,7 +139,7 @@ void gpuPopMatrix(void) state.dirty = true; } -void gpuLoadMatrix3D(const float m[4][4]) +void gpuLoadMatrix(const float m[4][4]) { #if SUPPORT_LEGACY_MATRIX { @@ -150,7 +154,7 @@ void gpuLoadMatrix3D(const float m[4][4]) state.dirty = true; } -void gpuLoadProjectionMatrix3D(const float m[4][4]) +void gpuLoadProjectionMatrix(const float m[4][4]) { #if SUPPORT_LEGACY_MATRIX { @@ -176,15 +180,6 @@ void gpuLoadProjectionMatrix3D(const float m[4][4]) state.dirty = true; } -#if 0 /* unused at the moment */ -void gpuLoadMatrix2D(const float m[3][3]) -{ - copy_m3_m3(ModelView2D, m); - CHECKMAT(ModelView2D); - state.dirty = true; -} -#endif - void gpuLoadIdentity(void) { unit_m4(ModelView); @@ -208,7 +203,7 @@ void gpuTranslate2f(float x, float y) unit_m4(m); m[3][0] = x; m[3][1] = y; - gpuMultMatrix2D(m); + gpuMultMatrix(m); } void gpuTranslate2fv(const float vec[2]) @@ -228,14 +223,14 @@ void gpuTranslate3f(float x, float y, float z) #if 1 translate_m4(ModelView, x, y, z); - CHECKMAT(ModelView3D); + CHECKMAT(ModelView); #else /* above works well in early testing, below is generic version */ Mat4 m; unit_m4(m); m[3][0] = x; m[3][1] = y; m[3][2] = z; - gpuMultMatrix3D(m); + gpuMultMatrix(m); #endif state.dirty = true; } @@ -249,7 +244,7 @@ void gpuScaleUniform(float factor) { Mat4 m; scale_m4_fl(m, factor); - gpuMultMatrix3D(m); + gpuMultMatrix(m); #if SUPPORT_LEGACY_MATRIX glScalef(factor, factor, factor); /* always scale Z since we can't distinguish 2D from 3D */ @@ -272,7 +267,7 @@ void gpuScale2f(float x, float y) m[1][1] = y; m[2][2] = 1.0f; m[3][3] = 1.0f; - gpuMultMatrix2D(m); + gpuMultMatrix(m); } void gpuScale2fv(const float vec[2]) @@ -295,7 +290,7 @@ void gpuScale3f(float x, float y, float z) m[1][1] = y; m[2][2] = z; m[3][3] = 1.0f; - gpuMultMatrix3D(m); + gpuMultMatrix(m); } void gpuScale3fv(const float vec[3]) @@ -303,7 +298,7 @@ void gpuScale3fv(const float vec[3]) gpuScale3f(vec[0], vec[1], vec[2]); } -void gpuMultMatrix3D(const float m[4][4]) +void gpuMultMatrix(const float m[4][4]) { #if SUPPORT_LEGACY_MATRIX { @@ -314,26 +309,10 @@ void gpuMultMatrix3D(const float m[4][4]) #endif mul_m4_m4_post(ModelView, m); - CHECKMAT(ModelView3D); + CHECKMAT(ModelView); state.dirty = true; } -#if MATRIX_2D_4x4 -void gpuMultMatrix2D(const float m[4][4]) -{ - mul_m4_m4_post(ModelView, m); - CHECKMAT(ModelView2D); - state.dirty = true; -} -#else -void gpuMultMatrix2D(const float m[3][3]) -{ - mul_m3_m3_post(ModelView2D, m); - CHECKMAT(ModelView2D); - state.dirty = true; -} -#endif - void gpuRotate2D(float deg) { #if SUPPORT_LEGACY_MATRIX @@ -368,7 +347,7 @@ void gpuRotate3fv(float deg, const float axis[3]) Mat4 m; axis_angle_to_mat4(m, axis, DEG2RADF(deg)); - gpuMultMatrix3D(m); + gpuMultMatrix(m); } void gpuRotateAxis(float deg, char axis) @@ -390,7 +369,7 @@ void gpuRotateAxis(float deg, char axis) /* rotate_m4 works in place */ rotate_m4(ModelView, axis, DEG2RADF(deg)); - CHECKMAT(ModelView3D); + CHECKMAT(ModelView); state.dirty = true; } @@ -533,7 +512,7 @@ void gpuOrtho(float left, float right, float bottom, float top, float near, floa #endif mat4_ortho_set(Projection, left, right, bottom, top, near, far); - CHECKMAT(Projection3D); + CHECKMAT(Projection); state.dirty = true; } @@ -588,7 +567,7 @@ void gpuFrustum(float left, float right, float bottom, float top, float near, fl #endif mat4_frustum_set(Projection, left, right, bottom, top, near, far); - CHECKMAT(Projection3D); + CHECKMAT(Projection); state.dirty = true; } @@ -611,7 +590,7 @@ void gpuLookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, mat4_look_from_origin(cm, lookdir, camup); - gpuMultMatrix3D(cm); + gpuMultMatrix(cm); gpuTranslate3f(-eyeX, -eyeY, -eyeZ); } @@ -669,7 +648,7 @@ bool gpuUnProject(const float win[3], const float model[4][4], const float proj[ return true; } -const float *gpuGetModelViewMatrix3D(float m[4][4]) +const float *gpuGetModelViewMatrix(float m[4][4]) { #if SUPPORT_LEGACY_MATRIX { @@ -692,7 +671,7 @@ const float *gpuGetModelViewMatrix3D(float m[4][4]) } } -const float *gpuGetProjectionMatrix3D(float m[4][4]) +const float *gpuGetProjectionMatrix(float m[4][4]) { #if SUPPORT_LEGACY_MATRIX { @@ -715,7 +694,7 @@ const float *gpuGetProjectionMatrix3D(float m[4][4]) } } -const float *gpuGetModelViewProjectionMatrix3D(float m[4][4]) +const float *gpuGetModelViewProjectionMatrix(float m[4][4]) { if (m == NULL) { static Mat4 temp; @@ -743,7 +722,7 @@ const float *gpuGetNormalMatrix(float m[3][3]) m = temp3; } - copy_m3_m4(m, (const float (*)[4])gpuGetModelViewMatrix3D(NULL)); + copy_m3_m4(m, (const float (*)[4])gpuGetModelViewMatrix(NULL)); invert_m3(m); transpose_m3(m); @@ -781,31 +760,31 @@ void gpuBindMatrices(const ShaderInterface* shaderface) if (MV) { #if DEBUG_MATRIX_BIND - puts("setting 3D MV matrix"); + puts("setting MV matrix"); #endif - glUniformMatrix4fv(MV->location, 1, GL_FALSE, gpuGetModelViewMatrix3D(NULL)); + glUniformMatrix4fv(MV->location, 1, GL_FALSE, gpuGetModelViewMatrix(NULL)); } if (P) { #if DEBUG_MATRIX_BIND - puts("setting 3D P matrix"); + puts("setting P matrix"); #endif - glUniformMatrix4fv(P->location, 1, GL_FALSE, gpuGetProjectionMatrix3D(NULL)); + glUniformMatrix4fv(P->location, 1, GL_FALSE, gpuGetProjectionMatrix(NULL)); } if (MVP) { #if DEBUG_MATRIX_BIND - puts("setting 3D MVP matrix"); + puts("setting MVP matrix"); #endif - glUniformMatrix4fv(MVP->location, 1, GL_FALSE, gpuGetModelViewProjectionMatrix3D(NULL)); + glUniformMatrix4fv(MVP->location, 1, GL_FALSE, gpuGetModelViewProjectionMatrix(NULL)); } if (N) { #if DEBUG_MATRIX_BIND - puts("setting 3D normal matrix"); + puts("setting normal matrix"); #endif glUniformMatrix3fv(N->location, 1, GL_FALSE, gpuGetNormalMatrix(NULL)); @@ -813,14 +792,14 @@ void gpuBindMatrices(const ShaderInterface* shaderface) if (MV_inv) { Mat4 m; - gpuGetModelViewMatrix3D(m); + gpuGetModelViewMatrix(m); invert_m4(m); glUniformMatrix4fv(MV_inv->location, 1, GL_FALSE, (const float*) m); } if (P_inv) { Mat4 m; - gpuGetProjectionMatrix3D(m); + gpuGetProjectionMatrix(m); invert_m4(m); glUniformMatrix4fv(P_inv->location, 1, GL_FALSE, (const float*) m); } @@ -832,6 +811,3 @@ bool gpuMatricesDirty(void) { return state.dirty; } - -#undef ModelView -#undef Projection diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c index d73aa107cab..7613479aacd 100644 --- a/source/blender/windowmanager/intern/wm_subwindow.c +++ b/source/blender/windowmanager/intern/wm_subwindow.c @@ -149,7 +149,7 @@ static void wm_swin_matrix_get(wmWindow *win, wmSubWindow *swin, float mat[4][4] orthographic_m4(mat, -GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS, -100, 100); } else { - gpuGetProjectionMatrix3D(mat); + gpuGetProjectionMatrix(mat); } } void wm_subwindow_matrix_get(wmWindow *win, int swinid, float mat[4][4]) diff --git a/source/blender/windowmanager/manipulators/intern/manipulator_library/arrow_manipulator.c b/source/blender/windowmanager/manipulators/intern/manipulator_library/arrow_manipulator.c index 3cb67259e03..99ca161f08f 100644 --- a/source/blender/windowmanager/manipulators/intern/manipulator_library/arrow_manipulator.c +++ b/source/blender/windowmanager/manipulators/intern/manipulator_library/arrow_manipulator.c @@ -210,7 +210,7 @@ static void arrow_draw_intern(ArrowManipulator *arrow, const bool select, const mul_mat3_m4_fl(mat, arrow->manipulator.scale); gpuPushMatrix(); - gpuMultMatrix3D(mat); + gpuMultMatrix(mat); gpuTranslate3fv(arrow->manipulator.offset); @@ -228,7 +228,7 @@ static void arrow_draw_intern(ArrowManipulator *arrow, const bool select, const mul_mat3_m4_fl(mat, inter->init_scale); gpuPushMatrix(); - gpuMultMatrix3D(mat); + gpuMultMatrix(mat); gpuTranslate3fv(arrow->manipulator.offset); glEnable(GL_BLEND); diff --git a/source/blender/windowmanager/manipulators/intern/manipulator_library/dial_manipulator.c b/source/blender/windowmanager/manipulators/intern/manipulator_library/dial_manipulator.c index 63b02cb1509..0fa6cbfbb28 100644 --- a/source/blender/windowmanager/manipulators/intern/manipulator_library/dial_manipulator.c +++ b/source/blender/windowmanager/manipulators/intern/manipulator_library/dial_manipulator.c @@ -239,7 +239,7 @@ static void dial_draw_intern( mul_mat3_m4_fl(mat, dial->manipulator.scale); gpuPushMatrix(); - gpuMultMatrix3D(mat); + gpuMultMatrix(mat); gpuTranslate3fv(dial->manipulator.offset); /* draw rotation indicator arc first */ diff --git a/source/blender/windowmanager/manipulators/intern/manipulator_library/primitive_manipulator.c b/source/blender/windowmanager/manipulators/intern/manipulator_library/primitive_manipulator.c index 9755d090e8b..bf53705a6e2 100644 --- a/source/blender/windowmanager/manipulators/intern/manipulator_library/primitive_manipulator.c +++ b/source/blender/windowmanager/manipulators/intern/manipulator_library/primitive_manipulator.c @@ -123,7 +123,7 @@ static void manipulator_primitive_draw_intern( mul_mat3_m4_fl(mat, prim->manipulator.scale); gpuPushMatrix(); - gpuMultMatrix3D(mat); + gpuMultMatrix(mat); manipulator_color_get(&prim->manipulator, highlight, col_outer); copy_v4_v4(col_inner, col_outer); @@ -148,7 +148,7 @@ static void manipulator_primitive_draw_intern( mul_mat3_m4_fl(mat, inter->init_scale); gpuPushMatrix(); - gpuMultMatrix3D(mat); + gpuMultMatrix(mat); glEnable(GL_BLEND); gpuTranslate3fv(prim->manipulator.offset); -- cgit v1.2.3