当前位置: 首页>>代码示例>>Python>>正文


Python bgl.GL_FLOAT属性代码示例

本文整理汇总了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) 
开发者ID:CGCookie,项目名称:addon_common,代码行数:23,代码来源:shaders.py

示例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) 
开发者ID:LuxCoreRender,项目名称:BlendLuxCore,代码行数:21,代码来源:viewport.py

示例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 ===== # 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:8,代码来源:space_view3d_enhanced_3d_cursor.py

示例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 
开发者ID:CGCookie,项目名称:addon_common,代码行数:7,代码来源:shaders.py

示例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) 
开发者ID:CGCookie,项目名称:addon_common,代码行数:7,代码来源:maths.py

示例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) 
开发者ID:CGCookie,项目名称:addon_common,代码行数:10,代码来源:bgl_ext.py

示例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 
开发者ID:LuxCoreRender,项目名称:BlendLuxCore,代码行数:38,代码来源:viewport.py

示例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]) 
开发者ID:CGCookie,项目名称:addon_common,代码行数:59,代码来源:shaders.py

示例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) 
开发者ID:CGCookie,项目名称:addon_common,代码行数:61,代码来源:bmesh_render.py

示例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() 
开发者ID:LuxCoreRender,项目名称:BlendLuxCore,代码行数:52,代码来源:viewport.py


注:本文中的bgl.GL_FLOAT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。