# (void**)? pointer to pointer?

This topic is 5447 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi I'm the beginner of using direct x 9.0 well, I've studied pointers pretty hard, but every time I saw some pointers being used by directx, I get confused... such as.. void* pVertices; buffer->Lock(0,0,(void**)&pVertices,0); .. I think pVertices means a pointer to vertices array . am I right? then why the lock function require a pointer to that pointer? Is this related with pointer array? or 2D array pointer? Is there anybody to explain why? and how~? thanks for reading man.. whoa~~! ps. Have you guys played KUF: crusader? this game is Awesome!!

##### Share on other sites
You can interchange the words "pointer" and "array". So a pointer to a pointer is the same as a pointer to an array, or and array of arrays.
Its because pVertices is a pointer, and the value of that pointer (whats its pointing to) needs to be set by the function call. So you pass a pointer to that pointer.
What I do is:
void* pVertices;buffer->Lock(0,0,(void**)&pVertices,0);pVertices->vPos = D3DXVECTOR3(0.0f, 0.0f, 0.0f);pVertices->dwColour = 0xffffffff;pVertices->tu = 0.0f;pVertices->tv = 0.0f;pVertices++;pVertices->vPos = D3DXVECTOR3(1.0f, 0.0f, 0.0f);pVertices->dwColour = 0xffffffff;pVertices->tu = 1.0f;pVertices->tv = 0.0f;pVertices++;// Etc

So you just increment the pointer for each vertex

##### Share on other sites
Thanks a lot for quick answer.Now I can see it;>

##### Share on other sites
Think about it in terms of memory. A pointer is just some place in memory that holds a value. It's value is the address of another spot in memory. So to change the value of the pointer, you have to pass in the address of it. :)

Address    Nomenclature      Value1          Pointer A         102          Pointer B         203          Pointer C         30...10         Value A           1920         Value B           3730         Pointer D         10&(Pointer A) = 1*(Pointer A) = 19  Pointer A  = 10 &(Pointer C) = 3 *(Pointer C) = 10**(Pointer C) = 19   Pointer C  = 30

Chris

##### Share on other sites
Quote:
 Original post by Evil SteveYou can interchange the words "pointer" and "array". So a pointer to a pointer is the same as a pointer to an array, or and array of arrays.

Keep in mind, however, that a pointer to a pointer isn't always a pointer to an array. It could simply be a pointer to another pointer. If you want to get technical about it, then yes, it could be a pointer to an array of one element. But then again you could dereference any pointer by using array notation: pNotAnArray[0] == *pNotAnArray;

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 18
• 13
• 14
• 43
• 63