sprite.scale == blur? how to disable

304 views
Skip to first unread message

Dysrythmic

unread,
Aug 17, 2009, 7:18:36 PM8/17/09
to pyglet-users
Hello,

I begin in pyglet and opengl in general.
I should want to disable the sort of blur or antialiasing filter when
a scaled sprite is draw (when scale > 1 ).
I find nothing about that in doc or on web...

thanks for help

++

Tristam MacDonald

unread,
Aug 17, 2009, 9:21:31 PM8/17/09
to pyglet...@googlegroups.com


On Mon, Aug 17, 2009 at 7:18 PM, Dysrythmic <metallic...@hotmail.com> wrote:

I begin in pyglet and opengl in general.
I should want to disable the sort of blur or antialiasing filter when
a scaled sprite is draw (when scale > 1 ).
I find nothing about that in doc or on web...

That isn't a blur - it is the default bilinear filtering on textures. You can disable it (but be warned that the results may not be pretty), by setting the texture filter to GL_NEAREST - see the following example:

from pyglet.gl import *

def texture_set_mag_filter_nearest( texture ):
glBindTexture( texture.target, texture.id )
glTexParameteri( texture.target, GL_TEXTURE_MAG_FILTER, GL_NEAREST )
glBindTexture( texture.target, 0 )

img = pyglet.image.load( 'image.png' )

texture_set_mag_filter_nearest( img.get_texture() )

sprite = pyglet.sprite.Sprite( img )
Reply all
Reply to author
Forward
0 new messages