views:

430

answers:

2

Hi

Using Opengl ES for Anroid we’re facing a problem when drawing a square with a texture. They look fine from a distance, but when getting close to the model the texture screws up. We believe this is caused by the fact that the model only consists of four vertices:

float[] coords = {

-1, 1, 0.0f,

1, 1, 0.0f,

-1, -1, 0.0f,

1, -1, 0.0f,
};

That is why we want to expand the model so it consists of 10x10 polygons, so the question is: In which order do we have to draw the vertices to create a plane similar to this:

http://cocktailgenerator.net/cis4/plan.png

Using GL_TRIANGLE_STRIP we are able to draw a rectangle of polygons like (1x10) and it works well, but how do we expand it to 10x10?

A: 

If you’re creating the rows from left to right you simply start a new row by adding an invisible degenerate strip: You add the last point of the row twice, inserting zero-area triangles. These triangles will be invisible when rendering faces. By using this technique you can create discontinuities in the strip and, for instance, start a new row in a big plane.

Regarding the original problem: Are you sure that you can get rid of you rendering problems by subdividing your mesh? It does not really sound like the right way to go.

Nikolai Ruhe
Thanks for your reply. We didn’t know that it was possible to divide meshes. Do you have a link with an example on how to do it?
Glen
+2  A: 

Here is how I solved it:

http://blog.jayway.com/2010/02/15/opengl-es-tutorial-for-android-%E2%80%93-part-v/

Glen