I'm developing a videogame in Android using OpenGL ES. I'm having some issues with the redimensioning of the textures.
I would like that my game could be compatible with any resolution, and for this, I created a constant with the relation between the game resolution and the screen resolution, like this:
Display display = getWindowManager().getDefaultDisplay();
KTE.SCREEN_WIDTH = display.getWidth();
KTE.SCREEN_HEIGHT = display.getHeight();
KTE.REDIMENSION_X = KTE.SCREEN_WIDTH/KTE.GAME_WIDTH;
KTE.REDIMENSION_Y = KTE.SCREEN_HEIGHT/KTE.GAME_HEIGHT;
Using this constant, I get the same result using differents screens sizes (with the redimensioning of all of the textures using the constant I calculated in the code before).
The problem is that I wanted to reduce the GAME resolution to make bigger all the textures, and now I get black pixels around the textures because my redimension constants are floats with a lot of decimals, and I guess all those black pixels are positions that are left during this calculations...
Anyone got this problem before? Any tip to redimensioning the game? I have tried a lot of things and I'm really stuck. Thanks.
It sounds like the "redimensioning" of the textures isn't working as expected. For instance, perhaps you are only resizing the data of the texture, but the texture itself is still the same size as before. This would account for black pixels at the boundary. Be sure you're creating your textures with your KTE.REDIMENSION_X/Y factor, and be sure when you're writing to your textures you're writing to the edges of them.
As for redimensioning the game, do you mean the screen size you render to? For this, it should be a simple change to glViewport(...) and perhaps the perspective frustrum's or orthos you create to view your scene. Changes to both of these are typically done when a screen size changes - changes to textures generally are not needed, except perhaps to bump up resolution (for instance for iOS retina displays that have 2x pixels).