什么是现代OpenGL等同于glBegin / glEnd [英] What is the modern OpenGL equivalent to glBegin/glEnd

查看:478
本文介绍了什么是现代OpenGL等同于glBegin / glEnd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为OpenGL构建一个图形API,它基于基本的调用绘图图形样式。基本上,不是将数据存储到GPU中,而是使用它的句柄来调用它,给出信息来绘制应该绘制每个更新的内容。我知道它很慢,但它很简单,它是非性能关键应用程序。无论如何,有没有任何现代等同于glBegin / glEnd?它不需要对每个顶点的调用,但是我可以发送数据每次更新,而不存储在gpu中的顶点?

I'm building a graphics API for OpenGL, which is based off the basic call-to-draw graphics style. Basically, instead of storing the data into the GPU, and call it using it's handle, give the info to draw what it should be drawing each update. I know it's slow, but it's simple and it's for non-performance critical applications. Anyway, is there any modern equivalent to glBegin/glEnd? It doesn't have to a call for every vertex, but a way where I can send the data each update, without storing the vertices in the gpu?

推荐答案

你几乎回答了自己的问题。

You pretty much answered your own question.


有什么现代的等同于glBegin / glEnd?它不需要对每个顶点的调用,但是我可以发送数据每次更新,而不存储在gpu中的顶点?

is there any modern equivalent to glBegin/glEnd? It doesn't have to a call for every vertex, but a way where I can send the data each update, without storing the vertices in the gpu?

基本上没有,现代的方式是使用 VAO VBO (和IBO)。

Basically no, the modern way is to use VAOs with VBOs (and IBOs).

如果您将要更改VBO中的数据,然后记住您可以更改模式参数sdk / docs / man / xhtml / glBufferData.xmlrel =nofollow> glBufferData

If you're going to change the data within the VBO, then remember that you can change the mode parameter in glBufferData.


  • GL_STREAM_DRAW - 数据存储内容将被修改一次,最多使用几次。

  • GL_STREAM_DRAW - The data store contents will be modified once and used at most a few times.

GL_STATIC_DRAW - 数据存储内容将被修改一次并使用多次。

GL_STATIC_DRAW - The data store contents will be modified once and used many times.

GL_DYNAMIC_DRAW - 数据存储内容将重复修改并使用多次。

GL_DYNAMIC_DRAW - The data store contents will be modified repeatedly and used many times.

然后使用 GL_DYNAMIC_DRAW ,而不是使用 GL_STATIC_DRAW 与使用 GL_STATIC_DRAW 相比,虽然这取决于数据量以及更改频率的频率。但尝试尽可能限制它,如果你不需要更新缓冲区内的数据,如果你不需要。

Then instead of using GL_STATIC_DRAW, then use GL_DYNAMIC_DRAW this will increase the FPS a lot compared to when using GL_STATIC_DRAW, though this depends on the amount of data, and how frequent you change it. But try to limit it as much as you can, like don't update the data within the buffers if you don't actually need to.

您可以阅读更多关于 OpenGL的Wiki点击此处的不同缓冲区。

You can read more about the different buffers on OpenGL's Wiki click here.

这篇关于什么是现代OpenGL等同于glBegin / glEnd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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