Perform the magic incantations to create an
        OpenGL scene using pyglet.
774532
def init_gl(self):
        

        # default background color is white-ish
        background = [.99, .99, .99, 1.0]
        # if user passed a background color use it
        if 'background' in self.kwargs:
            try:
                # convert to (4,) uint8 RGBA
                background = to_rgba(self.kwargs['background'])
                # convert to 0.0 - 1.0 float
                background = background.astype(np.float64) / 255.0
            except BaseException:
                log.error('background color set but wrong!',
                          exc_info=True)

        self._gl_set_background(background)
        self._gl_enable_depth(self.scene)
        self._gl_enable_color_material()
        self._gl_enable_blending()
        self._gl_enable_smooth_lines()
        self._gl_enable_lighting(self.scene)
527474
def insert_into_shaders(self, vertex, fragment):
        """"""
        to_insert = defaultdict(str)
        to_insert.update({key: '\n'.join(self._to_insert[key]) + '\n'
                          for key in self._to_insert})
        return _insert_glsl(vertex, fragment, to_insert)
698238
def draw(self, mode, selection):
        
        if not self._linked:
            raise RuntimeError('Cannot draw program if code has not been set')
        # Init
        gl.check_error('Check before draw')
        mode = as_enum(mode)
        # Draw
        if len(selection) == 3:
            # Selection based on indices
            id_, gtype, count = selection
            if count:
                self._pre_draw()
                ibuf = self._parser.get_object(id_)
                ibuf.activate()
                gl.glDrawElements(mode, count, as_enum(gtype), None)
                ibuf.deactivate()
        else:
            # Selection based on start and count
            first, count = selection
            if count:
                self._pre_draw()
                gl.glDrawArrays(mode, first, count)
        # Wrap up
        gl.check_error('Check after draw')
        self._post_draw()
584527
def copy_magic_into_pyc(input_pyc, output_pyc,
                        src_version, dest_version):
    """"""
    (version, timestamp, magic_int,
     co, is_pypy, source_size) = load_module(input_pyc)
    assert version == float(src_version), (
        "Need Python %s bytecode; got bytecode for version %s" %
        (src_version, version))
    magic_int = magic2int(magics[dest_version])
    write_bytecode_file(output_pyc, co, magic_int)
    print("Wrote %s" % output_pyc)
    return
32805
def draw(self, milliseconds, surface):
        """"""
        self.drawn_rects = []
        cam = Ragnarok.get_world().Camera
        cX, cY, cXMax, cYMax = cam.get_cam_bounds()

        #Draw out only the tiles visible to the camera.
        start_pos = self.pixels_to_tiles( (cX, cY) )
        start_pos -= Vector2(1, 1)
        end_pos = self.pixels_to_tiles( (cXMax, cYMax) )
        end_pos += Vector2(1, 1)

        start_pos.X, start_pos.Y = self.clamp_within_range(start_pos.X, start_pos.Y)
        end_pos.X, end_pos.Y = self.clamp_within_range(end_pos.X, end_pos.Y)

        cam_pos = cam.get_world_pos()
        for x in range(start_pos.X, end_pos.X + 1):
            for y in range(start_pos.Y, end_pos.Y + 1):
                tile = self.tiles[y][x]
                translate_posX = tile.coords.X - cam_pos.X
                translate_posY = tile.coords.Y - cam_pos.Y
                surface.blit(self.spritesheet.image, (translate_posX, translate_posY), tile.source, special_flags = 0)
871658
def create_graphics(self):
        """"""

        rnftools.utils.shell('"{}" "{}"'.format("gnuplot", self._gp_fn))

        if self.render_pdf_method is not None:
            svg_fn = self._svg_fn
            pdf_fn = self._pdf_fn
            svg42pdf(svg_fn, pdf_fn, method=self.render_pdf_method)
1039233
def plt(self, fout_img, engine="pydot"):
        """"""
        if engine == "pydot":
            self._plt_pydot(fout_img)
        elif engine == "pygraphviz":
            raise Exception("TO BE IMPLEMENTED SOON: ENGINE pygraphvis")
        else:
            raise Exception("UNKNOWN ENGINE({E})".format(E=engine))
437250
def draw_material(material, face=GL_FRONT_AND_BACK):
    """"""
    if material.gl_floats is None:
        material.gl_floats = (GLfloat * len(material.vertices))(*material.vertices)
        material.triangle_count = len(material.vertices) / material.vertex_size

    vertex_format = VERTEX_FORMATS.get(material.vertex_format)
    if not vertex_format:
        raise ValueError("Vertex format {} not supported by pyglet".format(material.vertex_format))

    glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT)
    glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT | GL_LIGHTING_BIT)
    glEnable(GL_CULL_FACE)
    glCullFace(GL_BACK)

    # Fall back to ambient texture if no diffuse
    texture = material.texture or material.texture_ambient
    if texture and material.has_uvs:
        bind_texture(texture)
    else:
        glDisable(GL_TEXTURE_2D)

    glMaterialfv(face, GL_DIFFUSE, gl_light(material.diffuse))
    glMaterialfv(face, GL_AMBIENT, gl_light(material.ambient))
    glMaterialfv(face, GL_SPECULAR, gl_light(material.specular))
    glMaterialfv(face, GL_EMISSION, gl_light(material.emissive))
    glMaterialf(face, GL_SHININESS, min(128.0, material.shininess))
    glEnable(GL_LIGHT0)

    if material.has_normals:
        glEnable(GL_LIGHTING)
    else:
        glDisable(GL_LIGHTING)

    glInterleavedArrays(vertex_format, 0, material.gl_floats)
    glDrawArrays(GL_TRIANGLES, 0, int(material.triangle_count))

    glPopAttrib()
    glPopClientAttrib()
1058099
def _draw(self, context, opacity):
        """"""

        # if we have been moved around, we should update bounds
        fresh_draw = len(self.__new_instructions or []) > 0
        if fresh_draw: #new stuff!
            self.paths = []
            self.__instruction_cache = self.__new_instructions
            self.__new_instructions = []
        else:
            if not self.__instruction_cache:
                return

        for instruction, args in self.__instruction_cache:
            if fresh_draw:
                if instruction in ("new_path", "stroke", "fill", "clip"):
                    self.paths.append((instruction, "path", context.copy_path()))

                elif instruction in ("save", "restore", "translate", "scale", "rotate"):
                    self.paths.append((instruction, "transform", args))

            if instruction == "set_color":
                self._set_color(context, args[0], args[1], args[2], args[3] * opacity)
            elif instruction == "show_layout":
                self._show_layout(context, *args)
            elif opacity < 1 and instruction == "paint":
                context.paint_with_alpha(opacity)
            else:
                getattr(context, instruction)(*args)
1208005
def enable(self):
		
		glEnable(GL_TEXTURE_3D)
		glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_REPEAT)
		glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_REPEAT)
		glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_REPEAT)
		glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
		glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
111501
function () {
            this.sbIndex = 0;
            this.length = 0;

            var samplers = [];

            // WebGL context
            this.gl = this.renderer.gl;

            this.flush();

            this.setProjection(this.gl.canvas.width, this.gl.canvas.height);

            this.setViewport(0, 0, this.gl.canvas.width, this.gl.canvas.height);

            // Initialize clear color
            this.gl.clearColor(0.0, 0.0, 0.0, 1.0);

            for (var i = 0; i < this.maxTextures; i++) {
                this.units[i] = false;
                samplers[i] = i;
            }
            // set the quad shader as the default program
            this.useShader(this.quadShader);
            this.quadShader.uniforms.uSampler = samplers;
        }
1000955
def paintGL(self):
        ''''''

        if self.post_processing:
            # Render to the first framebuffer
            glBindFramebuffer(GL_FRAMEBUFFER, self.fb0)
            glViewport(0, 0, self.width(), self.height())

            status = glCheckFramebufferStatus(GL_FRAMEBUFFER)
            if (status != GL_FRAMEBUFFER_COMPLETE):
                reason = dict(GL_FRAMEBUFFER_UNDEFINED='UNDEFINED',
                              GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT='INCOMPLETE_ATTACHMENT',
                              GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT='INCOMPLETE_MISSING_ATTACHMENT',
                              GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER='INCOMPLETE_DRAW_BUFFER',
                              GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER='INCOMPLETE_READ_BUFFER',
                              GL_FRAMEBUFFER_UNSUPPORTED='UNSUPPORTED',
                          )[status]

                raise Exception('Framebuffer is not complete: {}'.format(reason))
        else:
            glBindFramebuffer(GL_FRAMEBUFFER, DEFAULT_FRAMEBUFFER)


        # Clear color take floats
        bg_r, bg_g, bg_b, bg_a = self.background_color
        glClearColor(bg_r/255, bg_g/255, bg_b/255, bg_a/255)
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        proj = self.camera.projection
        cam = self.camera.matrix

        self.mvproj = np.dot(proj, cam)

        self.ldir = cam[:3, :3].T.dot(self.light_dir)



        # Draw World
        self.on_draw_world()

        # Iterate over all of the post processing effects
        if self.post_processing:
            if len(self.post_processing) > 1:
                newarg = self.textures.copy()

                # Ping-pong framebuffer rendering
                for i, pp in enumerate(self.post_processing[:-1]):
                    if i % 2:
                        outfb = self.fb1
                        outtex = self._extra_textures['fb1']
                    else:
                        outfb = self.fb2
                        outtex = self._extra_textures['fb2']

                    pp.render(outfb, newarg)

                    newarg['color'] = outtex

                self.post_processing[-1].render(DEFAULT_FRAMEBUFFER, newarg)

            else:
                self.post_processing[0].render(DEFAULT_FRAMEBUFFER, self.textures)

        # Draw the UI at the very last step
        self.on_draw_ui()
850029
def set_opengl_implementation(option):
    
    if option == 'software':
        QCoreApplication.setAttribute(Qt.AA_UseSoftwareOpenGL)
        if QQuickWindow is not None:
            QQuickWindow.setSceneGraphBackend(QSGRendererInterface.Software)
    elif option == 'desktop':
        QCoreApplication.setAttribute(Qt.AA_UseDesktopOpenGL)
        if QQuickWindow is not None:
            QQuickWindow.setSceneGraphBackend(QSGRendererInterface.OpenGL)
    elif option == 'gles':
        QCoreApplication.setAttribute(Qt.AA_UseOpenGLES)
        if QQuickWindow is not None:
            QQuickWindow.setSceneGraphBackend(QSGRendererInterface.OpenGL)
1287564
function() {
		var gl = this.gl;

		var program = gl.createProgram();
		gl.attachShader( program, this.vertexShader );
		gl.attachShader( program, this.fragmentShader );
		gl.linkProgram( program );	
		gl.useProgram( program );

		this.program = program;
	}
169046
function SceneNode(gl) {
  this._children = [];
  this._visible = true;
  this._name = name || '';
  this._gl = gl;
  this._order = 1;
}
785793
function() {
        var gl = this.context;
        gl.bindBuffer(gl.ARRAY_BUFFER, this._attributeBuffer);
        gl.bufferData(gl.ARRAY_BUFFER, this._attributeArray, gl.STATIC_DRAW);
        gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer);
        gl.bufferData(
            gl.ELEMENT_ARRAY_BUFFER,
            this._indexArray,
            gl.STATIC_DRAW
        );
        gl.drawElements(gl.TRIANGLES, this.index_pointer, gl.UNSIGNED_SHORT, 0);
    }
658702
def imagemagick(color_count, img, magick_command):
    """"""
    flags = ["-resize", "25%", "-colors", str(color_count),
             "-unique-colors", "txt:-"]
    img += "[0]"

    return subprocess.check_output([*magick_command, img, *flags]).splitlines()