本文整理汇总了Python中bgl.GL_FLOAT属性的典型用法代码示例。如果您正苦于以下问题:Python bgl.GL_FLOAT属性的具体用法?Python bgl.GL_FLOAT怎么用?Python bgl.GL_FLOAT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类bgl
的用法示例。
在下文中一共展示了bgl.GL_FLOAT属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: enable
# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import GL_FLOAT [as 别名]
def enable(self):
try:
if DEBUG_PRINT:
print('enabling shader <==================')
if self.checkErrors:
self.drawing.glCheckError('something broke before enabling shader program (%s, %d)' % (self.name,self.shaderProg))
bgl.glUseProgram(self.shaderProg)
if self.checkErrors:
self.drawing.glCheckError('something broke after enabling shader program (%s,%d)' % (self.name,self.shaderProg))
# special uniforms
# - uMVPMatrix works around deprecated gl_ModelViewProjectionMatrix
if 'uMVPMatrix' in self.shaderVars:
mvpmatrix = bpy.context.region_data.perspective_matrix
mvpmatrix_buffer = bgl.Buffer(bgl.GL_FLOAT, [4,4], mvpmatrix)
self.assign('uMVPMatrix', mvpmatrix_buffer)
if self.funcStart: self.funcStart(self)
except Exception as e:
print('Error with using shader: ' + str(e))
bgl.glUseProgram(0)
示例2: _update_texture
# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import GL_FLOAT [as 别名]
def _update_texture(self, scene):
if self._transparent:
gl_format = bgl.GL_RGBA
internal_format = bgl.GL_RGBA32F
else:
gl_format = bgl.GL_RGB
internal_format = bgl.GL_RGB32F
bgl.glActiveTexture(bgl.GL_TEXTURE0)
bgl.glBindTexture(bgl.GL_TEXTURE_2D, self.texture_id)
bgl.glTexImage2D(bgl.GL_TEXTURE_2D, 0, internal_format, self._width, self._height,
0, gl_format, bgl.GL_FLOAT, self.buffer)
bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_WRAP_S, bgl.GL_CLAMP_TO_EDGE)
bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_WRAP_T, bgl.GL_CLAMP_TO_EDGE)
bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MIN_FILTER, bgl.GL_NEAREST)
mag_filter = bgl.GL_NEAREST if scene.luxcore.viewport.mag_filter == "NEAREST" else bgl.GL_LINEAR
bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MAG_FILTER, mag_filter)
bgl.glBindTexture(bgl.GL_TEXTURE_2D, NULL)
示例3: gl_matrix_to_buffer
# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import GL_FLOAT [as 别名]
def gl_matrix_to_buffer(m):
tempMat = [m[i][j] for i in range(4) for j in range(4)]
return bgl.Buffer(bgl.GL_FLOAT, 16, tempMat)
# ===== DRAWING CALLBACKS ===== #
示例4: assign_buffer
# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import GL_FLOAT [as 别名]
def assign_buffer(self, varName, varValue):
return self.assign(varName, bgl.Buffer(bgl.GL_FLOAT, [4,4], varValue))
# https://www.opengl.org/sdk/docs/man/html/glVertexAttrib.xhtml
# https://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml
示例5: to_bglMatrix
# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import GL_FLOAT [as 别名]
def to_bglMatrix(mat):
# return bgl.Buffer(
# bgl.GL_FLOAT, len(mat)**2, [v for r in mat for v in r]
# )
return bgl.Buffer(bgl.GL_FLOAT, [len(mat), len(mat)], mat)
示例6: get_clip_planes
# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import GL_FLOAT [as 别名]
def get_clip_planes(rv3d):
#(int)(&((struct RegionView3D *)0)->rflag) == 842
#(int)(&((struct RegionView3D *)0)->clip) == 464
rv3d_ptr = rv3d.as_pointer()
rflag = ctypes.c_short.from_address(rv3d_ptr + 842).value
if rflag & 4: # RV3D_CLIPPING
clip = (6 * (4 * ctypes.c_float)).from_address(rv3d_ptr + 464)
return bgl.Buffer(bgl.GL_FLOAT, (6, 4), clip)
示例7: __init__
# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import GL_FLOAT [as 别名]
def __init__(self, engine, context, scene):
filmsize = utils.calc_filmsize(scene, context)
self._width, self._height = filmsize
self._border = utils.calc_blender_border(scene, context)
self._offset_x, self._offset_y = self._calc_offset(context, scene, self._border)
self._pixel_size = int(scene.luxcore.viewport.pixel_size)
if utils.is_valid_camera(scene.camera) and not utils.in_material_shading_mode(context):
pipeline = scene.camera.data.luxcore.imagepipeline
self._transparent = pipeline.transparent_film
else:
self._transparent = False
if self._transparent:
bufferdepth = 4
self._buffertype = bgl.GL_RGBA
self._output_type = pyluxcore.FilmOutputType.RGBA_IMAGEPIPELINE
else:
bufferdepth = 3
self._buffertype = bgl.GL_RGB
self._output_type = pyluxcore.FilmOutputType.RGB_IMAGEPIPELINE
self.buffer = bgl.Buffer(bgl.GL_FLOAT, [self._width * self._height * bufferdepth])
self._init_opengl(engine, scene)
# Denoiser
self._noisy_file_path = self._make_denoiser_filepath("noisy")
self._albedo_file_path = self._make_denoiser_filepath("albedo")
self._normal_file_path = self._make_denoiser_filepath("normal")
self._denoised_file_path = self._make_denoiser_filepath("denoised")
current_dir = dirname(os.path.realpath(__file__))
addon_dir = dirname(current_dir) # Go up one level
self._denoiser_path = which("oidnDenoise",
path=os.path.join(addon_dir, "bin") + os.pathsep + os.environ["PATH"])
self._denoiser_process = None
self.denoiser_result_cached = False
示例8: __init__
# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import GL_FLOAT [as 别名]
def __init__(self, name, srcVertex, srcFragment, funcStart=None, funcEnd=None, checkErrors=True, bindTo0=None):
self.drawing = Drawing.get_instance()
self.name = name
self.shaderProg = bgl.glCreateProgram()
self.shaderVert = bgl.glCreateShader(bgl.GL_VERTEX_SHADER)
self.shaderFrag = bgl.glCreateShader(bgl.GL_FRAGMENT_SHADER)
self.checkErrors = checkErrors
srcVertex = '\n'.join(l.strip() for l in srcVertex.split('\n'))
srcFragment = '\n'.join(l.strip() for l in srcFragment.split('\n'))
bgl.glShaderSource(self.shaderVert, srcVertex)
bgl.glShaderSource(self.shaderFrag, srcFragment)
dprint('RetopoFlow Shader Info: %s (%d)' % (self.name,self.shaderProg))
logv = self.shader_compile(name, self.shaderVert)
logf = self.shader_compile(name, self.shaderFrag)
if len(logv.strip()):
dprint(' vert log:\n' + '\n'.join((' '+l) for l in logv.splitlines()))
if len(logf.strip()):
dprint(' frag log:\n' + '\n'.join((' '+l) for l in logf.splitlines()))
bgl.glAttachShader(self.shaderProg, self.shaderVert)
bgl.glAttachShader(self.shaderProg, self.shaderFrag)
if bindTo0:
bgl.glBindAttribLocation(self.shaderProg, 0, bindTo0)
bgl.glLinkProgram(self.shaderProg)
self.shaderVars = {}
lvars = [l for l in srcVertex.splitlines() if l.startswith('in ')]
lvars += [l for l in srcVertex.splitlines() if l.startswith('attribute ')]
lvars += [l for l in srcVertex.splitlines() if l.startswith('uniform ')]
lvars += [l for l in srcFragment.splitlines() if l.startswith('uniform ')]
for l in lvars:
m = re.match('^(?P<qualifier>[^ ]+) +(?P<type>[^ ]+) +(?P<name>[^ ;]+)', l)
assert m
m = m.groupdict()
q,t,n = m['qualifier'],m['type'],m['name']
locate = bgl.glGetAttribLocation if q in {'in','attribute'} else bgl.glGetUniformLocation
if n in self.shaderVars: continue
self.shaderVars[n] = {
'qualifier': q,
'type': t,
'location': locate(self.shaderProg, n),
'reported': False,
}
dprint(' attribs: ' + ', '.join((k + ' (%d)'%self.shaderVars[k]['location']) for k in self.shaderVars if self.shaderVars[k]['qualifier'] in {'in','attribute'}))
dprint(' uniforms: ' + ', '.join((k + ' (%d)'%self.shaderVars[k]['location']) for k in self.shaderVars if self.shaderVars[k]['qualifier'] in {'uniform'}))
self.funcStart = funcStart
self.funcEnd = funcEnd
self.mvpmatrix_buffer = bgl.Buffer(bgl.GL_FLOAT, [4,4])
示例9: draw
# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import GL_FLOAT [as 别名]
def draw(self, opts):
if self.count == 0:
return
if self.gltype == bgl.GL_LINES:
if opts.get('line width', 1.0) <= 0:
return
elif self.gltype == bgl.GL_POINTS:
if opts.get('point size', 1.0) <= 0:
return
nosel = opts.get('no selection', False)
mx, my, mz = opts.get('mirror x', False), opts.get(
'mirror y', False), opts.get('mirror z', False)
focus = opts.get('focus mult', 1.0)
bmeshShader.assign('focus_mult', focus)
bmeshShader.assign('use_selection', 0.0 if nosel else 1.0)
bmeshShader.assign('cull_backfaces', 1.0 if opts.get('cull backfaces', False) else 0.0)
bmeshShader.assign('alpha_backface', opts.get('alpha backface', 0.5))
bmeshShader.assign('normal_offset', opts.get('normal offset', 0.0))
bmeshShader.vertexAttribPointer(
self.vbo_pos, 'vert_pos', 3, bgl.GL_FLOAT, buf=buf_zero)
self._check_error('draw: vertex attrib array pos')
bmeshShader.vertexAttribPointer(
self.vbo_norm, 'vert_norm', 3, bgl.GL_FLOAT, buf=buf_zero)
self._check_error('draw: vertex attrib array norm')
bmeshShader.vertexAttribPointer(
self.vbo_sel, 'selected', 1, bgl.GL_FLOAT, buf=buf_zero)
self._check_error('draw: vertex attrib array sel')
bgl.glBindBuffer(bgl.GL_ELEMENT_ARRAY_BUFFER, self.vbo_idx)
self._check_error('draw: element array buffer idx')
glSetOptions(self.options_prefix, opts)
self._draw(1, 1, 1)
if mx or my or mz:
glSetOptions('%s mirror' % self.options_prefix, opts)
if mx:
self._draw(-1, 1, 1)
if my:
self._draw(1, -1, 1)
if mz:
self._draw(1, 1, -1)
if mx and my:
self._draw(-1, -1, 1)
if mx and mz:
self._draw(-1, 1, -1)
if my and mz:
self._draw(1, -1, -1)
if mx and my and mz:
self._draw(-1, -1, -1)
bmeshShader.disableVertexAttribArray('vert_pos')
bmeshShader.disableVertexAttribArray('vert_norm')
bmeshShader.disableVertexAttribArray('selected')
bgl.glBindBuffer(bgl.GL_ELEMENT_ARRAY_BUFFER, 0)
bgl.glBindBuffer(bgl.GL_ARRAY_BUFFER, 0)
示例10: _init_opengl
# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import GL_FLOAT [as 别名]
def _init_opengl(self, engine, scene):
# Create texture
self.texture = bgl.Buffer(bgl.GL_INT, 1)
bgl.glGenTextures(1, self.texture)
self.texture_id = self.texture[0]
# Bind shader that converts from scene linear to display space,
# use the scene's color management settings.
engine.bind_display_space_shader(scene)
shader_program = bgl.Buffer(bgl.GL_INT, 1)
bgl.glGetIntegerv(bgl.GL_CURRENT_PROGRAM, shader_program)
# Generate vertex array
self.vertex_array = bgl.Buffer(bgl.GL_INT, 1)
bgl.glGenVertexArrays(1, self.vertex_array)
bgl.glBindVertexArray(self.vertex_array[0])
texturecoord_location = bgl.glGetAttribLocation(shader_program[0], "texCoord")
position_location = bgl.glGetAttribLocation(shader_program[0], "pos")
bgl.glEnableVertexAttribArray(texturecoord_location)
bgl.glEnableVertexAttribArray(position_location)
# Generate geometry buffers for drawing textured quad
width = self._width * self._pixel_size
height = self._height * self._pixel_size
position = [
self._offset_x, self._offset_y,
self._offset_x + width, self._offset_y,
self._offset_x + width, self._offset_y + height,
self._offset_x, self._offset_y + height
]
position = bgl.Buffer(bgl.GL_FLOAT, len(position), position)
texcoord = [0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0]
texcoord = bgl.Buffer(bgl.GL_FLOAT, len(texcoord), texcoord)
self.vertex_buffer = bgl.Buffer(bgl.GL_INT, 2)
bgl.glGenBuffers(2, self.vertex_buffer)
bgl.glBindBuffer(bgl.GL_ARRAY_BUFFER, self.vertex_buffer[0])
bgl.glBufferData(bgl.GL_ARRAY_BUFFER, 32, position, bgl.GL_STATIC_DRAW)
bgl.glVertexAttribPointer(position_location, 2, bgl.GL_FLOAT, bgl.GL_FALSE, 0, None)
bgl.glBindBuffer(bgl.GL_ARRAY_BUFFER, self.vertex_buffer[1])
bgl.glBufferData(bgl.GL_ARRAY_BUFFER, 32, texcoord, bgl.GL_STATIC_DRAW)
bgl.glVertexAttribPointer(texturecoord_location, 2, bgl.GL_FLOAT, bgl.GL_FALSE, 0, None)
bgl.glBindBuffer(bgl.GL_ARRAY_BUFFER, NULL)
bgl.glBindVertexArray(NULL)
engine.unbind_display_space_shader()