How to use the pyglet.gl function in pyglet

To help you get started, weā€™ve selected a few pyglet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyglet / pyglet / tests / interactive / graphics / test_multitexture.py View on Github external
def _bind_texture(self, i):
        gl.glActiveTexture((gl.GL_TEXTURE0, gl.GL_TEXTURE1, gl.GL_TEXTURE2)[i])
        gl.glEnable(gl.GL_TEXTURE_2D)
        gl.glBindTexture(gl.GL_TEXTURE_2D, self.texture[i].id)
        gl.glTexEnvf(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_COMBINE)
        gl.glTexEnvf(gl.GL_TEXTURE_ENV, gl.GL_COMBINE_ALPHA, gl.GL_REPLACE if i == 0 else gl.GL_ADD)
        gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST)
        gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)
github pvcraven / arcade / experimental / vbo_test_01.py View on Github external
def render_rect_filled(shape, x, y):
    """ Render the shape at the right spot. """
    # Set color
    GL.glDisable(GL.GL_BLEND)
    GL.glColor4ub(shape.color[0], shape.color[1], shape.color[2], 255)

    GL.glBindBuffer(GL.GL_ARRAY_BUFFER, shape.vbo_id)
    GL.glVertexPointer(2, GL.GL_FLOAT, 0, 0)

    GL.glLoadIdentity()
    GL.glTranslatef(x + shape.width / 2, y + shape.height / 2, 0)

    GL.glDrawArrays(GL.GL_QUADS, 0, shape.size)
github irskep / Space-Train / AdventureMaker.py View on Github external
print "Usage: python AdventureMaker.py "
            sys.exit(1)
        
        screen = pyglet.window.get_platform().get_default_display().get_default_screen()
        super(AdventureMakerWindow,self).__init__(width=screen.width-20, 
                                                  height=gamestate.norm_h, 
                                                  vsync=True)
        gamestate.main_window = self
        gamestate.scripts_enabled = False
        gamestate.init_scale()
        gamestate.keys = pyglet.window.key.KeyStateHandler()
        gamestate.main_window.push_handlers(gamestate.keys)
        
        engine.init()
        
        pyglet.gl.glEnable(pyglet.gl.GL_BLEND)
        pyglet.gl.glBlendFunc(pyglet.gl.GL_SRC_ALPHA, pyglet.gl.GL_ONE_MINUS_SRC_ALPHA)
        
        self.set_caption("Scene Editor: %s" % sys.argv[1])
        self.editorview = editorview.EditorView(sys.argv[1])
        
        pyglet.clock.schedule_interval(self.on_draw, 1/60.0)
        pyglet.clock.schedule_interval(self.editorview.update, 1/120.0)
github olehermanse / mrpg / mrpg / gui / sprite.py View on Github external
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        pyglet.gl.glTexParameteri(
            self._texture.target, pyglet.gl.GL_TEXTURE_MAG_FILTER, pyglet.gl.GL_NEAREST
        )
        pyglet.gl.glTexParameteri(
            self._texture.target, pyglet.gl.GL_TEXTURE_MIN_FILTER, pyglet.gl.GL_NEAREST
        )
github kjyv / FloBaRoID / visualizer.py View on Github external
def drawCube(self):
        #gl.glEnableVertexAttribArray(0)
        #gl.glVertexAttribPointer(0, 3, gl.GL_FLOAT, gl.GL_FALSE, 0, cube.vertices)
        #gl.glDrawElements(gl.GL_TRIANGLES, cube.indices)
        self.cube_list.draw(gl.GL_TRIANGLES)
github Permafacture / data-oriented-pyglet / examples / data_oriented_example.py View on Github external
def draw(self):
        gl.glClearColor(0.2, 0.4, 0.5, 1.0)
        gl.glBlendFunc (gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)                             
        gl.glEnable (gl.GL_BLEND)                                                            
        gl.glEnable (gl.GL_LINE_SMOOTH);                                                     
        gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
        gl.glEnableClientState(gl.GL_COLOR_ARRAY)

        n = len(self.as_array(self.verts))
        #TODO verts._buffer.ctypes.data is awkward
        gl.glVertexPointer(2, self.vert_dtype.gl, 0, self.verts._buffer.ctypes.data)
        gl.glColorPointer(3,  self.color_dtype.gl, 0, self.colors._buffer.ctypes.data)
        gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, n)
github joschabach / micropsi2 / micropsi_core / world / minecraft / vis / pyglet / window / __init__.py View on Github external
if (self._mouse_cursor.drawable and 
            self._mouse_visible and 
            self._mouse_in_window):
            gl.glMatrixMode(gl.GL_PROJECTION)
            gl.glPushMatrix()
            gl.glLoadIdentity()
            gl.glOrtho(0, self.width, 0, self.height, -1, 1)

            gl.glMatrixMode(gl.GL_MODELVIEW)
            gl.glPushMatrix()
            gl.glLoadIdentity()

            self._mouse_cursor.draw(self._mouse_x, self._mouse_y)

            gl.glMatrixMode(gl.GL_PROJECTION)
            gl.glPopMatrix()

            gl.glMatrixMode(gl.GL_MODELVIEW)
            gl.glPopMatrix()
github psychopy / psychopy / psychopy / visual / shape2.py View on Github external
#!/usr/bin/env python2

'''Create fillable ShapeStim from a list of vertices.'''

# Part of the PsychoPy library
# Copyright (C) 2015 Jonathan Peirce
# Distributed under the terms of the GNU General Public License (GPL)

# Author: Jeremy R. Gray, November 2015

import pyglet
pyglet.options['debug_gl'] = False
GL = pyglet.gl
import numpy
import copy

from psychopy import logging
from psychopy.visual.shape import ShapeStim
from psychopy.contrib import tesselate


class ShapeStim2(ShapeStim):
    """A class for fillable polygons: concave, convex, self-crossing, or with holes.

    Line shapes are not handled well; use a ShapeStim instead.

    `vertices` can be a list of loops, where each loop is a list of points (x,y),
    e.g., to define a shape with a hole. `vertices` can also be a list of points (x,y).
    See Coder demo > stimuli > filled_shapes.py
github los-cocos / cocos / cocos / framegrabber.py View on Github external
def grab(self, texture):
        self.pbuf = gl.Pbuffer(director.window, [
            gl.GLX_CONFIG_CAVEAT, gl.GLX_NONE,
            gl.GLX_RED_SIZE, 8,
            gl.GLX_GREEN_SIZE, 8,
            gl.GLX_BLUE_SIZE, 8,
            gl.GLX_DEPTH_SIZE, 24,
            gl.GLX_DOUBLEBUFFER, 1,
            ])
github joschabach / micropsi2 / micropsi_core / world / minecraft / vis / pyglet / window / __init__.py View on Github external
def get_windows(self):
            '''Get the windows currently attached to this display.

            :rtype: sequence of `Window`
            '''
            raise NotImplementedError('deprecated')
else:
    Display = pyglet.canvas.Display
    Screen = pyglet.canvas.Screen


# XXX remove
# Create shadow window. (trickery is for circular import)
if not _is_epydoc:
    pyglet.window = sys.modules[__name__]
    gl._create_shadow_window()