OpenGL: load projection matrix with new API

New API does not share legacy OpenGL's concept of matrix modes.

Part of T49450
This commit is contained in:
2017-03-22 14:48:47 -04:00
parent 0c2fd1357d
commit 98a0dd6888
6 changed files with 10 additions and 36 deletions

View File

@@ -1065,11 +1065,7 @@ void DRW_draw_callbacks_pre_scene(void)
struct ARegion *ar = CTX_wm_region(DST.context);
RegionView3D *rv3d = CTX_wm_region_view3d(DST.context);
/* This is temporary
* waiting for the full matrix switch */
glMatrixMode(GL_PROJECTION);
gpuLoadMatrix3D(rv3d->winmat);
glMatrixMode(GL_MODELVIEW);
gpuLoadProjectionMatrix3D(rv3d->winmat);
gpuLoadMatrix3D(rv3d->viewmat);
ED_region_draw_cb_draw(DST.context, ar, REGION_DRAW_PRE_VIEW);
@@ -1080,11 +1076,7 @@ void DRW_draw_callbacks_post_scene(void)
struct ARegion *ar = CTX_wm_region(DST.context);
RegionView3D *rv3d = CTX_wm_region_view3d(DST.context);
/* This is temporary
* waiting for the full matrix switch */
glMatrixMode(GL_PROJECTION);
gpuLoadMatrix3D(rv3d->winmat);
glMatrixMode(GL_MODELVIEW);
gpuLoadProjectionMatrix3D(rv3d->winmat);
gpuLoadMatrix3D(rv3d->viewmat);
ED_region_draw_cb_draw(DST.context, ar, REGION_DRAW_POST_VIEW);

View File

@@ -531,9 +531,7 @@ void DRW_draw_grid(void)
*(&grid_unit) = NULL; /* drawgrid need this to detect/affect smallest valid unit... */
drawgrid(&scene->unit, ar, v3d, &grid_unit);
glMatrixMode(GL_PROJECTION);
gpuLoadMatrix3D(rv3d->winmat);
glMatrixMode(GL_MODELVIEW);
gpuLoadProjectionMatrix3D(rv3d->winmat);
gpuLoadMatrix3D(rv3d->viewmat);
}
else {

View File

@@ -675,9 +675,7 @@ 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]);
glMatrixMode(GL_PROJECTION);
gpuLoadMatrix3D(di->orig_projmat);
glMatrixMode(GL_MODELVIEW);
gpuLoadProjectionMatrix3D(di->orig_projmat);
gpuLoadMatrix3D(di->orig_viewmat);
MEM_freeN(di);
@@ -702,7 +700,6 @@ void bglPolygonOffset(float viewdist, float dist)
// glPolygonOffset(-1.0, -1.0);
/* hack below is to mimic polygon offset */
glMatrixMode(GL_PROJECTION);
gpuGetProjectionMatrix3D(winmat);
/* dist is from camera to center point */
@@ -734,17 +731,13 @@ void bglPolygonOffset(float viewdist, float dist)
winmat[14] -= offs;
offset += offs;
gpuLoadMatrix3D(winmat);
glMatrixMode(GL_MODELVIEW);
}
else {
glMatrixMode(GL_PROJECTION);
winmat[14] += offset;
offset = 0.0;
gpuLoadMatrix3D(winmat);
glMatrixMode(GL_MODELVIEW);
}
gpuLoadProjectionMatrix3D(winmat);
}
/* **** Color management helper functions for GLSL display/transform ***** */

View File

@@ -207,9 +207,7 @@ 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 */
glMatrixMode(GL_PROJECTION);
gpuLoadMatrix3D(rv3d->winmat); /* XXX make a gpuLoadProjectionMatrix function? */
glMatrixMode(GL_MODELVIEW);
gpuLoadProjectionMatrix3D(rv3d->winmat);
gpuLoadMatrix3D(rv3d->viewmat);
}
@@ -1496,9 +1494,7 @@ 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);
glMatrixMode(GL_PROJECTION);
gpuLoadMatrix3D(rv3d->winmat); /* XXX make a gpuLoadProjectionMatrix function? */
glMatrixMode(GL_MODELVIEW);
gpuLoadProjectionMatrix3D(rv3d->winmat);
gpuLoadMatrix3D(rv3d->viewmat);
}
else {

View File

@@ -1584,10 +1584,7 @@ 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);
/* XXX make function? replaces persp(1) */
glMatrixMode(GL_PROJECTION);
gpuLoadMatrix3D(rv3d->winmat); /* XXX make a gpuLoadProjectionMatrix function? */
glMatrixMode(GL_MODELVIEW);
gpuLoadProjectionMatrix3D(rv3d->winmat);
gpuLoadMatrix3D(rv3d->viewmat);
}
else if (!draw_grids_after) {

View File

@@ -96,9 +96,7 @@ void view3d_region_operator_needs_opengl(wmWindow *win, ARegion *ar)
RegionView3D *rv3d = ar->regiondata;
wmSubWindowSet(win, ar->swinid);
glMatrixMode(GL_PROJECTION);
gpuLoadMatrix3D(rv3d->winmat);
glMatrixMode(GL_MODELVIEW);
gpuLoadProjectionMatrix3D(rv3d->winmat);
gpuLoadMatrix3D(rv3d->viewmat);
}
}