Load image with pyglet turns some transparency pixels white

1.1k Views Asked by At

I'm using cocos2D-python and I am loading images with pyglet.image.load and pyglet.resource.image but it still adds some white pixels where it is suppoused to be transparent.

I've used pygame before but never experienced it with that.

If it matters I use paint.net and save the images as .png

Thanks in advance

https://dl.dropboxusercontent.com/u/58141766/white%20pixels%20%3B(.png

2

There are 2 best solutions below

0
On

Just to add some clarity for Frothiny's answer:

The lines he mentioned fix the problem, but their placement is important. I was able to get the fix to work by adding the gl lines immediately after creating the sprite.

Example

# Your imports...
from pyglet.gl import *
# Your program's code...
Sprite('someimage.png')
glEnable(GL_TEXTURE_2D)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
0
On

So apparently because I wanted it pixelated it decided to mipmap it or something so it anti-aliased it kind of.. Anyways I found this as a halfworking solution:

from pyglet.gl import *
glEnable(GL_TEXTURE_2D)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)

Then a working solution was adding glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST) everytime I loaded a texture, probably not the most effecient thing to do but meh.

Here is where I found it: https://gamedev.stackexchange.com/questions/20297/how-can-i-resize-pixel-art-in-pyglet-without-making-it-blurry