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 开发者_如何学PythonSpecifies 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
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);
GLuint is an unsigned int.
You can see it in the header files as:
typedef unsigned int GLuint;
Here's a link the the OpenGL 2 header file
And here's a link for the upcoming OpenGL 3 header file
In case you haven't come across typedeff before, here's the Wiki page explaining typedef
精彩评论