热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

OpenGLES-如何绘制填充的多边形?-OpenGLES-HowtoDrawafilledPolygon?

ItriedgooglingandsearchingonstackbutIdidntfindanything:-((Mappingirregularshapesor

I tried googling and searching on stack but I didn't find anything :-(
( Mapping irregular shapes or other polygons (cartoons, sprites) to triangles in OpenGL ES )

我尝试使用谷歌搜索和搜索堆栈,但我没有找到任何东西:-((将不规则形状或其他多边形(卡通,精灵)映射到OpenGL ES中的三角形)

I want to draw a filled polygon in OpenGL ES on iPad (2D, don't need 3D) (I'm new to OpenGL && OpenGL ES) It seems simple on OpenGL but with ES with just can draw triangle.

我想在iPad上的OpenGL ES中绘制一个填充多边形(2D,不需要3D)(我是OpenGL && OpenGL ES的新手)。在OpenGL上看起来很简单但是ES只能画三角形。

But I can't find any good tutorial about this :-( Does it exist any wrapper / library or anything else that could help me ?

但我找不到任何关于此的好教程:-(是否存在任何包装/库或其他任何可以帮助我的东西?

I don't want to use CoreGraphics, it's too slow for what I'm doing ^^
And if possible, avoiding too (big) library like Cocos2D.

我不想使用CoreGraphics,它对我正在做的事情来说太慢了^^如果可能的话,避免像Cocos2D这样的(大)库。

Edit : Working On the Problem, here are some useful links (will edit)
Links
- Polygon Triangulation
http://www.vterrain.org/Implementation/Libs/triangulate.html
http://en.wikipedia.org/wiki/Polygon_triangulation (WIKI) http://www.flipcode.com/archives/Efficient_Polygon_Triangulation.shtml (polygon WITHOUT holes) http://www.cs.unc.edu/~dm/CODE/GEM/chapter.html (polygon WITH holes, C code)

编辑:解决问题,这里有一些有用的链接(将编辑)链接 - 多边形三角测量http://www.vterrain.org/Implementation/Libs/triangulate.html http://en.wikipedia.org/wiki/Polygon_triangulation (WIKI)http://www.flipcode.com/archives/Efficient_Polygon_Triangulation.shtml(没有孔的多边形)http://www.cs.unc.edu/~dm/CODE/GEM/chapter.html(带孔的多边形, C代码)

Solution
I will try using polygon tessellation to get triangles. At first I'm going to try ( http://www.flipcode.com/archives/Efficient_Polygon_Triangulation.shtml ) and as I need polygon with holes, the second one ( http://www.cs.unc.edu/~dm/CODE/GEM/chapter.html ). If anyone has a better way, PLEASE, tell me with a comment ^^

解决方案我将尝试使用多边形细分来获取三角形。起初我要尝试(http://www.flipcode.com/archives/Efficient_Polygon_Triangulation.shtml),因为我需要带孔的多边形,第二个(http://www.cs.unc.edu/~) dm / CODE / GEM / chapter.html)。如果有人有更好的方法,请告诉我评论^^

Thanks :-)

6 个解决方案

#1


3  

Cocos2D is cool library wrapping OpenGL and has many useful features ( mainly for games but not limited to ).

Cocos2D是包装OpenGL的酷库,具有许多有用的功能(主要用于游戏但不限于此)。

For polygon tessellation use : http://flipcode.net/archives/Efficient_Polygon_Triangulation.shtml I've used it before and it worked well.

对于多边形镶嵌使用:http://flipcode.net/archives/Efficient_Polygon_Triangulation.shtml我以前使用它并且它运行良好。

#2


6  

I haven't tried using OpenGL ES, but judging from a quick look in the documentation you should be able to draw a convex polygon using e.g. a "triangle fan":

我没有尝试过使用OpenGL ES,但从文档中快速浏览一下,您应该能够使用例如,绘制凸多边形。一个“三角扇”:

glVertexPointer(2, ..., arrayOfCoordinates)
...
glDrawElements(GL_TRIANGLE_FAN, ... , arrayOfIndices);

You can think of a "triangle fan" as the spokes of a bicycle-wheel dividing the area of the wheel into "triangles" (the outer edge of a bicycle wheel is of course round, but I hope you get the idea).

您可以将“三角扇”视为自行车车轮的轮辐,将车轮区域划分为“三角形”(自行车车轮的外缘当然是圆形的,但我希望您能得到这个想法)。

UPDATE: I found a small diagram on the web:

更新:我在网上找到了一个小图:

#3


2  

On the Wikipedia Polygon Triangulation Talk page I argue that more triangles will in fact be faster.

在Wikipedia Polygon Triangulation Talk页面上,我认为更多的三角形实际上会更快。

I have written a triangulation engine that supports holes and runs in O(n log (n)) time. I tested it under Gdk and then made an Android app from it.

我编写了一个支持孔的三角测量引擎,并在O(n log(n))时间内运行。我在Gdk下测试了它,然后用它制作了一个Android应用程序。

#4


2  

What is your final choice? I recently tested 5 of the libs listed in below link: http://vterrain.org/Implementation/Libs/triangulate.html

你最后的选择是什么?我最近测试了以下链接中列出的5个库:http://vterrain.org/Implementation/Libs/triangulate.html

But NONE of them is satisfying...

但他们中的任何一个都令人满意......

  1. iphone-glu: (http://code.google.com/p/iphone-glu/)

    • Bugs in the algorithm? there are tiny holes not filled, or sometimes draw outside of the polygon
    • 算法中的错误?有没有填充的小孔,或者有时会在多边形外部绘制

  2. iphone-glu:(http://code.google.com/p/iphone-glu/)算法中的错误?有没有填充的小孔,或者有时会在多边形外部绘制

  3. Triangulte: (http://www.flipcode.com/archives/Efficient_Polygon_Triangulation.shtml)

    • doesn't support holes…
    • 不支持洞...

  4. Triangulte:(http://www.flipcode.com/archives/Efficient_Polygon_Triangulation.shtml)不支持漏洞......

  5. Triangulation: (http://www.cs.unc.edu/~dm/CODE/GEM/chapter.html)

    • Buggy, sometimes runs out of bounds, or negative index etc...
    • 越野车,有时跑出界限,或负面指数等...

  6. 三角测量:(http://www.cs.unc.edu/~dm/CODE/GEM/chapter.html)越野车,有时跑出界限,或负面指数等...

  7. poly2tri: (http://code.google.com/p/poly2tri/)

    • Buggy, crash in certain cases
    • 越野车,在某些情况下崩溃

  8. poly2tri:(http://code.google.com/p/poly2tri/)Buggy,在某些情况下崩溃

  9. openglespolygon: (https://github.com/nroets/OpenGlEsPolygon)

    • imperfect algorithm? there are tiny holes (not filled) along the edges of the polygon
    • 不完美的算法?沿着多边形的边缘有小孔(未填充)

  10. openglespolygon:(https://github.com/nroets/OpenGlEsPolygon)不完美的算法?沿着多边形的边缘有小孔(未填充)

#5


0  

In non-ES OpenGL one would tend to use the tessellator from the GL Utility (glu) library. I found this project which aims to make glu available for the iPhone and it claims to support polygon tessellation - if it works, then it would be a good option.

在非ES OpenGL中,人们倾向于使用GL Utility(glu)库中的曲面细分器。我发现这个项目的目的是让iPhone可用于iPhone,它声称支持多边形镶嵌 - 如果它有效,那么它将是一个不错的选择。

#6


0  

When you need do triangulation of polygons with holes, you can try use GPC. There is function for tringulation called gpc_polygon_to_tristrip.

当您需要对带孔的多边形进行三角测量时,您可以尝试使用GPC。有一个叫做gpc_polygon_to_tristrip的tringulation功能。

For render use GL_TRIANGLE_STRIP.

对于渲染使用GL_TRIANGLE_STRIP。

But read gpc license first!

但首先阅读gpc许可证!


推荐阅读
  • 知识图谱——机器大脑中的知识库
    本文介绍了知识图谱在机器大脑中的应用,以及搜索引擎在知识图谱方面的发展。以谷歌知识图谱为例,说明了知识图谱的智能化特点。通过搜索引擎用户可以获取更加智能化的答案,如搜索关键词"Marie Curie",会得到居里夫人的详细信息以及与之相关的历史人物。知识图谱的出现引起了搜索引擎行业的变革,不仅美国的微软必应,中国的百度、搜狗等搜索引擎公司也纷纷推出了自己的知识图谱。 ... [详细]
  • 基于PgpoolII的PostgreSQL集群安装与配置教程
    本文介绍了基于PgpoolII的PostgreSQL集群的安装与配置教程。Pgpool-II是一个位于PostgreSQL服务器和PostgreSQL数据库客户端之间的中间件,提供了连接池、复制、负载均衡、缓存、看门狗、限制链接等功能,可以用于搭建高可用的PostgreSQL集群。文章详细介绍了通过yum安装Pgpool-II的步骤,并提供了相关的官方参考地址。 ... [详细]
  • GetWindowLong函数
    今天在看一个代码里头写了GetWindowLong(hwnd,0),我当时就有点费解,靠,上网搜索函数原型说明,死活找不到第 ... [详细]
  • EPICS Archiver Appliance存储waveform记录的尝试及资源需求分析
    本文介绍了EPICS Archiver Appliance存储waveform记录的尝试过程,并分析了其所需的资源容量。通过解决错误提示和调整内存大小,成功存储了波形数据。然后,讨论了储存环逐束团信号的意义,以及通过记录多圈的束团信号进行参数分析的可能性。波形数据的存储需求巨大,每天需要近250G,一年需要90T。然而,储存环逐束团信号具有重要意义,可以揭示出每个束团的纵向振荡频率和模式。 ... [详细]
  • 本文分享了一个关于在C#中使用异步代码的问题,作者在控制台中运行时代码正常工作,但在Windows窗体中却无法正常工作。作者尝试搜索局域网上的主机,但在窗体中计数器没有减少。文章提供了相关的代码和解决思路。 ... [详细]
  • 推荐系统遇上深度学习(十七)详解推荐系统中的常用评测指标
    原创:石晓文小小挖掘机2018-06-18笔者是一个痴迷于挖掘数据中的价值的学习人,希望在平日的工作学习中,挖掘数据的价值, ... [详细]
  • 本文详细介绍了Java中vector的使用方法和相关知识,包括vector类的功能、构造方法和使用注意事项。通过使用vector类,可以方便地实现动态数组的功能,并且可以随意插入不同类型的对象,进行查找、插入和删除操作。这篇文章对于需要频繁进行查找、插入和删除操作的情况下,使用vector类是一个很好的选择。 ... [详细]
  • 一、Hadoop来历Hadoop的思想来源于Google在做搜索引擎的时候出现一个很大的问题就是这么多网页我如何才能以最快的速度来搜索到,由于这个问题Google发明 ... [详细]
  • 学习SLAM的女生,很酷
    本文介绍了学习SLAM的女生的故事,她们选择SLAM作为研究方向,面临各种学习挑战,但坚持不懈,最终获得成功。文章鼓励未来想走科研道路的女生勇敢追求自己的梦想,同时提到了一位正在英国攻读硕士学位的女生与SLAM结缘的经历。 ... [详细]
  • 生成式对抗网络模型综述摘要生成式对抗网络模型(GAN)是基于深度学习的一种强大的生成模型,可以应用于计算机视觉、自然语言处理、半监督学习等重要领域。生成式对抗网络 ... [详细]
  • android listview OnItemClickListener失效原因
    最近在做listview时发现OnItemClickListener失效的问题,经过查找发现是因为button的原因。不仅listitem中存在button会影响OnItemClickListener事件的失效,还会导致单击后listview每个item的背景改变,使得item中的所有有关焦点的事件都失效。本文给出了一个范例来说明这种情况,并提供了解决方法。 ... [详细]
  • Metasploit攻击渗透实践
    本文介绍了Metasploit攻击渗透实践的内容和要求,包括主动攻击、针对浏览器和客户端的攻击,以及成功应用辅助模块的实践过程。其中涉及使用Hydra在不知道密码的情况下攻击metsploit2靶机获取密码,以及攻击浏览器中的tomcat服务的具体步骤。同时还讲解了爆破密码的方法和设置攻击目标主机的相关参数。 ... [详细]
  • t-io 2.0.0发布-法网天眼第一版的回顾和更新说明
    本文回顾了t-io 1.x版本的工程结构和性能数据,并介绍了t-io在码云上的成绩和用户反馈。同时,还提到了@openSeLi同学发布的t-io 30W长连接并发压力测试报告。最后,详细介绍了t-io 2.0.0版本的更新内容,包括更简洁的使用方式和内置的httpsession功能。 ... [详细]
  • http:my.oschina.netleejun2005blog136820刚看到群里又有同学在说HTTP协议下的Get请求参数长度是有大小限制的,最大不能超过XX ... [详细]
  • 本文介绍了在使用Python中的aiohttp模块模拟服务器时出现的连接失败问题,并提供了相应的解决方法。文章中详细说明了出错的代码以及相关的软件版本和环境信息,同时也提到了相关的警告信息和函数的替代方案。通过阅读本文,读者可以了解到如何解决Python连接服务器失败的问题,并对aiohttp模块有更深入的了解。 ... [详细]
author-avatar
Tags | 热门标签
RankList | 热门文章
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有