I'm following along the book, OpenGL ES 2 for Android : A Quick Start Guide, in Chapter 8, texture rendering.

The codes I followed along were typed according to the book. The texture I used in my program is a custom 128x256 image, while the texture the book used is a 512x1024 image. I figured since both texture image ratios are the same, the textures shouldn't be causing any issues.

Below is an image of a screenshot I took in Android, concerning the Z fighting.

The problem is in the center of the screenshot, the white link flickers through the blue portion of the texture rapidly. My guess would be that tje triangle fans were drawn incorrectly or something, but I couldn't think of any other ways of drawing triangle fans that doesn't work as it is supposed to do.

The white line shouldn't be drawn going through the table, that's it. I don't have a good example available to show what it should look like, but here is the texture, and how it should look when it is laid flat, like in the screenshot.

Quote

The book's example and my project are the same, I just swapped out the textures.

Why are you rendering 6 vertices? A triangle fan only requires 4 vertices to form a quad. If the problem really is Z-fighting, it's because you're rendering two overlapping triangles at almost the same depth. The flickering is due to rounding differences between the two triangles.

I did check that already, but didn't see an error. Of course theagentd is right that one only needs 4 vertices for a quad, but his approach should be correct too. He starts in the middle and then goes around the four corners (first needs to be stored twice).

Since you're setting the position of a FloatBuffer, the offset should indeed be in the number of floats. I was under the impression that you were using vertex buffer objects.

There's a huge number of things that could be going wrong actually. Try changing the shader to not sample the texture. Instead just have it output the texture coordinates to the red and blue channels. You need to figure out exactly where it's going wrong.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org