Question

I need to draw circles in my Android application. Actually it is a Pacman game and I need to draw tablets. Since there are many tablets on field I decided to draw each tablet with a single polygon.

Here is the illustration of my idea:

http://www.advancedigital.ru/ideal_circle_with_only_one_polygon.jpg

Vertex coordrs:

//  (x, y)
0 : -R, R * (Math.sqrt(2) + 1)
1 : -R, -R
2 : R * (Math.sqrt(2) + 1), -R

Vertex coords are calculated relative to circle center to place circles with ease later.

The problem is in texture mapping, according to my calculations UVs should be like this

0 : 0, -(Math.sqrt(2) + 0.5)
1 : 0, 1
2 : 1, (Math.sqrt(2) + 0.5)

But negative V value causes application to show only black screen. That is why I think that I'm missing something or I'm going the wrong way…

My question is: Is it possible to render the texture in that way or not? If it isn't possible, what is the best way to draw small dots?

P.S: I'm working with OpenGL ES 2.0 on Android.

Seems to me, that this guy is trying to do the same.

Was it helpful?

Solution

The GL_TEXTURE_WRAP_S and GL_TEXTURE_WRAP_T texture parameters are set to GL_REPEAT by default. Set them to GL_CLAMP_TO_EDGE instead to get the effect you're looking for (see the glTexParameter documentation)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top