[Bf-blender-cvs] [288d8f3] soc-2013-viewport_fx: Added GPU_clipping module which implements state for the common clipping state. Also added preliminary support for clipping in the basic aspect, but only for the compatibility profile (i.e. still need to implement GLSL clipping planes)

jwilkins noreply at git.blender.org
Sat Feb 15 20:36:51 CET 2014


Commit: 288d8f3ed74bda30ca15570ad8daec810e299667
Author: jwilkins
Date:   Sat Feb 15 13:36:34 2014 -0600
https://developer.blender.org/rB288d8f3ed74bda30ca15570ad8daec810e299667

Added GPU_clipping module which implements state for the common clipping state.  Also added preliminary support for clipping in the basic aspect, but only for the compatibility profile (i.e. still need to implement GLSL clipping planes)

===================================================================

M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/editors/transform/transform_manipulator.c
M	source/blender/gpu/CMakeLists.txt
M	source/blender/gpu/GPU_basic.h
A	source/blender/gpu/GPU_clipping.h
M	source/blender/gpu/GPU_common.h
M	source/blender/gpu/GPU_deprecated.h
M	source/blender/gpu/GPU_matrix.h
M	source/blender/gpu/intern/gpu_basic.c
A	source/blender/gpu/intern/gpu_clipping.c
A	source/blender/gpu/intern/gpu_clipping_intern.h
M	source/blender/gpu/intern/gpu_common.c
M	source/blender/gpu/intern/gpu_common_intern.h
M	source/blender/gpu/intern/gpu_init_exit.c
M	source/blender/gpu/intern/gpu_matrix.c
M	source/blender/gpu/shaders/gpu_shader_common_constants.glsl
M	source/blender/gpu/shaders/gpu_shader_common_uniforms.glsl

===================================================================

diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 4ae4418..6b2f1de 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -82,6 +82,7 @@
 
 #include "GPU_basic.h"
 #include "GPU_blender_aspect.h"
+#include "GPU_clipping.h"
 #include "GPU_colors.h"
 #include "GPU_draw.h"
 #include "GPU_extensions.h"
@@ -176,46 +177,27 @@ static void view3d_draw_clipping(RegionView3D *rv3d)
 
 void ED_view3d_clipping_set(RegionView3D *rv3d)
 {
-#if defined(WITH_GL_PROFILE_COMPAT)
-	if (GPU_PROFILE_COMPAT) {
-		double plane[4];
-		const unsigned int tot = (rv3d->viewlock & RV3D_BOXCLIP) ? 4 : 6;
-		unsigned int a;
+	GPUplane plane[6];
+	const unsigned int tot = (rv3d->viewlock & RV3D_BOXCLIP) ? 4 : 6;
+	unsigned int a;
 
-		for (a = 0; a < tot; a++) {
-			copy_v4db_v4fl(plane, rv3d->clip[a]);
-			glClipPlane(GL_CLIP_PLANE0 + a, plane);
-			glEnable(GL_CLIP_PLANE0 + a);
-		}
+	// XXX jwilkins: this copy would not be needed if planes were kept as doubles
+	for (a = 0; a < tot; a++) {
+		copy_v4db_v4fl(plane[a].equation, rv3d->clip[a]);
 	}
-#endif
+
+	GPU_set_clip_planes(tot, plane);
 }
 
 /* use these to temp disable/enable clipping when 'rv3d->rflag & RV3D_CLIPPING' is set */
 void ED_view3d_clipping_disable(void)
 {
-#if defined(WITH_GL_PROFILE_COMPAT)
-	if (GPU_PROFILE_COMPAT) {
-		unsigned int a;
-
-		for (a = 0; a < 6; a++) {
-			glDisable(GL_CLIP_PLANE0 + a);
-		}
-	}
-#endif
+	GPU_aspect_disable(GPU_ASPECT_BASIC, GPU_BASIC_CLIPPING);
 }
 
 void ED_view3d_clipping_enable(void)
 {
-#if defined(WITH_GL_PROFILE_COMPAT)
-	if (GPU_PROFILE_COMPAT) {
-		unsigned int a;
-
-		for (a = 0; a < 6; a++) {
-			glEnable(GL_CLIP_PLANE0 + a);
-		}
-	}
-#endif
+	GPU_aspect_enable(GPU_ASPECT_BASIC, GPU_BASIC_CLIPPING);
 }
 
 static bool view3d_clipping_test(const float co[3], float clip[6][4])
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index e3dcb77..8f93c1e 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -67,7 +67,9 @@
 #include "BKE_editmesh.h"
 #include "BKE_lattice.h"
 
+#include "GPU_basic.h"
 #include "GPU_blender_aspect.h"
+#include "GPU_clipping.h"
 #include "GPU_primitives.h"
 #include "GPU_matrix.h"
 #include "GPU_select.h"
@@ -967,9 +969,6 @@ static void postOrtho(int ortho)
 
 static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, int drawflags, int combo)
 {
-#if defined(WITH_GL_PROFILE_COMPAT)
-	double plane[4];
-#endif
 	float matt[4][4];
 	float size;
 	float cywid = 0.33f * 0.01f * (float)U.tw_handlesize;
@@ -992,14 +991,13 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
 	gpuPushMatrix();
 	gpuTranslate(rv3d->twmat[3][0], rv3d->twmat[3][1], rv3d->twmat[3][2]);
 
-#if defined(WITH_GL_PROFILE_COMPAT)
-	if (GPU_PROFILE_COMPAT && arcs) {
-		/* clipplane makes nice handles, calc here because of multmatrix but with translate! */
-		copy_v3db_v3fl(plane, rv3d->viewinv[2]);
-		plane[3] = -0.02f * size; // clip just a bit more
-		glClipPlane(GL_CLIP_PLANE0, plane);
+	if (arcs) {
+		/* clip plane makes nice handles, calc here because of multmatrix but with translate! */
+		GPUplane plane;
+		copy_v3db_v3fl(plane.equation, rv3d->viewinv[2]);
+		plane.equation[3] = -0.02f * size; // clip just a bit more
+		GPU_set_clip_planes(1, &plane);
 	}
-#endif
 
 	/* sets view screen aligned */
 	gpuRotateVector(RAD2DEGF(-2.0f * saacos(rv3d->viewquat[0])), rv3d->viewquat+1);
@@ -1064,11 +1062,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
 
 	// donut arcs
 	if (arcs) {
-#if defined(WITH_GL_PROFILE_COMPAT)
-		if (GPU_PROFILE_COMPAT) {
-			glEnable(GL_CLIP_PLANE0);
-		}
-#endif
+		GPU_aspect_enable(GPU_ASPECT_BASIC, GPU_BASIC_CLIPPING);
 
 		/* Z circle */
 		if (drawflags & MAN_ROT_Z) {
@@ -1113,11 +1107,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
 			postOrtho(ortho);
 		}
 
-#if defined(WITH_GL_PROFILE_COMPAT)
-		if (GPU_PROFILE_COMPAT) {
-			glDisable(GL_CLIP_PLANE0);
-		}
-#endif
+		GPU_aspect_disable(GPU_ASPECT_BASIC, GPU_BASIC_CLIPPING);
 	}
 	else /* !arcs */ {
 		/* axes */
@@ -1161,11 +1151,10 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
 		}
 
 		if (moving) {
-#if defined(WITH_GL_PROFILE_COMPAT)
-		if (GPU_PROFILE_COMPAT) {
-			glEnable(GL_CLIP_PLANE0);
-		}
-#endif
+			if (arcs) {
+				GPU_aspect_enable(GPU_ASPECT_BASIC, GPU_BASIC_CLIPPING);
+			}
+
 			/* Z circle */
 			if (drawflags & MAN_ROT_Z) {
 				preOrthoFront(ortho, matt, 2);
@@ -1211,11 +1200,9 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
 				postOrtho(ortho);
 			}
 
-#if defined(WITH_GL_PROFILE_COMPAT)
-			if (GPU_PROFILE_COMPAT && arcs) {
-				glDisable(GL_CLIP_PLANE0);
+			if (arcs) {
+				GPU_aspect_disable(GPU_ASPECT_BASIC, GPU_BASIC_CLIPPING);
 			}
-#endif
 		}
 
 		/* Z handle on X axis */
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index 827fe2d..9141305 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -48,6 +48,7 @@ set(INTERN_INC
 	intern/gpu_aspect_intern.h
 	intern/gpu_basic_intern.h
 	intern/gpu_blender_aspect_intern.h
+	intern/gpu_clipping_intern.h
 	intern/gpu_common_intern.h
 	intern/gpu_codegen.h
 	intern/gpu_extensions_intern.h
@@ -96,6 +97,7 @@ set(SRC
 	intern/gpu_basic.c
 	intern/gpu_blender_aspect.c
 	intern/gpu_buffers.c
+	intern/gpu_clipping.c
 	intern/gpu_codegen.c
 	intern/gpu_common.c
 	intern/gpu_debug.c
@@ -120,6 +122,7 @@ set(SRC
 	GPU_basic.h
 	GPU_blender_aspect.h
 	GPU_buffers.h
+	GPU_clipping.h
 	GPU_colors.h
 	GPU_common.h
 	GPU_deprecated.h
diff --git a/source/blender/gpu/GPU_basic.h b/source/blender/gpu/GPU_basic.h
index e8cc014..161ad6b 100644
--- a/source/blender/gpu/GPU_basic.h
+++ b/source/blender/gpu/GPU_basic.h
@@ -49,10 +49,11 @@ typedef enum GPUBasicOption {
 	GPU_BASIC_LOCAL_VIEWER   = (1<<3), /* use for orthographic projection         */
 	GPU_BASIC_SMOOTH         = (1<<4), /* use smooth shading                      */
 	GPU_BASIC_ALPHATEST      = (1<<5), /* use alpha test                          */
+	GPU_BASIC_CLIPPING       = (1<<6), /* use clipping                            */
 
-	GPU_BASIC_FAST_LIGHTING  = (1<<6), /* use faster lighting (set automatically) */
+	GPU_BASIC_FAST_LIGHTING  = (1<<7), /* use faster lighting (set automatically) */
 
-	GPU_BASIC_OPTIONS_NUM         = 7,
+	GPU_BASIC_OPTIONS_NUM         = 8,
 	GPU_BASIC_OPTION_COMBINATIONS = (1<<GPU_BASIC_OPTIONS_NUM)
 } GPUBasicOption;
 
diff --git a/source/blender/gpu/GPU_clipping.h b/source/blender/gpu/GPU_clipping.h
new file mode 100644
index 0000000..519f3a9
--- /dev/null
+++ b/source/blender/gpu/GPU_clipping.h
@@ -0,0 +1,57 @@
+#ifndef _GPU_CLIPPING_H_
+#define _GPU_CLIPPING_H_
+
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2014 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Jason Wilkins
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/gpu/GPU_clipping.h
+ *   \ingroup gpu
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct GPUplane {
+	double equation[4];
+} GPUplane;
+
+/* Set clipping planes and also applies appropriate transformations */
+void GPU_set_clip_planes(int clip_plane_count, const GPUplane clip_planes[]);
+
+int GPU_get_clip_planes(GPUplane clip_planes_out[]);
+
+/* Set clip planes without transforming them.
+   Suitable for restoring a backup copy of previous clip plane state.
+   Keeps clip planes from getting transformed twice. */
+void GPU_restore_clip_planes(int clip_plane_count, const GPUplane clip_planes[]);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _GPU_CLIPPING_H_ */
diff --git a/source/blender/gpu/GPU_common.h b/source/blender/gpu/GPU_common.h
index b1e2aca..db4d47f 100644
--- a/source/blender/gpu/GPU_common.h
+++ b/source/blender/gpu/GPU_common.h
@@ -42,9 +42,11 @@ extern "C" {
 
 
 
-#define GPU_MAX_COMMON_TEXCOORDS 1
-#define GPU_MAX_COMMON_SAMPLERS  1
-#define GPU_MAX_COMMON_LIGHTS    8
+// XXX jwilkins: do these belong here?
+#define GPU_MAX_COMMON_TEXCOORDS   1
+#define GPU_MAX_COMMON_SAMPLERS    1
+#define GPU_MAX_COMMON_LIGHTS      8
+#define GPU_MAX_COMMON_CLIP_PLANES 6
 
 
 
diff --git a/source/blender/gpu/GPU_deprecated.h b/source/blender/gpu/GPU_deprecated.h
index 2598525..7cf0ced 100644
--- a/source/blender/gpu/GPU_deprecated.h
+++ b/source/blender/gpu/GPU_deprecated.h
@@ -630,4 +630,7 @@
 #undef glLoadName
 #define glLoadName DO_NOT_USE_glLoadName
 
+#undef glClipPlane
+#define glClipPlane DO_NOT_USE_glClipPlane
+
 #endif /* _GPU_DEPRECATED_H_ */
diff --git a/source/blender/gpu/GPU_matrix.h b/source/blender/gpu/GPU_matrix.h
index be45eee..bfa48a9 100644
--- a/source/blender/gpu/GPU_matrix.h
+++ b/source/blender/gpu/GPU_matrix.h
@@ -75,6 +75,7 @@ GLboolean gpuUnProject(const GLfloat win[3], const GLfloat model[16], const GLfl
 
 void GPU_feedback_vertex_3fv(GLenum type, GLfloat x, GLfloat y, GLfloat z,            GLfloat out[3]);
 void GPU_feedback_vertex_4fv(GLenum type, GLfloat x, GLfloat y, GLfloat z, GLfloat w, GLfloat out[4]);
+void GPU_feedback_vertex_4dv(GLenum type, GLdouble x, 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list