我怎么可以使用gldrawelements许多方格? [英] how i can use gldrawelements for many squares?

查看:124
本文介绍了我怎么可以使用gldrawelements许多方格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个2D 的Open GL 比赛,我必须在屏幕上绘制很多广场的tilemap的,具有diferent glTexCoordPointer 从质感。

I am developing a 2D Open GL game and i have to draw many squares on screen for a tilemap, with a diferent glTexCoordPointer from the texture.

现在,我不知道如何使用 Gldrawelements 为平局许多方格,如果我要画很多广场这将是指数的结构?

Now, I don't know how to use Gldrawelements for draw many squares, which would be the structure of the indices if I want to draw many squares?

和,我怎么可以把每个数组(顶点),其中包含在每平方米的坐标vertexbuffer

And, how can I put each array (vertices), which contains the coordinates of each square on the vertexbuffer?

此外,才有可能在短短的一个电话设置不同的 glTexCoordPointer 为每平方的方法或者是必要的一环像调用glDrawArrays ?但是,我想用 gldrawelements ,因为我不想做一个循环执行多次调用glDrawArrays 为每平方米,我的 FPS 尤其是下降。

Also, will it be possible to set different glTexCoordPointer for each square in just one call to the method or is necessary a loop like with GlDrawArrays? But, I want to use gldrawelements because i dont want to make a loop which execute many times gldrawarrays for each square, my fps drops notably.

推荐答案

如果该广场是彼此相邻,然后用四带(或等效一个三角地带):

If the squares are adjacent to each other, then use a quad-strip (or a equivalently a triangle-strip):

如果正方形是不相交的简单的使用四边形

If the squares are disjoint simply use quads

您也可以使用四带(等效于一个三角形地带)
在这种情况下,通过将简并四边形(三角形):

You can also use a quad-strip (equivalently a triangle-strip) in this case by adding degenerate quads (triangles):

GLushort indices[] = {A, B, C, D, D, E, E, F, G, H, H, I, I, J, K, L}

两个方块用相同的顶点位置,但不同的纹理坐标,必须重新用不同的四边形psented $ P $。

Two squares with the same vertex positions, but different texture coordinates must be represented with different quads.

这篇关于我怎么可以使用gldrawelements许多方格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆