Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL ES texture mapping

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.

like image 840
Anton Boritskiy Avatar asked Mar 06 '26 02:03

Anton Boritskiy


1 Answers

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)

like image 127
Michael Avatar answered Mar 07 '26 16:03

Michael



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!