OpenGL ES texture mapping

て烟熏妆下的殇ゞ 提交于 2019-12-10 20:24:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!