diff options
author | mano-wii <germano.costa@ig.com.br> | 2019-04-03 02:03:16 +0300 |
---|---|---|
committer | mano-wii <germano.costa@ig.com.br> | 2019-04-03 02:03:16 +0300 |
commit | 78bf358bf0805f69bc7317c4c5d1e10c0ece4dca (patch) | |
tree | 5a0ee6ab4a6864592c95ae2f97b284bcf9b004cd /modules/snap_context/utils_shader.py | |
parent | ad2ee4cd6f97d2bfbe6a77e76baa5ad4de8e4b34 (diff) |
Remove support for blender2.79blender2.7
The addon does not work on all OS.
And now there is an improved version of it for blender2.8.
Diffstat (limited to 'modules/snap_context/utils_shader.py')
-rw-r--r-- | modules/snap_context/utils_shader.py | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/modules/snap_context/utils_shader.py b/modules/snap_context/utils_shader.py deleted file mode 100644 index 1758585a..00000000 --- a/modules/snap_context/utils_shader.py +++ /dev/null @@ -1,85 +0,0 @@ -# ##### 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 3 -# 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, see <http://www.gnu.org/licenses/>. -# -# ##### END GPL LICENSE BLOCK ##### - - -import bgl - -def check_shaderError(shader, flag, isProgram, errorMessage): - success = bgl.Buffer(bgl.GL_INT, 1) - - if isProgram: - bgl.glGetProgramiv(shader, flag, success) - else: - bgl.glGetShaderiv(shader, flag, success) - - if success[0] == bgl.GL_FALSE: - import numpy as np - import ctypes - - offset = bgl.Buffer(bgl.GL_INT, 1, (ctypes.c_int32 * 1).from_address(0)) - error = bgl.Buffer(bgl.GL_BYTE, 1024) - if isProgram: - bgl.glGetProgramInfoLog(shader, 1024, offset, error) - print(errorMessage, np.bytes_(error).decode("utf-8")) - else: - bgl.glGetShaderInfoLog(shader, 1024, offset, error) - print(errorMessage, np.bytes_(error).decode("utf-8")) - - del offset - raise #RuntimeError(errorMessage, bgl.glGetShaderInfoLog(shader)) - - -def create_shader(source, shaderType): - shader = bgl.glCreateShader(shaderType) - - if shader == 0: - raise RuntimeError("Error: Shader creation failed!") - - bgl.glShaderSource(shader, source) - bgl.glCompileShader(shader) - - check_shaderError(shader, bgl.GL_COMPILE_STATUS, False, "Error: Shader compilation failed:") - - return shader - - -class Shader(): - def __init__(self, vertexcode, geomcode, fragcode): - self.program = bgl.glCreateProgram() - self.shaders = [] - - if vertexcode: - self.shaders.append(create_shader(vertexcode, bgl.GL_VERTEX_SHADER)) - if geomcode: - self.shaders.append(create_shader(geomcode, bgl.GL_GEOMETRY_SHADER)) - if fragcode: - self.shaders.append(create_shader(fragcode, bgl.GL_FRAGMENT_SHADER)) - - for shad in self.shaders: - bgl.glAttachShader(self.program, shad) - - bgl.glLinkProgram(self.program) - check_shaderError(self.program, bgl.GL_LINK_STATUS, True, "Error: Program linking failed:") - bgl.glValidateProgram(self.program) - check_shaderError(self.program, bgl.GL_VALIDATE_STATUS, True, "Error: Program is invalid:") - - def __del__(self): - for shad in self.shaders: - bgl.glDetachShader(self.program, shad) - bgl.glDeleteShader(shad) - bgl.glDeleteProgram(self.program) - #print('shader_del') |