I am writing a small application that currently generates a random texture map.
I draw this map as a group of 10 x 15 ATVs that fill all triangular stripes. I use a “map” to capture an int, which I then take as the texture location for this square in textureAtlas. therefore, for example, 0 is the bottom left “tile”. Atlas is 128 x 128 and is divided into 32 pixel tiles.
However, I seem to get some odd artifacts where a texture from one tile crawls to the next plate. I wondered if this was the image itself, but as far as I can tell, the pixels are exactly where they should be. Then I looked at the texture coordinates that I specified, but they all look accurate (0.0, 0.25, 0.5, 0.75, 1.0), dividing them into 4 rows and columns, which I would expect).
It is strange if I run it on an emulator, I do not receive any artifacts.
Is there a parameter that I don’t have that will cause 1 pixel bleeding? It seems that it is only vertical - it can be connected with the phone, I "stretch" the image in this direction when the phone screen is larger than usual in this direction.
I load the texture like this:
int id = newTextureID(gl);
Matrix flip = new Matrix();
flip.postScale(1f, -1f);
Bitmap temp = BitmapFactory.decodeResource(context.getResources(), resource);
int width = temp.getWidth();
int height = temp.getHeight();
Bitmap bmp = Bitmap.createBitmap(temp, 0, 0, width, height, flip, true);
temp.recycle();
gl.glBindTexture(GL10.GL_TEXTURE_2D, id);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR);
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bmp, 0);
TextureAtlas atlas = new TextureAtlas(id, width, height, tileSize);
return atlas;
Then I will do this:
gl.glBindTexture(GL10.GL_TEXTURE_2D, currentAtlas.textureID);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer);
gl.glDrawElements(GL10.GL_TRIANGLES, indices.length, GL10.GL_UNSIGNED_SHORT, indexBuffer);
, , ...
- , , , , , , !
.
: - . , . : D /.
ScreenCap