filled antialiased poly cocos2d(填充抗锯齿聚 cocos2d)
问题描述
如何在 Cocos2D 框架中绘制填充多边形?
How can I draw filled poly in Cocos2D framework?
下面的代码绘制多边形但没有抗锯齿.我应该改变什么?
Code below draws poly but without antialiasing.What should I change?
void ccFillPoly( CGPoint *poli, int points, BOOL closePolygon )
{
// Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
// Needed states: GL_VERTEX_ARRAY,
// Unneeded states: GL_TEXTURE_2D, GL_TEXTURE_COORD_ARRAY, GL_COLOR_ARRAY
glDisable(GL_TEXTURE_2D);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, poli);
if( closePolygon )
// glDrawArrays(GL_LINE_LOOP, 0, points);
glDrawArrays(GL_TRIANGLE_FAN, 0, points);
else
glDrawArrays(GL_LINE_STRIP, 0, points);
// restore default state
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_TEXTURE_2D);
}
推荐答案
模拟抗锯齿的一个好方法是在多边形周围添加透明顶点.这种方法快速且美观,但实施起来并不难.这里是抗锯齿线的解决方案.
One good approach to emulate antialiasing is to add transparent vertices around your polygon. This method is fast and fine-looking, but is little hard to implement. Here is solution for antialiased lines.
如果您不担心性能,您可以多次渲染多边形,并具有一定的透明度并偏移 1 个像素.这适用于没有纹理的多边形.
If you don't worry about performance, you may render the polygon multiple times with some transparency and offset by 1 pixel. This would work for not textured polygons.
这篇关于填充抗锯齿聚 cocos2d的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:填充抗锯齿聚 cocos2d


基础教程推荐
- NSString intValue 不能用于检索电话号码 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01