Click here to Skip to main content
15,887,341 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Passing an array as argument to a function Pin
Greg Utas30-Mar-20 4:11
professionalGreg Utas30-Mar-20 4:11 
GeneralRe: Passing an array as argument to a function Pin
Richard MacCutchan30-Mar-20 4:24
mveRichard MacCutchan30-Mar-20 4:24 
GeneralRe: Passing an array as argument to a function Pin
k505430-Mar-20 4:58
mvek505430-Mar-20 4:58 
GeneralRe: Passing an array as argument to a function Pin
k505429-Mar-20 7:52
mvek505429-Mar-20 7:52 
GeneralRe: Passing an array as argument to a function Pin
Calin Negru29-Mar-20 8:11
Calin Negru29-Mar-20 8:11 
GeneralRe: Passing an array as argument to a function Pin
k505429-Mar-20 9:42
mvek505429-Mar-20 9:42 
GeneralRe: Passing an array as argument to a function Pin
Calin Negru30-Mar-20 22:30
Calin Negru30-Mar-20 22:30 
GeneralRe: Passing an array as argument to a function Pin
Calin Negru31-Mar-20 21:36
Calin Negru31-Mar-20 21:36 
This array of pointers thing is above trivial. Here is my old code:
CUSTOMVERTEX* ScreenLetters;
	ScreenTextBuffers[0]->Lock( 0, 0, (void**)&ScreenLetters, 0 );
	 int LetterVertexDataincrement = 0;
	 int letterwidth = 12;
	 int letterheight = 12;
	 
	 for(int ii = 0; ii < ScreenLetterGroups[0].height;ii++)
	 {
		 for(int i = 0; i < ScreenLetterGroups[0].width;i++)
		{
			//. .
		    //_ .
			ScreenLetters[LetterVertexDataincrement].position.x = i * letterwidth + ScreenLetterGroups[0].x;
			ScreenLetters[LetterVertexDataincrement].position.y = ii * letterheight + ScreenLetterGroups[0].y;
		 ScreenLetters[LetterVertexDataincrement].position.z = 20;
		 ScreenLetters[LetterVertexDataincrement].color = 0xffffffff;
// ... filling the array ...

}
}

ScreenTextBuffers[0]->Unlock();


I have this piece of code repeating for every ScreenTextBuffers element. I want to place it in a `for` loop so what I`m doing is:
CUSTOMVERTEX ** ScreenLettersP_s = new CUSTOMVERTEX* [NumberOfTextBuffers];
	 int LetterVertexDataincrement = 0;
	 int letterwidth = 12;
	 int letterheight = 12;
	for(int iii =0; iii < NumberOfTextBuffers; iii++)
	{
		ScreenTextBuffers[iii]->Lock( 0, 0, (void**)&ScreenLettersP_s[iii], 0 );
		
	 
	 for(int ii = 0; ii < ScreenLetterGroups[iii].height;ii++)
	 {
		 for(int i = 0; i < ScreenLetterGroups[iii].width;i++)
		{
			//. .
		    //_ .

		 *ScreenLettersP_s[LetterVertexDataincrement]->position.x = i * letterwidth + ScreenLetterGroups[iii].x; // `illegal indirection`
		 *ScreenLettersP_s[LetterVertexDataincrement]->position.y = ii * letterheight + ScreenLetterGroups[iii].y;
		 *ScreenLettersP_s[LetterVertexDataincrement]->position.z = 20;
		 *ScreenLettersP_s[LetterVertexDataincrement]->color = 0xffffffff;

// ... filling the array ...

}
}
 ScreenTextBuffers[i]->Unlock();
}

but it doesn`t compile, I`m getting an `illegal indirection` error

struct CUSTOMVERTEX
{
    D3DXVECTOR3 position; // The position
    D3DCOLOR    color;    // The color
    FLOAT       tu, tv;   // The texture coordinates
};


modified 1-Apr-20 6:03am.

GeneralRe: Passing an array as argument to a function Pin
Richard MacCutchan31-Mar-20 23:02
mveRichard MacCutchan31-Mar-20 23:02 
GeneralRe: Passing an array as argument to a function Pin
Calin Negru31-Mar-20 23:26
Calin Negru31-Mar-20 23:26 
GeneralRe: Passing an array as argument to a function Pin
Richard MacCutchan1-Apr-20 0:36
mveRichard MacCutchan1-Apr-20 0:36 
GeneralRe: Passing an array as argument to a function Pin
Calin Negru1-Apr-20 1:12
Calin Negru1-Apr-20 1:12 
GeneralRe: Passing an array as argument to a function Pin
Richard MacCutchan1-Apr-20 1:26
mveRichard MacCutchan1-Apr-20 1:26 
GeneralRe: Passing an array as argument to a function Pin
Calin Negru1-Apr-20 1:49
Calin Negru1-Apr-20 1:49 
GeneralRe: Passing an array as argument to a function Pin
Richard MacCutchan1-Apr-20 2:45
mveRichard MacCutchan1-Apr-20 2:45 
GeneralRe: Passing an array as argument to a function Pin
Calin Negru1-Apr-20 5:19
Calin Negru1-Apr-20 5:19 
GeneralRe: Passing an array as argument to a function Pin
Richard MacCutchan1-Apr-20 6:39
mveRichard MacCutchan1-Apr-20 6:39 
GeneralRe: Passing an array as argument to a function Pin
Calin Negru31-Mar-20 4:42
Calin Negru31-Mar-20 4:42 
GeneralRe: Passing an array as argument to a function Pin
Richard MacCutchan31-Mar-20 4:58
mveRichard MacCutchan31-Mar-20 4:58 
GeneralRe: Passing an array as argument to a function Pin
Calin Negru31-Mar-20 5:28
Calin Negru31-Mar-20 5:28 
AnswerRe: Passing an array as argument to a function Pin
Stefan_Lang30-Mar-20 23:18
Stefan_Lang30-Mar-20 23:18 
GeneralRe: Passing an array as argument to a function Pin
Calin Negru31-Mar-20 0:02
Calin Negru31-Mar-20 0:02 
AnswerRe: Passing an array as argument to a function Pin
Calin Negru11-Apr-20 5:13
Calin Negru11-Apr-20 5:13 
GeneralRe: Passing an array as argument to a function Pin
kalberts11-Apr-20 8:19
kalberts11-Apr-20 8:19 
QuestionError in BSTR TagVariant After project Migration from VS2010 to VS2017 Pin
Member 1326109427-Mar-20 2:19
Member 1326109427-Mar-20 2:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.