Alexis King
Alexis King

Reputation: 43842

Disable anti-aliasing by default in cocos2d

I'm making a game in cocos2d that uses "old-school" style graphics, and I don't want the sprites to be antialiased in any way. I can use [[sprite texture] setAliasTexParameters] to disable the antialiasing, but I need to do that for every sprite, and it clutters the code. Is there any way to do it globally by default?

Upvotes: 1

Views: 3762

Answers (3)

Benoît Freslon
Benoît Freslon

Reputation: 2021

CCTexture2D.m

 - (id) initWithData:(const void*)data pixelFormat:(CCTexture2DPixelFormat)pixelFormat pixelsWide:(NSUInteger)width pixelsHigh:(NSUInteger)height contentSize:(CGSize)size
{
    if((self = [super init])) {
        glPixelStorei(GL_UNPACK_ALIGNMENT,1);
        glGenTextures(1, &name_);
        glBindTexture(GL_TEXTURE_2D, name_);

        [self setAliasTexParameters];

Upvotes: 1

Daniel
Daniel

Reputation: 31579

You can edit CCTexture2D code to setAliasTexParameters by default, but that will mean updates to cocos2d will be a headache really fast.
What I done when I needed this, I wrote a function to create the textures for me and it called setAliasTexParameters on each.

Upvotes: 2

Daniel Pereira
Daniel Pereira

Reputation: 1785

You may be able to get the same effect by reducing the pixel format.

[CCTexture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGBA4444];

If not, you could create a factory that sets the setAliasTexParameters as the texture object is instantiated reducing the code clutter.

Upvotes: 0

Related Questions