什么时候的OpenGL拿完在功能指针? [英] When does OpenGL get finished with pointers in functions?

查看:173
本文介绍了什么时候的OpenGL拿完在功能指针?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OpenGL的具有多项功能直接采取指针。他们中的一些读取这些指针数据,其他的将数据写入到这些指针

OpenGL has a number of functions that directly take pointers. Some of them read data from those pointers, others write data to those pointers.

不过,OpenGL函数往往不会立即执行。通常情况下,当你画的东西,它需要一段时间绘制完成。

However, OpenGL functions often don't execute immediately. Usually, when you draw something, it takes a while for the drawing to finish.

因此​​,我怎么知道什么时候的OpenGL与指针我把它完成了吗?

So how do I know when OpenGL is finished with a pointer I give it?

推荐答案

所有OpenGL函数,除下文所述,将与你给它在该函数的返回指针任何完成。因此, glReadPixels 将完成基于其返回的所有像素读取和格式转换。这就是为什么异步像素传送是用于读取操作很重要。它允许OpenGL的的做到这一点,不与GPU同步。

All OpenGL functions, with the exception noted below, will be finished with any pointer you give it upon that function's return. So glReadPixels will have finished all pixel reading and format conversion upon its return. This is why asynchronous pixel transfer is so important for reading operations. It allows OpenGL to not do that, to not synchronize with the GPU.

唯一的例外是每一个单词指针结尾的功能。比如像 glVertexAttribPointer glTexCoordPointer ,等等。当您使用这些功能(在核心配置文件的OpenGL 3.2+不再合法)客户端内存中,这些功能存储一个指针,它指向的内存。因此,必须确保该指针是有效的,只要你打算与那些顶点属性来呈现。

The only exception to this rule is every function that ends in the word "Pointer". Things like glVertexAttribPointer, glTexCoordPointer, and the like. When you use client-side memory with these functions (no longer legal in core profile OpenGL 3.2+), these functions store a pointer to that memory. Therefore, you must ensure that this pointer is valid for as long as you intend to render with those vertex attributes.

使用客户端内存中的每个渲染电话后,OpenGL的要求执行已经完成的时候从客户端内存读取渲染函数返回。所以,你可以调用调用glDrawArrays ,然后有问题删除指针。而且,只要你不把另一绘制调用,直到你已经改变了这些指针,你的罚款。这意味着OpenGL的必须由时间已复制了所有相关的顶点数据渲染调用返回(的原因使用缓冲区对象是一个更快)。

After each rendering call using client-memory, OpenGL requires that the implementation have finished reading from client memory by the time the rendering function returns. So you can call glDrawArrays, then delete the pointers in question. And as long as you don't make another draw call until you've changed those pointers, you're fine. This means OpenGL has to have copied out all relevant vertex data by the time the rendering call returns (one of the reasons why using buffer objects is faster).

这篇关于什么时候的OpenGL拿完在功能指针?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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