本文整理汇总了Python中OpenGL.GL.glClear方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glClear方法的具体用法?Python GL.glClear怎么用?Python GL.glClear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenGL.GL
的用法示例。
在下文中一共展示了GL.glClear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glClear [as 别名]
def render(self, context):
self.shader.bind()
flipY = -1
projection = utils.createPerspectiveOrtho(-1.0, 1.0, 1.0 * flipY, -1.0 * flipY, -1.0, 1.0)
self.shader.uniformMatrix4f(shader.PROJECTION, projection)
self.shader.uniformf("imageSize", *self.getSize())
self.setUniforms(self.shader, context.uniforms)
self.textureMap.bindTextures(self.shader)
gl.glClearColor(*self.clearColor)
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
self.bindAttributeArray(self.shader, "inVertex", self.verts, 4)
gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, len(self.verts) // 4);
self.unbindAttributeArray(self.shader, "inVertex")
self.textureMap.unbindTextures()
self.shader.unbind()
示例2: render_rgb_indexed_colors
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glClear [as 别名]
def render_rgb_indexed_colors(self, **kwargs):
'''Draws scene in the background buffer to extract mouse click info'''
import OpenGL.GL as gl
import OpenGL.GLU as glu
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLoadIdentity()
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
# camera_pos_rtp is relative to the target position. To get the
# absolute camera position, we need to add the target position.
gl.glPushMatrix()
camera_pos_xyz = np.array(rtp_to_xyz(*self.camera_pos_rtp)) \
+ self.target_pos
glu.gluLookAt(
*(list(camera_pos_xyz) + list(self.target_pos) + self.up))
self.draw_data_set()
gl.glPopMatrix()
gl.glFlush()
示例3: main_pygame
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glClear [as 别名]
def main_pygame():
pygame.init()
size = 800, 600
pygame.display.set_mode(size, pygame.DOUBLEBUF | pygame.OPENGL)
io = imgui.get_io()
io.fonts.add_font_default()
io.display_size = size
renderer = PygameRenderer()
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
renderer.process_event(event)
imgui.new_frame()
on_frame()
# note: cannot use screen.fill((1, 1, 1)) because pygame's screen
# does not support fill() on OpenGL sufraces
gl.glClearColor(1, 1, 1, 1)
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
imgui.render()
pygame.display.flip()
示例4: main_cocos2d
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glClear [as 别名]
def main_cocos2d():
class HelloWorld(ImguiLayer):
is_event_handler = True
def __init__(self):
super(HelloWorld, self).__init__()
self._text = "Input text here"
def draw(self, *args, **kwargs):
imgui.new_frame()
on_frame()
gl.glClearColor(1., 1., 1., 1)
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
imgui.render()
director.init(width=800, height=600, resizable=True)
hello_layer = HelloWorld()
main_scene = cocos.scene.Scene(hello_layer)
director.run(main_scene)
# backend-independent frame rendering function:
示例5: paintGL
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glClear [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));
示例6: paintGL
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glClear [as 别名]
def paintGL(self):
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
if not self.first:
return
f = open('opengl_test.txt', 'w')
gl_version = float(gl.glGetString(gl.GL_VERSION)[:3])
f.write('Supported OpenGL version: %.1f\n' % gl_version)
if gl_version >= 2.0:
f.write('Supported GLSL version: ' +
gl.glGetString(gl.GL_SHADING_LANGUAGE_VERSION).decode() + '\n')
f.write('Context was valid in initializeGL? %d\n' % self.was_valid_in_init)
numext = gl.glGetIntegerv(gl.GL_NUM_EXTENSIONS)
f.write('Supported OpenGL extensions:' + '\n')
extensions = ''
for i in range(numext):
extensions += ', ' + gl.glGetStringi(gl.GL_EXTENSIONS, i).decode()
f.write(extensions)
f.close()
self.first = False
示例7: render
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glClear [as 别名]
def render(self, pixmap, viewport_shape):
"""Renders the pixmap on a fullscreen quad.
Args:
pixmap: A 3D numpy array of bytes (np.uint8), with dimensions
(width, height, 3).
viewport_shape: A tuple of two elements, (width, height).
"""
GL.glClear(GL.GL_COLOR_BUFFER_BIT)
GL.glViewport(0, 0, *viewport_shape)
GL.glUseProgram(self._shader)
GL.glActiveTexture(GL.GL_TEXTURE0)
GL.glBindTexture(GL.GL_TEXTURE_2D, self._texture)
GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1)
GL.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGB, pixmap.shape[1],
pixmap.shape[0], 0, GL.GL_RGB, GL.GL_UNSIGNED_BYTE,
pixmap)
GL.glUniform1i(self._var_texture_sampler, 0)
GL.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4)
示例8: paintGL
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glClear [as 别名]
def paintGL(self):
GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
GL.glLoadIdentity()
GL.glTranslated(0.0, 0.0, -10.0)
GL.glRotated(self.xRot / 16.0, 1.0, 0.0, 0.0)
GL.glRotated(self.yRot / 16.0, 0.0, 1.0, 0.0)
GL.glRotated(self.zRot / 16.0, 0.0, 0.0, 1.0)
GL.glScalef(self.zoom,self.zoom,self.zoom)
GL.glCallList(self.electrode_object)
GL.glCallList(self.center_dir)
if self.plug_object != 0:
GL.glCallList(self.plug_object)
示例9: viewer_refresh
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glClear [as 别名]
def viewer_refresh(self, q):
while not q.empty():
self.state = q.get()
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
gl.glClearColor(0.0, 0.0, 0.0, 1.0)
self.dcam.Activate(self.scam)
if self.state is not None:
if self.state[0].shape[0] >= 2:
# draw poses
gl.glColor3f(0.0, 1.0, 0.0)
pangolin.DrawCameras(self.state[0][:-1])
if self.state[0].shape[0] >= 1:
# draw current pose as yellow
gl.glColor3f(1.0, 1.0, 0.0)
pangolin.DrawCameras(self.state[0][-1:])
if self.state[1].shape[0] != 0:
# draw keypoints
gl.glPointSize(5)
gl.glColor3f(1.0, 0.0, 0.0)
pangolin.DrawPoints(self.state[1], self.state[2])
pangolin.FinishFrame()
示例10: main
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glClear [as 别名]
def main():
pangolin.CreateWindowAndBind('Main', 640, 480)
gl.glEnable(gl.GL_DEPTH_TEST)
# Define Projection and initial ModelView matrix
scam = pangolin.OpenGlRenderState(
pangolin.ProjectionMatrix(640, 480, 420, 420, 320, 240, 0.2, 100),
pangolin.ModelViewLookAt(-2, 2, -2, 0, 0, 0, pangolin.AxisDirection.AxisY))
handler = pangolin.Handler3D(scam)
# Create Interactive View in window
dcam = pangolin.CreateDisplay()
dcam.SetBounds(0.0, 1.0, 0.0, 1.0, -640.0/480.0)
dcam.SetHandler(handler)
dcam.Resize(pangolin.Viewport(0,0,640*2,480*2))
while not pangolin.ShouldQuit():
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
gl.glClearColor(1.0, 1.0, 1.0, 1.0)
dcam.Activate(scam)
# Render OpenGL Cube
pangolin.glDrawColouredCube()
# Draw Point Cloud
points = np.random.random((100000, 3)) * 10
colors = np.zeros((len(points), 3))
colors[:, 1] = 1 -points[:, 0] / 10.
colors[:, 2] = 1 - points[:, 1] / 10.
colors[:, 0] = 1 - points[:, 2] / 10.
gl.glPointSize(2)
gl.glColor3f(1.0, 0.0, 0.0)
# access numpy array directly(without copying data), array should be contiguous.
pangolin.DrawPoints(points, colors)
pangolin.FinishFrame()
示例11: display
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glClear [as 别名]
def display():
gl.glClear (gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
glut.glutSwapBuffers()
示例12: on_paint
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glClear [as 别名]
def on_paint(self, event):
"""Process the drawing event."""
import OpenGL.GL as gl
import OpenGL.GLU as glu
self.canvas.SetCurrent(self.canvas.context)
if not self.gl_initialized:
self.initgl()
self.gl_initialized = True
self.print_help()
if self.light:
gl.glEnable(gl.GL_LIGHTING)
else:
gl.glDisable(gl.GL_LIGHTING)
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
gl.glLoadIdentity()
gl.glPushMatrix()
glu.gluLookAt(*(list(rtp_to_xyz(
*self.camera_pos_rtp)) + list(self.target_pos) + list(self.up)))
self.draw_cube()
gl.glPopMatrix()
gl.glFlush()
self.SwapBuffers()
event.Skip()
示例13: main_glfw
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glClear [as 别名]
def main_glfw():
def glfw_init():
width, height = 1280, 720
window_name = "minimal ImGui/GLFW3 example"
if not glfw.init():
print("Could not initialize OpenGL context")
exit(1)
# OS X supports only forward-compatible core profiles from 3.2
glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3)
glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 3)
glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, gl.GL_TRUE)
# Create a windowed mode window and its OpenGL context
window = glfw.create_window(
int(width), int(height), window_name, None, None
)
glfw.make_context_current(window)
if not window:
glfw.terminate()
print("Could not initialize Window")
exit(1)
return window
window = glfw_init()
impl = GlfwRenderer(window)
while not glfw.window_should_close(window):
glfw.poll_events()
impl.process_inputs()
imgui.new_frame()
on_frame()
gl.glClearColor(1., 1., 1., 1)
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
imgui.render()
impl.render(imgui.get_draw_data())
glfw.swap_buffers(window)
impl.shutdown()
glfw.terminate()
示例14: main
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glClear [as 别名]
def main():
imgui.create_context()
window = impl_glfw_init()
impl = GlfwRenderer(window)
while not glfw.window_should_close(window):
glfw.poll_events()
impl.process_inputs()
imgui.new_frame()
if imgui.begin_main_menu_bar():
if imgui.begin_menu("File", True):
clicked_quit, selected_quit = imgui.menu_item(
"Quit", 'Cmd+Q', False, True
)
if clicked_quit:
exit(1)
imgui.end_menu()
imgui.end_main_menu_bar()
imgui.show_test_window()
imgui.begin("Custom window", True)
imgui.text("Bar")
imgui.text_colored("Eggs", 0.2, 1., 0.)
imgui.end()
gl.glClearColor(1., 1., 1., 1)
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
imgui.render()
impl.render(imgui.get_draw_data())
glfw.swap_buffers(window)
impl.shutdown()
glfw.terminate()
示例15: paintGL
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glClear [as 别名]
def paintGL(self):
if self.opengl:
GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
self.opengl.draw(self.defaultFramebufferObject(), self.width(), -self.height())