问题
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.
回答1:
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)
来源:https://stackoverflow.com/questions/11734666/opengl-es-texture-mapping