def main(argv): app = QtGui.QApplication(sys.argv) widget = CGLPlotWidget(aspect=1) gl_context = widget.context() gl_context.makeCurrent() data = np.array(image[:, :, :3].sum(-1), dtype=np.float32) shape = list(data.shape) print shape plat, = cl.get_platforms() ati, intel = plat.get_devices() print intel cl_context = cl.Context(devices=[intel]) implot = ImagePlot(widget.context(), cl_context, shape, share=False, interp=Interp.NEAREST) cl_data = cl.Buffer(cl_context, cl.mem_flags.READ_WRITE, data.nbytes) import pylab cdict = pylab.cm.jet._segmentdata pipe_segment = ColorMap(gl_context, cl_context, cdict, cl_data, implot.texture.cl_image, shape, clim=(np.float32(data.min()), np.float32(data.max())) ) cl.enqueue_copy(implot.queue, cl_data, data) implot.queue.finish() implot._pipe_segments.append(pipe_segment) implot.process() widget.add_plot(implot) widget.show() widget.resize(480, 640,) bring_to_front() sys.exit(app.exec_())
if sys.platform == 'darwin' and os.path.exists('/usr/bin/osascript'): Popen('/usr/bin/osascript -e \'tell application "Python"\nactivate\nend tell\'', shell=True) return if __name__ == '__main__': app = QtGui.QApplication(sys.argv) f = QtOpenGL.QGLFormat.defaultFormat() f.setSampleBuffers(True) QtOpenGL.QGLFormat.setDefaultFormat(f) canvas = CGLPlotWidget() gl_context = canvas.context() gl_context.makeCurrent() cl_context = cl.Context(properties=get_gl_sharing_context_properties(), devices=[]) plot1 = LinePlot(gl_context, cl_context, n_vertices, scale=0.5, color=(1, 0, 0)) plot2 = LinePlot(gl_context, cl_context, n_vertices, scale=1.1, color=(0, .8, .2)) generate_sin = cl.Program(cl_context, src).build().generate_sin pipe_segment = ComputationalPipe(gl_context, cl_context, (n_vertices,), None, generate_sin, plot1.vtx_array.cl_buffer, np.float32(1.1))