danielleM
December 11th, 2003, 11:35 AM
Below is the code that I want to use in my program.
Basically, it creates a VertexBuffer called
StrokeList[brush_size]->g_pSPLINE_POINTS
Where StrokeList is an array of a structure I created that contains a LPDIRECT3DVERTEXBUFFER9 inside of it.
I need to create a variable amount of VertexBuffers so I thought that this would be a good way to do it (I know that it is incredibly slow, but at the moment, speed is not the biggest concern).
However doing this gives me some wonky results in my input and I was wondering if there was something wrong with my code that I was missing. That is some fundamental idea in regards to VertexBuffers that make this impossible.
Thanks
Danielle
for(int brush_size = BRUSH_NUMBER; brush_size > 2; brush_size--)
{
//Create a new VertexBuffer for each radius of brush stroke to easily render them
if( FAILED( error = D3D_Device->CreateVertexBuffer(StrokeList[brush_size]->totalNumberRectPoints*sizeof(STROKE),
0, D3DFVF_STROKE, D3DPOOL_DEFAULT,
&StrokeList[brush_size]->g_pSPLINE_POINTS, NULL ) ) )
{
assert(error == D3DERR_INVALIDCALL);
return error;
}
//Lock the Vertex Buffer to store the strokes
STROKE* Vertices;
if(FAILED(StrokeList[brush_size]->g_pSPLINE_POINTS->Lock(0, sizeof(STROKE), (void**)&Vertices, 0)))
return false;
Also, please note that when I try to render the code, I change the stream source each time with
D3D_Device->SetStreamSource( 0, StrokeList[Brush_size]->g_pSPLINE_POINTS, 0, sizeof(STROKE) );
Any thoughts, ideas or questions on this would be greatly appriciated :)
Danielle
Basically, it creates a VertexBuffer called
StrokeList[brush_size]->g_pSPLINE_POINTS
Where StrokeList is an array of a structure I created that contains a LPDIRECT3DVERTEXBUFFER9 inside of it.
I need to create a variable amount of VertexBuffers so I thought that this would be a good way to do it (I know that it is incredibly slow, but at the moment, speed is not the biggest concern).
However doing this gives me some wonky results in my input and I was wondering if there was something wrong with my code that I was missing. That is some fundamental idea in regards to VertexBuffers that make this impossible.
Thanks
Danielle
for(int brush_size = BRUSH_NUMBER; brush_size > 2; brush_size--)
{
//Create a new VertexBuffer for each radius of brush stroke to easily render them
if( FAILED( error = D3D_Device->CreateVertexBuffer(StrokeList[brush_size]->totalNumberRectPoints*sizeof(STROKE),
0, D3DFVF_STROKE, D3DPOOL_DEFAULT,
&StrokeList[brush_size]->g_pSPLINE_POINTS, NULL ) ) )
{
assert(error == D3DERR_INVALIDCALL);
return error;
}
//Lock the Vertex Buffer to store the strokes
STROKE* Vertices;
if(FAILED(StrokeList[brush_size]->g_pSPLINE_POINTS->Lock(0, sizeof(STROKE), (void**)&Vertices, 0)))
return false;
Also, please note that when I try to render the code, I change the stream source each time with
D3D_Device->SetStreamSource( 0, StrokeList[Brush_size]->g_pSPLINE_POINTS, 0, sizeof(STROKE) );
Any thoughts, ideas or questions on this would be greatly appriciated :)
Danielle