OpenGL: disable rotate manipulator clipping on Mac

This fixes T51143.

gl_ClipDistance is part of GLSL version 1.3 but Mac is stuck on 1.2 for now.

This workaround uses GPU_SHADER_3D_UNIFORM_COLOR for the entire rotation widget, ignoring any clipping plane. The CLIPPING shader only works on GLSL 1.3+ so I removed its 1.2 cruft.

A legacy implementation using gl_ClipVertex might be possible, but is not worth the effort. This problem (and workaround) goes away when all platforms move to 3.3 core profile.
This commit is contained in:
Mike Erwin
2017-04-07 03:08:00 -04:00
parent c986a2c7aa
commit 9c01aaa3dd
2 changed files with 16 additions and 5 deletions

View File

@@ -1133,18 +1133,24 @@ static void draw_manipulator_rotate(
// donut arcs
if (arcs) {
float axis_model_mat[4][4];
#if !APPLE_LEGACY
float clip_plane[4];
copy_v3_v3(clip_plane, rv3d->viewinv[2]);
clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], rv3d->twmat[3]);
clip_plane[3] -= 0.02f * size; /* clip just a bit more so view aligned arcs are not visible */
#endif
gpuPopMatrix(); /* we setup our own matrix, pop previously set twmat */
#if !APPLE_LEGACY
immUnbindProgram();
immBindBuiltinProgram(GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR);
immUniform4fv("ClipPlane", clip_plane);
glEnable(GL_CLIP_DISTANCE0);
#endif
/* Z circle */
if (drawflags & MAN_ROT_Z) {
@@ -1152,7 +1158,9 @@ static void draw_manipulator_rotate(
else manipulator_setcolor(v3d, 'Z', colcode, 255);
twmat_to_rotation_axis_mat(rv3d->twmat, 2, ortho, axis_model_mat);
#if !APPLE_LEGACY
immUniformMatrix4fv("ModelMatrix", axis_model_mat);
#endif
gpuPushMatrix();
gpuMultMatrix3D(axis_model_mat);
@@ -1165,7 +1173,9 @@ static void draw_manipulator_rotate(
else manipulator_setcolor(v3d, 'X', colcode, 255);
twmat_to_rotation_axis_mat(rv3d->twmat, 0, ortho, axis_model_mat);
#if !APPLE_LEGACY
immUniformMatrix4fv("ModelMatrix", axis_model_mat);
#endif
gpuPushMatrix();
gpuMultMatrix3D(axis_model_mat);
@@ -1178,7 +1188,9 @@ static void draw_manipulator_rotate(
else manipulator_setcolor(v3d, 'Y', colcode, 255);
twmat_to_rotation_axis_mat(rv3d->twmat, 1, ortho, axis_model_mat);
#if !APPLE_LEGACY
immUniformMatrix4fv("ModelMatrix", axis_model_mat);
#endif
gpuPushMatrix();
gpuMultMatrix3D(axis_model_mat);
@@ -1186,7 +1198,10 @@ static void draw_manipulator_rotate(
gpuPopMatrix();
}
#if !APPLE_LEGACY
glDisable(GL_CLIP_DISTANCE0);
#endif
gpuPushMatrix(); /* to balance final pop at end of function */
}
else {

View File

@@ -3,11 +3,7 @@ uniform mat4 ModelViewProjectionMatrix;
uniform mat4 ModelMatrix;
uniform vec4 ClipPlane;
#if __VERSION__ == 120
attribute vec3 pos;
#else
in vec3 pos;
#endif
in vec3 pos;
void main()
{