本文整理汇总了Python中OpenGL.GL.GL_FALSE属性的典型用法代码示例。如果您正苦于以下问题:Python GL.GL_FALSE属性的具体用法?Python GL.GL_FALSE怎么用?Python GL.GL_FALSE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类OpenGL.GL
的用法示例。
在下文中一共展示了GL.GL_FALSE属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: paintGL
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import GL_FALSE [as 别名]
def paintGL(self):
self.makeCurrent()
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
self.program.bind()
self.program.enableAttributeArray("position")
self.vbo.bind()
gl.glVertexAttribPointer(self.program.attributeLocation("position"), 2, gl.GL_FLOAT, gl.GL_FALSE, 0, self.vbo)
self.program.enableAttributeArray("normal")
self.vbo_cols.bind()
gl.glVertexAttribPointer(self.program.attributeLocation("normal"), 3, gl.GL_FLOAT, gl.GL_FALSE, 0, self.vbo_cols)
gl.glDrawArrays(gl.GL_TRIANGLES, 0, len(self.data))
print(self.context().format().majorVersion())
print(self.context().format().minorVersion())
print(gl.glGetString(gl.GL_VERSION));
示例2: _init_shaders
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import GL_FALSE [as 别名]
def _init_shaders(self):
"""Initializes the shaders used to render the textures fullscreen quad."""
vs = shaders.compileShader(_VERTEX_SHADER, GL.GL_VERTEX_SHADER)
fs = shaders.compileShader(_FRAGMENT_SHADER, GL.GL_FRAGMENT_SHADER)
self._shader = shaders.compileProgram(vs, fs)
stride = _FLOATS_PER_VERTEX * _SIZE_OF_FLOAT
var_position = GL.glGetAttribLocation(self._shader, _VAR_POSITION)
GL.glVertexAttribPointer(
var_position, 2, GL.GL_FLOAT, GL.GL_FALSE, stride, None)
GL.glEnableVertexAttribArray(var_position)
var_uv = GL.glGetAttribLocation(self._shader, _VAR_UV)
uv_offset = ctypes.c_void_p(_FLOATS_PER_XY * _SIZE_OF_FLOAT)
GL.glVertexAttribPointer(
var_uv, 2, GL.GL_FLOAT, GL.GL_FALSE, stride, uv_offset)
GL.glEnableVertexAttribArray(var_uv)
self._var_texture_sampler = GL.glGetUniformLocation(
self._shader, _VAR_TEXTURE_SAMPLER)
示例3: __init__
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import GL_FALSE [as 别名]
def __init__(self, shader_type, source):
self.code_ = source
self.shader_type_ = shader_type
self.id_ = gl.glCreateShader(self.shader_type_)
gl.glShaderSource(self.id_, source)
gl.glCompileShader(self.id_)
success = gl.glGetShaderiv(self.id_, gl.GL_COMPILE_STATUS)
if success == gl.GL_FALSE:
error_string = gl.glGetShaderInfoLog(self.id_).decode("utf-8")
raise RuntimeError(error_string)
示例4: paintGL
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import GL_FALSE [as 别名]
def paintGL(self):
self.makeCurrent()
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
self.program.bind()
self.program.enableAttributeArray("position")
self.vbo.bind()
gl.glVertexAttribPointer(self.program.attributeLocation("position"), 2, gl.GL_FLOAT, gl.GL_FALSE, 0, self.vbo)
self.program.enableAttributeArray("color")
self.vbo_cols.bind()
gl.glVertexAttribPointer(self.program.attributeLocation("color"), 3, gl.GL_FLOAT, gl.GL_FALSE, 0, self.vbo_cols)
self.vbo_index.bind()
#gl.glDrawArrays(gl.GL_TRIANGLES, 0, len(self.data))
gl.glDrawElements(gl.GL_TRIANGLES, len(self.index), gl.GL_UNSIGNED_INT, None)
print(self.context().format().majorVersion())
print(self.context().format().minorVersion())
print(gl.glGetString(gl.GL_VERSION));
示例5: paintGL
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import GL_FALSE [as 别名]
def paintGL(self, p, opt, widget):
p.beginNativePainting()
import OpenGL.GL as gl
## set clipping viewport
view = self.getViewBox()
if view is not None:
rect = view.mapRectToItem(self, view.boundingRect())
#gl.glViewport(int(rect.x()), int(rect.y()), int(rect.width()), int(rect.height()))
#gl.glTranslate(-rect.x(), -rect.y(), 0)
gl.glEnable(gl.GL_STENCIL_TEST)
gl.glColorMask(gl.GL_FALSE, gl.GL_FALSE, gl.GL_FALSE, gl.GL_FALSE) # disable drawing to frame buffer
gl.glDepthMask(gl.GL_FALSE) # disable drawing to depth buffer
gl.glStencilFunc(gl.GL_NEVER, 1, 0xFF)
gl.glStencilOp(gl.GL_REPLACE, gl.GL_KEEP, gl.GL_KEEP)
## draw stencil pattern
gl.glStencilMask(0xFF)
gl.glClear(gl.GL_STENCIL_BUFFER_BIT)
gl.glBegin(gl.GL_TRIANGLES)
gl.glVertex2f(rect.x(), rect.y())
gl.glVertex2f(rect.x()+rect.width(), rect.y())
gl.glVertex2f(rect.x(), rect.y()+rect.height())
gl.glVertex2f(rect.x()+rect.width(), rect.y()+rect.height())
gl.glVertex2f(rect.x()+rect.width(), rect.y())
gl.glVertex2f(rect.x(), rect.y()+rect.height())
gl.glEnd()
gl.glColorMask(gl.GL_TRUE, gl.GL_TRUE, gl.GL_TRUE, gl.GL_TRUE)
gl.glDepthMask(gl.GL_TRUE)
gl.glStencilMask(0x00)
gl.glStencilFunc(gl.GL_EQUAL, 1, 0xFF)
try:
x, y = self.getData()
pos = np.empty((len(x), 2))
pos[:,0] = x
pos[:,1] = y
gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
try:
gl.glVertexPointerf(pos)
pen = fn.mkPen(self.opts['pen'])
color = pen.color()
gl.glColor4f(color.red()/255., color.green()/255., color.blue()/255., color.alpha()/255.)
width = pen.width()
if pen.isCosmetic() and width < 1:
width = 1
gl.glPointSize(width)
gl.glEnable(gl.GL_LINE_SMOOTH)
gl.glEnable(gl.GL_BLEND)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
gl.glHint(gl.GL_LINE_SMOOTH_HINT, gl.GL_NICEST)
gl.glDrawArrays(gl.GL_LINE_STRIP, 0, pos.size / pos.shape[-1])
finally:
gl.glDisableClientState(gl.GL_VERTEX_ARRAY)
finally:
p.endNativePainting()
示例6: _create_device_objects
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import GL_FALSE [as 别名]
def _create_device_objects(self):
# save state
last_texture = gl.glGetIntegerv(gl.GL_TEXTURE_BINDING_2D)
last_array_buffer = gl.glGetIntegerv(gl.GL_ARRAY_BUFFER_BINDING)
last_vertex_array = gl.glGetIntegerv(gl.GL_VERTEX_ARRAY_BINDING)
self._shader_handle = gl.glCreateProgram()
# note: no need to store shader parts handles after linking
vertex_shader = gl.glCreateShader(gl.GL_VERTEX_SHADER)
fragment_shader = gl.glCreateShader(gl.GL_FRAGMENT_SHADER)
gl.glShaderSource(vertex_shader, self.VERTEX_SHADER_SRC)
gl.glShaderSource(fragment_shader, self.FRAGMENT_SHADER_SRC)
gl.glCompileShader(vertex_shader)
gl.glCompileShader(fragment_shader)
gl.glAttachShader(self._shader_handle, vertex_shader)
gl.glAttachShader(self._shader_handle, fragment_shader)
gl.glLinkProgram(self._shader_handle)
# note: after linking shaders can be removed
gl.glDeleteShader(vertex_shader)
gl.glDeleteShader(fragment_shader)
self._attrib_location_tex = gl.glGetUniformLocation(self._shader_handle, "Texture")
self._attrib_proj_mtx = gl.glGetUniformLocation(self._shader_handle, "ProjMtx")
self._attrib_location_position = gl.glGetAttribLocation(self._shader_handle, "Position")
self._attrib_location_uv = gl.glGetAttribLocation(self._shader_handle, "UV")
self._attrib_location_color = gl.glGetAttribLocation(self._shader_handle, "Color")
self._vbo_handle = gl.glGenBuffers(1)
self._elements_handle = gl.glGenBuffers(1)
self._vao_handle = gl.glGenVertexArrays(1)
gl.glBindVertexArray(self._vao_handle)
gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self._vbo_handle)
gl.glEnableVertexAttribArray(self._attrib_location_position)
gl.glEnableVertexAttribArray(self._attrib_location_uv)
gl.glEnableVertexAttribArray(self._attrib_location_color)
gl.glVertexAttribPointer(self._attrib_location_position, 2, gl.GL_FLOAT, gl.GL_FALSE, imgui.VERTEX_SIZE, ctypes.c_void_p(imgui.VERTEX_BUFFER_POS_OFFSET))
gl.glVertexAttribPointer(self._attrib_location_uv, 2, gl.GL_FLOAT, gl.GL_FALSE, imgui.VERTEX_SIZE, ctypes.c_void_p(imgui.VERTEX_BUFFER_UV_OFFSET))
gl.glVertexAttribPointer(self._attrib_location_color, 4, gl.GL_UNSIGNED_BYTE, gl.GL_TRUE, imgui.VERTEX_SIZE, ctypes.c_void_p(imgui.VERTEX_BUFFER_COL_OFFSET))
# restore state
gl.glBindTexture(gl.GL_TEXTURE_2D, last_texture)
gl.glBindBuffer(gl.GL_ARRAY_BUFFER, last_array_buffer)
gl.glBindVertexArray(last_vertex_array)