Getting transparency to work in glumpy with pygame -


i have been having difficulties getting glumpy work transparent colormaps, , transparency in general.

below simple script should draw 2 transparent glumpy images, 1 on top of other. second overwrites first, can't see 1 behind other.

i have experimented different opengl enable/disable commands, no joy! or suggestions appreciated.

from pylab import * import pygame pygame.locals import *  import glumpy import opengl.gl gl import opengl.glu glu  # set width , height of screen [width,height] size=[256,256] screen=pygame.display.set_mode(size,opengl|doublebuf)  ## think here might work, i've ## experimented turining these off , on. suggestions? gl.gldisable(gl.gl_depth_test) gl.gldisable(gl.gl_lighting) gl.glenable(gl.gl_blend) gl.glblendfunc (gl.gl_src_alpha, gl.gl_one_minus_src_alpha)  = np.random.rand(256,256).astype('f') a[0:128,:] = 1.0 b = np.random.rand(256,256).astype('f') b[:,0:128] = 1.0  # cmaps acm = glumpy.colormap.colormap("rd", (0., (1.,1.,0.,0.0)), (1., (1.0,0.0,0.0,1.0))) bcm = glumpy.colormap.colormap("bl", (0., (0.,1.0,1.,0.0)), (1., (0.0,0.0,1.0,1.0)))  # glumpy images ai = glumpy.image.image(a,colormap=acm) bi = glumpy.image.image(b,colormap=bcm)  print('press q or esc quit')  while true :     gl.glpushmatrix()     gl.glloadidentity()     gl.glviewport(0, 0, size[0],size[1])      # draw diagonal line underneath     gl.glcolor4d(1,0,0,1)     gl.glbegin(gl.gl_lines)     gl.glvertex3d(0,0,-0.1)     gl.glvertex3d(1,1.0,-0.1)     gl.glend()      # draw glumpy images, ai beneath bi     ai.draw(x=-1,y=-1,z=0,width=2.0,height=2.0)     bi.draw(x=-.9,y=-.9,z=0.1,width=1.8,height=2.0)      gl.glpopmatrix()      pygame.display.flip()     gl.glclearcolor(0.1, 0.1, 0.1, 0.1);     gl.glclear(gl.gl_color_buffer_bit);      event in pygame.event.get(): # user did         if event.type == pygame.keydown:             if event.key in [pygame.k_q, pygame.k_escape] :                 pygame.quit()                 sys.exit() 

i believe problem above caused bug in glumpy. have outlined simple patch appears rectify problem here: https://groups.google.com/forum/#!topic/glumpy-users/uui4yzl0ktu


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -