Differences between textureoptions in andengine

Source: Internet
Author: User

After learning the textures in andengine, we found that textureoptions has the following options in the source code:

public static final TextureOptions NEAREST = new TextureOptions(GLES20.GL_NEAREST, GLES20.GL_NEAREST, GLES20.GL_CLAMP_TO_EDGE, GLES20.GL_CLAMP_TO_EDGE, false);public static final TextureOptions BILINEAR = new TextureOptions(GLES20.GL_LINEAR, GLES20.GL_LINEAR, GLES20.GL_CLAMP_TO_EDGE, GLES20.GL_CLAMP_TO_EDGE, false);public static final TextureOptions REPEATING_NEAREST = new TextureOptions(GLES20.GL_NEAREST, GLES20.GL_NEAREST, GLES20.GL_REPEAT, GLES20.GL_REPEAT, false);public static final TextureOptions REPEATING_BILINEAR = new TextureOptions(GLES20.GL_LINEAR, GLES20.GL_LINEAR, GLES20.GL_REPEAT, GLES20.GL_REPEAT, false);public static final TextureOptions NEAREST_PREMULTIPLYALPHA = new TextureOptions(GLES20.GL_NEAREST, GLES20.GL_NEAREST, GLES20.GL_CLAMP_TO_EDGE, GLES20.GL_CLAMP_TO_EDGE, true);public static final TextureOptions BILINEAR_PREMULTIPLYALPHA = new TextureOptions(GLES20.GL_LINEAR, GLES20.GL_LINEAR, GLES20.GL_CLAMP_TO_EDGE, GLES20.GL_CLAMP_TO_EDGE, true);public static final TextureOptions REPEATING_NEAREST_PREMULTIPLYALPHA = new TextureOptions(GLES20.GL_NEAREST, GLES20.GL_NEAREST, GLES20.GL_REPEAT, GLES20.GL_REPEAT, true);public static final TextureOptions REPEATING_BILINEAR_PREMULTIPLYALPHA = new TextureOptions(GLES20.GL_LINEAR, GLES20.GL_LINEAR, GLES20.GL_REPEAT, GLES20.GL_REPEAT, true);public static final TextureOptions DEFAULT = NEAREST;

Some netizens in the Forum gave the following instructions:

-Nearest: faster then bilinear as only the nearest pixel on
Texture is used (sprites tend to look pixelated when, physical resolution is higher or lower than texture resolution. up/down-scaling)
-Bilinear: slower than nearest, but looks better, as not only one pixel from the texture is fetched but the 4 nearest.

The difference between those and the repeating textureoptions is the way OpenGL treats texturecoordinates that are out of the physical bounds of the texture (usually ranging from 0.0 to 1.0 ).
Where repeating paints the texture twice when the coordinates go from 0.0 to 2.0, NON-REPEATING will stretch the outermost pixel of the texture what looks pretty uugly.

So the repeating textureoptions are used only in very special cases.

For a description what the premultiplyalpha-Thing is, have a look here:
Click Open Link

In general, nearest is faster than bilinear, because nearest uses a pixel closest to the zoom position during scaling, while bilinear uses the nearest four pixels to determine the final display effect of the zoom position. However, bilinear achieves better results than earest.

Repeating is only used in special cases.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.