glGenTextures GLuint 还是数组?

发布于 2024-10-17 14:13:54 字数 583 浏览 8 评论 0原文

首先,我对 C/C++ 的了解很少,所以我的知识可能有一个黑点,但我目前正在尝试将 OpenGL 的一些功能移植到 AS3 并查看 OpenGL 的 glGenTextures() 方法

< a href="http://www.opengl.org/sdk/docs/man/xhtml/glGenTextures.xml" rel="nofollow">http://www.opengl.org/sdk/docs/man/xhtml/ glGenTextures.xml

这个方法需要几个,但我的问题是针对后面的参数

GLuint * 纹理

我查找了 GLuint 的类型数据,它似乎是一个 32 位无符号整数,但是文档然后说以下:

textures 指定存储生成的纹理名称的数组。

那么,GLuint 是一个数组还是一个无符号整数??如果这是某种指向数组内存地址的指针(不知道这是否也是可能的?)那么任何人都可以推荐一种等效的实现方法ActionScript 中具有类似的功能,请记住参数是按值计算的,而不是在 ActionScript 中按引用计算的。

非常感谢 SO 上的所有好心人。

加里·帕鲁克

Firstly, I have very little knowledge of C/C++ so there might be a black spot in my knowledge with that but I'm currently attempting to port some of the functionality of OpenGL to AS3 and looking at the glGenTextures() method of OpenGL

http://www.opengl.org/sdk/docs/man/xhtml/glGenTextures.xml

This method takes a couple of but my question is aimed at the later parameter

GLuint * textures

I looked up the type data for GLuint and it appears to be a 32 bit unsigned integer, however the documentation then says the following:

textures Specifies an array in which the generated texture names are stored.

So, is GLuint an array or is it an unsigned integer??, and if this is some kind of pointer to a memory address of an Array (have no idea if that's also a possibilty?) Then can anyone recommend an equivalent way of implementing similar functionality within ActionScript bearing in mind that the parameters are by value and not by reference within ActionScript.

Many thanks to all the good people on SO.

Gary Paluk

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

等风来 2024-10-24 14:13:54

您熟悉指针表示法吗?函数确实接受一个数组:一个 GLuint 数据数组。因此,在创建纹理时,您可以创建一个纹理并简单地指向该 GLuint 的地址,也可以通过传入第一个纹理的指针来创建多个纹理(这基本上就是数组的工作方式)。

GLuint myTexture;
glGenTextures(1, &myTexture); // generate just one texture

GLuint myTextures[32];
glGenTextures(32, myTextures); // generate 32 textures

GLuint myOtherTexture;
GLuint* myTexturePointer = &myOtherTexture;
glGenTextures(1, myTexturePointer); // generate 1 texture using a pointer

GLuint* moreTextures = new GLuint[16];
// generate only 8 textures in the latter half of the array
glGenTextures(8, moreTextures + 8);

Are you familiar with pointer notation? The function does take an array: an array of GLuint data. So, when creating a texture, you can either create one texture and simply point to the address of that one GLuint, or you can create multiple textures by passing in a pointer to the first one (which is basically how arrays work).

GLuint myTexture;
glGenTextures(1, &myTexture); // generate just one texture

GLuint myTextures[32];
glGenTextures(32, myTextures); // generate 32 textures

GLuint myOtherTexture;
GLuint* myTexturePointer = &myOtherTexture;
glGenTextures(1, myTexturePointer); // generate 1 texture using a pointer

GLuint* moreTextures = new GLuint[16];
// generate only 8 textures in the latter half of the array
glGenTextures(8, moreTextures + 8);
小姐丶请自重 2024-10-24 14:13:54

GLuint 是一个无符号整数。

您可以在头文件中看到它:

typedef unsigned int GLuint;

如果您以前没有遇到过 typedeff,这里是解释 typedef 的 Wiki 页面

GLuint is an unsigned int.

You can see it in the header files as:

typedef unsigned int GLuint;

In case you haven't come across typedeff before, here's the Wiki page explaining typedef

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文