什么是相当于 glBegin/glEnd 的现代 OpenGL [英] What is the modern OpenGL equivalent to glBegin/glEnd

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

问题描述

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

解决方案

你几乎已经回答了你自己的问题.

<块引用>

是否有任何现代版本的 glBegin/glEnd 等价物?它不必调用每个顶点,而是一种我可以在每次更新时发送数据的方式,而无需将顶点存储在 gpu 中?

基本上不,现代方法是使用 VAOsVBOs(和 IBOs).

如果您要更改 VBO 中的数据,请记住您可以更改 glBufferData.

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

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

  • GL_DYNAMIC_DRAW - 数据存储内容将被重复修改和多次使用.

然后,而不是使用 GL_STATIC_DRAW,然后使用 GL_DYNAMIC_DRAW 与使用 GL_STATIC_DRAW 相比,这将大大提高 FPS,尽管这取决于数据量,以及更改数据的频率.但是尽量限制它,比如如果你真的不需要,不要更新缓冲区中的数据.

您可以在 OpenGL Wiki 上阅读有关不同缓冲区的更多信息.>

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.

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?

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

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 - The data store contents will be modified once and used at most a few times.

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

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

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.

You can read more about the different buffers on the OpenGL Wiki.

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

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