Python pyglet.gl.glClearColor() Examples

The following are 23 code examples of pyglet.gl.glClearColor(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pyglet.gl , or try the search function .
Example #1
Source File: example_wythoff_shader_animation.py    From pywonderland with MIT License 6 votes vote down vote up
def on_draw(self):
        gl.glClearColor(0, 0, 0, 0)
        self.clear()
        gl.glViewport(0, 0, self.width, self.height)
        now = time.clock() - self._start_time
        now *= self._speed
        with self.bufferA:
            with self.shaderA:
                self.shaderA.uniformf("iTime", now)
                self.shaderA.uniformi("iFrame", self._frame_count)
                gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4)

        with self.bufferB:
            with self.shaderB:
                self.shaderB.uniformf("iTime", now)
                gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4)

        with self.shaderC:
            self.shaderC.uniformf("iTime", now)
            gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4)

        self._frame_count += 1 
Example #2
Source File: example_wythoff_shader_animation.py    From pywonderland with MIT License 6 votes vote down vote up
def on_draw(self):
        gl.glClearColor(0, 0, 0, 0)
        self.clear()
        gl.glViewport(0, 0, self.width, self.height)
        self._last = self._now
        self._now = time.clock()
        itime = self._now - self._start_time
        idate = get_idate()
        delta = self._now - self._last
        with self.bufferA:
            with self.shaderA:
                self.shaderA.uniformf("iTime", itime)
                self.shaderA.uniformf("iDate", *idate)
                self.shaderA.uniformf("iTimeDelta", delta)
                gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4)

        with self.shaderB:
            self.shaderB.uniformf("iTime", itime)
            self.shaderB.uniformf("iDate", *idate)
            self.shaderB.uniformf("iTimeDelta", delta)
            gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4)

        self._frame_count += 1 
Example #3
Source File: test_empty_document.py    From pyglet with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def text_window(request):
    class _TestWindow(window.Window):
        def __init__(self, doctype, *args, **kwargs):
            super(_TestWindow, self).__init__(*args, **kwargs)

            self.batch = graphics.Batch()
            self.document = doctype()
            self.layout = layout.IncrementalTextLayout(self.document,
                self.width, self.height, batch=self.batch)

        def on_draw(self):
            gl.glClearColor(1, 1, 1, 1)
            self.clear()
            self.batch.draw()

        def set_bold(self):
            self.document.set_style(0, len(self.document.text), {"bold": True})

    return _TestWindow(request.param) 
Example #4
Source File: test_window_events.py    From pyglet with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _draw(self):
        gl.glClearColor(0.5, 0, 0, 1)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)
        gl.glLoadIdentity()
        self.label.draw()
        self.window.flip() 
Example #5
Source File: gl.py    From ratcave with MIT License 5 votes vote down vote up
def clear_color(r, g, b):
    pyglet_gl.glClearColor(r, g, b, 1.)
    pyglet_gl.glClear(pyglet_gl.GL_COLOR_BUFFER_BIT | pyglet_gl.GL_DEPTH_BUFFER_BIT) 
Example #6
Source File: test_content_valign.py    From pyglet with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def on_draw(self):
        gl.glClearColor(1, 1, 1, 1)
        self.clear()
        self.batch.draw() 
Example #7
Source File: test_plain.py    From pyglet with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def on_draw(self):
        gl.glClearColor(1, 1, 1, 1)
        self.clear()
        self.batch.draw() 
Example #8
Source File: test_style.py    From pyglet with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def on_draw(self):
        gl.glClearColor(1, 1, 1, 1)
        self.clear()
        self.batch.draw() 
Example #9
Source File: event_loop.py    From pyglet with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def clear(self):
        gl.glClearColor(*self.clear_color)
        self.window.clear() 
Example #10
Source File: show_input.py    From pyglet with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def on_draw():
    gl.glClearColor(0.3, 0.3, 0.4, 1.0)
    window.clear()
    batch.draw()
    window.invalid = False 
Example #11
Source File: EMPTY.py    From flappy-bird-py with GNU General Public License v2.0 5 votes vote down vote up
def on_draw(self):
        gl.glClearColor(1, 1, 1, 1)
        self.clear()
        self.batch.draw() 
Example #12
Source File: PLAIN.py    From flappy-bird-py with GNU General Public License v2.0 5 votes vote down vote up
def on_draw(self):
        gl.glClearColor(1, 1, 1, 1)
        self.clear()
        self.batch.draw() 
Example #13
Source File: STYLE.py    From flappy-bird-py with GNU General Public License v2.0 5 votes vote down vote up
def on_draw(self):
        gl.glClearColor(1, 1, 1, 1)
        self.clear()
        self.batch.draw() 
Example #14
Source File: CONTENT_VALIGN_BOTTOM.py    From flappy-bird-py with GNU General Public License v2.0 5 votes vote down vote up
def on_draw(self):
        gl.glClearColor(1, 1, 1, 1)
        self.clear()
        self.batch.draw() 
Example #15
Source File: CONTENT_VALIGN_CENTER.py    From flappy-bird-py with GNU General Public License v2.0 5 votes vote down vote up
def on_draw(self):
        gl.glClearColor(1, 1, 1, 1)
        self.clear()
        self.batch.draw() 
Example #16
Source File: integrations_pyglet.py    From pyimgui with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def main():

    window = pyglet.window.Window(width=1280, height=720, resizable=True)
    gl.glClearColor(1, 1, 1, 1)
    imgui.create_context()
    impl = PygletRenderer(window)

    def update(dt):
        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()

    @window.event
    def on_draw():
        update(1/60.0)
        window.clear()
        imgui.render()
        impl.render(imgui.get_draw_data())

    pyglet.app.run()
    impl.shutdown() 
Example #17
Source File: integrations_cocos2d.py    From pyimgui with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def draw(self, *args, **kwargs):
        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()
        self.renderer.render(imgui.get_draw_data()) 
Example #18
Source File: render.py    From RLSchool with Apache License 2.0 5 votes vote down vote up
def _gl_unset_background():
        gl.glClearColor(*[0, 0, 0, 0]) 
Example #19
Source File: render.py    From RLSchool with Apache License 2.0 5 votes vote down vote up
def _gl_set_background(background):
        gl.glClearColor(*background) 
Example #20
Source File: wangtile.py    From pywonderland with MIT License 5 votes vote down vote up
def on_draw(self):
        gl.glClearColor(0, 0, 0, 0)
        self.clear()
        gl.glViewport(0, 0, self.width, self.height)
        with self.shader:
            self.shader.uniformf("iTime", time.clock() - self._start_time)
            gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4) 
Example #21
Source File: Mobius_in_H3space.py    From pywonderland with MIT License 5 votes vote down vote up
def on_draw(self):
        gl.glClearColor(0, 0, 0, 0)
        self.clear()
        gl.glViewport(0, 0, self.width, self.height)
        with self.shader:
            self.shader.uniformf("iTime", time.clock() - self._start_time)
            gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4)

        if self.video_on and (self.frame_count % self.sample_rate == 0):
            self.write_video_frame()

        self.frame_count += 1 
Example #22
Source File: loxodrome.py    From pywonderland with MIT License 5 votes vote down vote up
def on_draw(self):
        gl.glClearColor(0, 0, 0, 0)
        self.clear()
        gl.glViewport(0, 0, self.width, self.height)
        now = time.clock() - self._start_time
        now *= 20
        with self.shader:
            self.shader.uniformf("iTime", now)
            gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4) 
Example #23
Source File: fractal3d.py    From pywonderland with MIT License 5 votes vote down vote up
def on_draw(self):
        gl.glClearColor(0, 0, 0, 0)
        self.clear()
        gl.glViewport(0, 0, self.width, self.height)
        with self.shader:
            self.shader.uniformf("iTime", time.clock() - self._start_time)
            gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4)