   directx/win32 types confusion
  why does this work in directx2 lines I don't get    1)   WORD *indicie; //why don't you need to declare NEW keyword for array?VOID *pIndicie=0;g_pIB->Lock(0,0,(void**)&indicie,0);//frontindicie[0]=0;indicie[1]=1;indicie[2]=2;//l sideindicie[3]=3;indicie[4]=0;indicie[5]=2;g_pIB->Lock(0,0,(void**)&indicie,0);   2)//memcpy(pIndicie,indicie,sizeof(indicie));  why can't this work (without comment) and the indicie[] outside the lock commands?g_pIB->Unlock();   
Quote:Original post by jagguywhy does this work in directx2 lines I don't get    1)   WORD *indicie; //why don't you need to declare NEW keyword for array?VOID *pIndicie=0;g_pIB->Lock(0,0,(void**)&indicie,0); //frontindicie[0]=0;indicie[1]=1;indicie[2]=2;//l sideindicie[3]=3;indicie[4]=0;indicie[5]=2; g_pIB->Lock(0,0,(void**)&indicie,0);    2)//memcpy(pIndicie,indicie,sizeof(indicie));  why can't this work (without comment) and the indicie[] outside the lock commands? g_pIB->Unlock();1) Because D3D gives you the pointer back. Essentially, you can think of it doing the allocation for you, and Unlock() will free that memory (It's a bit different, but that's a reasonable enough analogy). That's why you pass (void**)&indicie instead of (void*)indicie2)Because sizeof(indicie) is 4, because indicie is a pointer. Using memcpy(pIndicie,indicie,sizeof(WORD)*6); should work as expected.Slightly offtopic: It's index, not indicie [smile]EDIT: I just noticed you're locking the IB twice, which you shouldn't be doing (You don't need to). Also, you pass indicie to the Lock() call, when you should be passing pIndicie in your code (D3D will modify the pointer to point at the locked data)   