[PyOpenGL-Users] Why glDrawpixels does not render my transparent background?
Brought to you by:
mcfletch
From: Stéphane A. <san...@fr...> - 2012-02-02 14:01:55
|
Hi ! I want to render font in opengl with transparent background. The main problem is that my background is always opaque black ! Thanks for help. here is my code : glEnable(GL_BLEND) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) font = ImageFont.truetype("/usr/share/fonts/truetype/wqy/wqymicrohei.ttc", 16) textsize = font.getsize(u"当前运行列表") im = Image.new("RGB",textsize,"#000") draw = ImageDraw.Draw(im) transparent_area = (0,0,im.size[0],im.size[1]) mask=Image.new('L', im.size, color=0) drawmask = ImageDraw.Draw(mask) drawmask.rectangle(transparent_area, fill=0) im.putalpha(mask) draw.text((0,0), u"当前运行列表", font=font, fill="red") #im.save('render.png') ix, iy, image = im.size[0], im.size[1], im.tostring("raw", "RGBA", 0,-1) glDrawPixels(ix,iy,GL_RGBA,GL_UNSIGNED_BYTE,image) |