I’m developing fairly simple 2D game for android using OpenGL ES. I want it to run on almost any device on the market. The problem I face is, when I map the textures I use. If the image I want to map is with different size than its target object, the image quality is reduced (even when the size of the image is bigger than the object), it gets pixelated. I want very sharp images, and the only way to receive them is when I use textures and objects with same dimensions. But in this case I need like 4,5 textures representing the same image with different dimensions, to support enough screen resolutions. I’m using PNG images and the following GL methods:
glClear(GL10.GL_COLOR_BUFFER_BIT);
glEnable(GL10.GL_TEXTURE_2D);
glEnable(GL10.GL_BLEND);
glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
//drawing happens here
glDisable(GL10.GL_BLEND);
There is no problem for me to create so many images, but the size of the game will get bigger. Am I doing anything wrong, or just OpenGL can not resize images like Photoshop?
Have you experimented with alternative sampling options, like GL_NEAREST or GL_LINEAR? (see
glTexParameteri).I don’t think this is the fault of opengl, but when you display textures that are not at their native resolution (or an even multiple of it), there will always be some loss of exactness (because the image must be resampled at non-pixel boundaries). GL_LINEAR may alleviate some of the pixellated look at the expense of being slightly blurry, which may or may not be noticible.