Original Post
So I was checking out the nehe tutorials when I noticed this code
glGenTextures( 3, &texture[0] );
I thought, "But, isn't it a pointer already? What's being passed into the function? The address of an address?" So I ran my own tests, making my own types and making pointer arrays.
box *myBoxes[3];
for (int z = 0;z<3;z++) myBoxes[z] = new box;
cout << "myBoxes:\t" << myBoxes << endl;
cout << "*myBoxes:\t" << *myBoxes << endl;
cout << "&myBoxes:\t" << &myBoxes << endl << endl;
cout << "myBoxes[0]:\t" << myBoxes[0] << endl;
/*cout << "myBoxes[0]:\t" << *myBoxes[0] << endl; (realized i couldn't do that lol)*/
cout << "&myBoxes[0]:\t" << &myBoxes[0] << endl << endl;
cout << "myBoxes[1]:\t" << myBoxes[1] << endl;
cout << "&myBoxes[1]:\t" << &myBoxes[1] << endl << endl;
I received this output:
myBoxes: 0012FEC0
*myBoxes: 00322EE0
&myBoxes: 0012FEC0
myBoxes[0]: 00322EE0
&myBoxes[0]: 0012FEC0
myBoxes[1]: 00322F20
&myBoxes[1]: 0012FEC4
I noticed some patterns here such as &myBoxes[0] has the same value as &myBoxes (which is the same as myBoxes), which lead me to find out that I could do glGenTextures( 3, texture ). The problem for me is that I don't totally understand what's going on here? What gets passed into glGenTextures? What IS the value in myBoxes[0]? What IS the value in &myBoxes[0]? Why do they differ? And how come the myBoxes[1] values differ? I am confused! @_@ Educate me, please. (I'm really just on a quest to understand these pointer arrays. I bet there's an obvious explanation for this that I was trying too hard to find.) Thanks very much in advance.
[edited by - andyZER0 on April 14, 2004 3:24:11 PM]
[edited by - andyZER0 on April 14, 2004 3:25:21 PM]
[edited by - andyZER0 on April 14, 2004 3:25:53 PM]