[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50904] branches/soc-2012-swiss_cheese: OpenGL Usage Polcy fixes: glBlendFunc
Jason Wilkins
Jason.A.Wilkins at gmail.com
Wed Sep 26 14:17:29 CEST 2012
Revision: 50904
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50904
Author: jwilkins
Date: 2012-09-26 12:17:28 +0000 (Wed, 26 Sep 2012)
Log Message:
-----------
OpenGL Usage Polcy fixes: glBlendFunc
Default value is GL_ALPHA/GL_ONE_MINUS_ALPHA.
No need to set this as blend function if that is what is needed.
Always return value to this if using a non-default blend function.
Modified Paths:
--------------
branches/soc-2012-swiss_cheese/intern/cycles/device/device.cpp
branches/soc-2012-swiss_cheese/intern/cycles/device/device_cuda.cpp
branches/soc-2012-swiss_cheese/source/blender/editors/interface/interface_draw.c
branches/soc-2012-swiss_cheese/source/blender/editors/mask/mask_draw.c
branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_draw.c
branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate_glsl.c
branches/soc-2012-swiss_cheese/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
Modified: branches/soc-2012-swiss_cheese/intern/cycles/device/device.cpp
===================================================================
--- branches/soc-2012-swiss_cheese/intern/cycles/device/device.cpp 2012-09-26 11:16:27 UTC (rev 50903)
+++ branches/soc-2012-swiss_cheese/intern/cycles/device/device.cpp 2012-09-26 12:17:28 UTC (rev 50904)
@@ -115,7 +115,7 @@
if(transparent) {
glEnable(GL_BLEND);
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); /* non-standard blend function */
}
glPixelZoom((float)width/(float)w, (float)height/(float)h);
@@ -132,8 +132,10 @@
glRasterPos2f(0.0f, 0.0f);
glPixelZoom(1.0f, 1.0f);
- if(transparent)
+ if(transparent) {
glDisable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* reset blender default */
+ }
}
Device *Device::create(DeviceInfo& info, bool background, int threads)
Modified: branches/soc-2012-swiss_cheese/intern/cycles/device/device_cuda.cpp
===================================================================
--- branches/soc-2012-swiss_cheese/intern/cycles/device/device_cuda.cpp 2012-09-26 11:16:27 UTC (rev 50903)
+++ branches/soc-2012-swiss_cheese/intern/cycles/device/device_cuda.cpp 2012-09-26 12:17:28 UTC (rev 50904)
@@ -778,12 +778,12 @@
glBindTexture(GL_TEXTURE_2D, pmem.cuTexId);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, (void*)offset);
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
-
+
glEnable(GL_TEXTURE_2D);
-
+
if(transparent) {
glEnable(GL_BLEND);
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); /* non-standard blend function */
}
glColor3f(1.0f, 1.0f, 1.0f);
@@ -806,9 +806,11 @@
glPopMatrix();
- if(transparent)
+ if(transparent) {
glDisable(GL_BLEND);
-
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* reset blender default */
+ }
+
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);
Modified: branches/soc-2012-swiss_cheese/source/blender/editors/interface/interface_draw.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/editors/interface/interface_draw.c 2012-09-26 11:16:27 UTC (rev 50903)
+++ branches/soc-2012-swiss_cheese/source/blender/editors/interface/interface_draw.c 2012-09-26 12:17:28 UTC (rev 50904)
@@ -667,16 +667,14 @@
float x, float y, float w, float h, float *data, int res, const short is_line)
{
int i;
-
- if (is_line) {
+ if (is_line) {
glLineWidth(1.5);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE); /* non-standard blend function */
gpuCurrentColor4f(r, g, b, alpha);
/* curve outline */
- glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glEnable(GL_LINE_SMOOTH);
gpuBegin(GL_LINE_STRIP);
for (i = 0; i < res; i++) {
@@ -687,36 +685,38 @@
glDisable(GL_LINE_SMOOTH);
glLineWidth(1.0);
+
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* reset blender default */
}
else {
/* under the curve */
- glBlendFunc(GL_SRC_ALPHA, GL_ONE); /* non-standard blend function */
- gpuCurrentColor4f(r, g, b, alpha);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ gpuCurrentColor4f(r, g, b, alpha);
glShadeModel(GL_FLAT);
- gpuBegin(GL_TRIANGLE_STRIP); // DOODLE: line graph drawn using quads, locking done by function callee
- gpuVertex2f(x, y);
- gpuVertex2f(x, y + (data[0] * h));
+ gpuBegin(GL_TRIANGLE_STRIP); // DOODLE: line graph drawn using quads, locking done by function callee
+ gpuVertex2f(x, y);
+ gpuVertex2f(x, y + (data[0] * h));
for (i = 1; i < res; i++) {
float x2 = x + i * (w / (float)res);
- gpuVertex2f(x2, y + (data[i] * h));
- gpuVertex2f(x2, y);
+ gpuVertex2f(x2, y + (data[i] * h));
+ gpuVertex2f(x2, y);
}
- gpuEnd();
+ gpuEnd();
- /* curve outline */
- gpuCurrentColor4x(CPACK_BLACK, 0.250f);
+ /* curve outline */
+ gpuCurrentColor4x(CPACK_BLACK, 0.250f);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* reset blender default */
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* reset blender default */
glEnable(GL_LINE_SMOOTH);
- gpuBegin(GL_LINE_STRIP); // DOODLE: line graph drawn using a line strip, locking done by callee
+ gpuBegin(GL_LINE_STRIP); // DOODLE: line graph drawn using a line strip, locking done by callee
for (i = 0; i < res; i++) {
float x2 = x + i * (w / (float)res);
- gpuVertex2f(x2, y + (data[i] * h));
+ gpuVertex2f(x2, y + (data[i] * h));
}
- gpuEnd();
+ gpuEnd();
glDisable(GL_LINE_SMOOTH);
}
@@ -1456,7 +1456,6 @@
/* grid, hsv uses different grid */
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
gpuCurrentColor4x(CPACK_BLACK, 0.188f);
ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 0.1666666f);
glDisable(GL_BLEND);
Modified: branches/soc-2012-swiss_cheese/source/blender/editors/mask/mask_draw.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/editors/mask/mask_draw.c 2012-09-26 11:16:27 UTC (rev 50903)
+++ branches/soc-2012-swiss_cheese/source/blender/editors/mask/mask_draw.c 2012-09-26 12:17:28 UTC (rev 50904)
@@ -388,7 +388,6 @@
if (is_smooth) {
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
feather_points = BKE_mask_spline_feather_differentiated_points_with_resolution(spline, width, height, &tot_feather_point, (is_fill != FALSE));
Modified: branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_draw.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_draw.c 2012-09-26 11:16:27 UTC (rev 50903)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_draw.c 2012-09-26 12:17:28 UTC (rev 50904)
@@ -1281,7 +1281,7 @@
enable_blend();
if (!GMS.lastblendfuncdefault) {
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* set blender default */
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* set blend function default */
GMS.lastblendfuncdefault = GL_TRUE;
}
}
Modified: branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate_glsl.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate_glsl.c 2012-09-26 11:16:27 UTC (rev 50903)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate_glsl.c 2012-09-26 12:17:28 UTC (rev 50904)
@@ -97,8 +97,9 @@
bufferDataGLSL* bufferData = GPU_IMMEDIATE->bufferData;
offset = 0;
-glEnable(GL_BLEND);
-glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ glEnable(GL_BLEND); /* XXX: why? */
+
GPU_CHECK_NO_ERROR();
/* setup vertex arrays
Modified: branches/soc-2012-swiss_cheese/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
===================================================================
--- branches/soc-2012-swiss_cheese/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp 2012-09-26 11:16:27 UTC (rev 50903)
+++ branches/soc-2012-swiss_cheese/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp 2012-09-26 12:17:28 UTC (rev 50904)
@@ -154,7 +154,7 @@
glDisable(GL_BLEND);
glDisable(GL_ALPHA_TEST);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* set default blend function */
//m_last_alphablend = GPU_BLEND_SOLID;
GPU_set_material_alpha_blend(GPU_BLEND_SOLID);
More information about the Bf-blender-cvs
mailing list