OpenGL ES 2.0:带有VBO的glDrawElements之前需要的命令 [英] OpenGL ES 2.0: Commands required just before glDrawElements with VBO

查看:441
本文介绍了OpenGL ES 2.0:带有VBO的glDrawElements之前需要的命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了带有顶点和索引数据的顶点缓冲对象(VBO).我还创建了一个GLprogram来使用自定义着色器,因此我在代码中调用了glUseProgram.

I've setup a Vertex Buffer Object (VBO) with vertex and index data. I've also created a GLprogram to use custom shaders, so I call glUseProgram within my code.

我的顶点数据每帧都会更改,因此我已经为我的两个glBufferData调用提供了GL_STREAM_DRAW(一个用于顶点数据,一个用于索引).

My vertex data changes every frame, so I've supplied GL_STREAM_DRAW to my two glBufferData calls (one for vertex data, one for indices).

当顶点数据改变时,我使用glBufferSubData来修改它们的顶点数据区域.在每一帧中,我都希望从第一个顶点绘制到第N个顶点,其中N是一个变化的值.

I use glBufferSubData to modify regions of my vertex data when they change. At each frame I want to draw from the first vertex to the Nth, with N being a changing value.

我的问题是:我每次调用glDrawElements都必须调用 哪些命令?理想情况下,我只想简单地自己调用glDrawElements出于性能原因,每个帧.

My question is: which commands must I call every time that I call glDrawElements? Ideally I'd like to simply call glDrawElements on its own in each frame, for performance reasons.

我正在研究《 OpenGL ES 2.0编程指南》这本书,但没有地方告诉我每次绘制时必须使用哪些命令,而只需要调用一次.

I'm poring over the book "OpenGL ES 2.0 Programming Guide" but nowhere does it tell me which commands I must use every time I draw, and which I need to call only once.

推荐答案

glDrawElements提交几何.如果您使用的是VBO,则它将使用当前绑定的GL_ELEMENT_ARRAY_BUFFER中的条目为GL_ARRAY_BUFFER的相关部分或绑定到每个属性的缓冲区中的条目建立索引.

glDrawElements submits geometry. If you're using VBOs then it uses entries in the currently bound GL_ELEMENT_ARRAY_BUFFER to index entries in the relevant portions of the GL_ARRAY_BUFFER or buffers bound for each attribute.

如果您不更改任何其他绑定,则无需重复glDrawElements以外的任何调用.如果在当前调用glDrawElements的位置复制并粘贴该行以使其出现两次,则所有几何图形的绘制次数将是以前的两倍.

If you don't change any other bindings then is no need to repeat any call other than glDrawElements. If, where you currently call glDrawElements you copy and paste that line to appear twice, all your geometry will be drawn twice as many times as before.

这篇关于OpenGL ES 2.0:带有VBO的glDrawElements之前需要的命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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