Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualReflexus

Posted 17 May 2013 - 04:27 PM

it's not working as expected:

 

I'll assume you don't know how to describe the problem. No, errors, it just looks funny, right?


1. The first issue I see is, to account for every line-segment you batch, make sure you do something like this (notice *lineNum):

device->DrawIndexedPrimitiveUP( D3DPT_TRIANGLELIST, 0, 4*lineNum, 2*lineNum, indexBuffer, D3DFMT_INDEX32, vrts, sizeof( TVertex ) );

 

Or you can increment a variable to use for the arguments, just as you probably do with 'vrts'.

 

2. Why are you making an allocation for the buffer? The following code you have written is unnecessary and bad: DWORD* index = new DWORD[indicesCount];

 

The Lock() function will modify your pointer to point somewhere used in the write-combining process. Not only is this memory allocation unnecessary, but you're creating a memory leak.

3. How do you determine "indicesCount" ?
4. My suggestions:

Construct your index layer in explicit terms of line segments. e.g.

 

uint i = 0;
uint vI = 0;
for (uint lineI = 0; lineI != lineQ; ++lineI)
{
	index[i++] = vI;
	index[i++] = vI + 2;
	index[i++] = vI + 1;
	index[i++] = vI + 1;
	index[i++] = vI + 2;
	index[i++] = vI + 3;
	vI += 4;
}

 

indicesCount can be determined just like this: lineQ * 6;

Notation info: I have a personal habit of appending a capital letter i to denote an index and Q to denote a quantity.

Hopefully these tips get you somewhere. biggrin.png


#2Reflexus

Posted 17 May 2013 - 04:25 PM

it's not working as expected:

 

I'll assume you don't know how to describe the problem. No, errors, it just looks funny, right?


1. The first issue I see is, to account for every line-segment you batch, make sure you do something like this (notice *lineNum):

device->DrawIndexedPrimitiveUP( D3DPT_TRIANGLELIST, 0, 4*lineNum, 2*lineNum, indexBuffer, D3DFMT_INDEX32, vrts, sizeof( TVertex ) );

 

Or you can increment a variable to use for the arguments, just as you probably do with 'vrts'.

 

2. Why are you allocating for the buffer? The following code you have written is unecessary: DWORD* index = new DWORD[indicesCount];

 

The Lock() function will modify your pointer to point somewhere used in the write-combining process. Not only is this memory allocation unnecessary, but you're creating a memory leak.

3. How do you determine "indicesCount" ?
4. My suggestions:

Construct your index layer explicitly by line segments. e.g.

 

uint i = 0;
uint vI = 0;
for (uint lineI = 0; lineI != lineQ; ++lineI)
{
	index[i++] = vI;
	index[i++] = vI + 2;
	index[i++] = vI + 1;
	index[i++] = vI + 1;
	index[i++] = vI + 2;
	index[i++] = vI + 3;
	vI += 4;
}

indicesCount can be determined just like this: lineQ * 6;

Notation: I have a personal habit of appending a capital letter i to denote an index and Q to denote a quantity.

Hopefully these tips get you somewhere. biggrin.png


#1Reflexus

Posted 17 May 2013 - 04:24 PM

it's not working as expected:

 

I'll assume you don't know how to describe the problem. No, errors, it just looks funny, right?


1. The first issue I see is, to account for every line-segment you batch, make sure you do something like this (notice *lineNum):

device->DrawIndexedPrimitiveUP( D3DPT_TRIANGLELIST, 0, 4*lineNum, 2*lineNum, indexBuffer, D3DFMT_INDEX32, vrts, sizeof( TVertex ) );

 

Or you can increment a variable to use for the arguments, just as you probably do with 'vrts'.

 

2. Why are you allocating for the buffer? This is unecessary: DWORD* index = new DWORD[indicesCount]; The Lock() function will modify your pointer to point somewhere used in the write-combining process. Not only is this memory allocation unnecessary, but you're creating a memory leak.

3. How do you determine "indicesCount" ?
4. My suggestions:

Construct your index layer explicitly by line segments. e.g.

 

uint i = 0;
uint vI = 0;
for (uint lineI = 0; lineI != lineQ; ++lineI)
{
	index[i++] = vI;
	index[i++] = vI + 2;
	index[i++] = vI + 1;
	index[i++] = vI + 1;
	index[i++] = vI + 2;
	index[i++] = vI + 3;
	vI += 4;
}

indicesCount can be determined just like this: lineQ * 6;

Notation: I have a personal habit of appending a capital letter i to denote an index and Q to denote a quantity.

Hopefully these tips get you somewhere. :D


PARTNERS