glGen * vs glCreate *命名约定 [英] glGen* vs glCreate* naming convention

查看:223
本文介绍了glGen * vs glCreate *命名约定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我浏览了OpenGL标准,以寻求对此的解释...为什么某些对象(着色器对象)使用以前缀 glCreate 开头的函数,而某些对象(缓冲对象)使用函数以前缀 glGen 开头?有语义上的原因吗?

I've browsed the OpenGL standards looking for an explanation for this... why do some objects (shader objects) use functions starting with the prefix glCreate and some objects (buffer objects) use function starting with the prefix glGen? Is there a semantic reason for this?

推荐答案

glGen…函数可追溯到OpenGL-1.1(glGenTextures),用于创建对象名称,而无需实际初始化对象.但是,大多数情况下,这些功能一次只能创建一个对象名称.因此,不必将指针传递给缓冲区和缓冲区的大小,而是在大多数情况下只返回一个整数即可.

The glGen… functions go back to OpenGL-1.1 (glGenTextures) and are used to create object names without actually initializing the object. However most of the time those functions are used to create only one object name at a time. So instead of passing them a pointer to a buffer and the size of the buffer you could most of the time just return a single integer.

3Dlabs引入GLSL时,他们试图打破旧的glGen…约定来现代化OpenGL API.

When 3Dlabs introduced GLSL they tried to break with the old glGen… convention to modernize the OpenGL API.

是的,这有点无关紧要,坦率地说,我更喜欢GLSL API使用glGen…命名约定.但是我们只能使用glCreateShaderglCreateProgram.

Yes, this is a bit inconsequential and frankly I'd prefer the GLSL API to use the glGen… naming convention. But we're stuck with glCreateShader and glCreateProgram and that's it.

如果您要使用一个命名约定,则可以编写以下包装:

If you want to have a single naming convention you may write the following wrappers:

GLuint glCreateTexture(void) { GLuint name; glGenTextures(1, &name); return name; }
GLuint glCreateBuffer(void) { GLuint name; glGenTextures(1, &name); return name; }
...

这篇关于glGen * vs glCreate *命名约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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