Using 1 Large VB... Drawing Simple Rectangle

Started by
1 comment, last by AquaMacker 12 years, 11 months ago
[font="Verdana"]
Hi ^^a

I'm sorry. I can't English very well.
Please understand me.

I'm using 1 static Large VB...
I'm drawing a simple rectangle with moving start vertexbuffer offset.

Let's see code ^^a (English too difficult ??)


stVertexTex1* v = NULL;
pMesh->LockVertexBuffer( 0, (void**)&v );
v[0] = stVertexTex1( -2.0f, -0.5f, 0.0f, 0.0f, 1.0f );
v[1] = stVertexTex1( -2.0f, 0.5f, 0.0f, 0.0f, 0.0f );
v[2] = stVertexTex1( 2.0f, 0.5f, 0.0f, 1.0f, 0.0f );
v[3] = stVertexTex1( 2.0f, -0.5f, 0.0f, 0.0f, 1.0f );
pMesh->UnlockVertexBuffer();

stVertexTex1* vertices;
stVertexTex1* verticesNew;
pMesh->LockVertexBuffer( D3DLOCK_READONLY, (void**)&vertices );
vb->Lock( 0 <- start vertexbuffer offset 0. I want to moving 10
, 4 * sizeof(stVertexTex1)
, (void**)&verticesNew
, D3DLOCK_NOSYSLOCK );
::CopyMemory( verticesNew, vertices, 4 * sizeof(stVertexTex1) );
vb->Unlock();
pMesh->UnlockVertexBuffer();

Drawing code...

Device->SetVertexDeclaration( pDeclFont );
Device->SetStreamSource( 0
, vb
, 0 --> 10 Changing ???
, sizeof(stVertexTex1) );
Device->SetIndices( ibFont );

pEffect->Begin( NULL, NULL );
pEffect->BeginPass(2);
pEffect->CommitChanges();
Device->DrawIndexedPrimitive( D3DPT_TRIANGLELIST
, 0
, 0
, 4
, 0
, 2 );


Code + English...

If ( VB start offset moving )
{
vb->Lock( 0 -----> vb->Lock( 10
}

Then Drawing Code is Change ?

{
Device->SetStreamSource( 0, vb , 0, sizeof(stVertexTex1) ) -------> Drawing very well
----->
Device->SetStreamSource( 0, vb , 10, sizeof(stVertexTex1) ) -----> Can't Drawing ??
}

Using Start VB Offset moving Drawing...
X-files( Tiny, Dwarf etc...) are Drawing Very well.
BUT
This Simple rectalge ONLY can't drawing ??[/font]
Advertisement
Hey there don't worry about the english... Your not actually copying the data into the vertex buffer
stVertexTex1* v = NULL;
v[0] = stVertexTex1( -2.0f, -0.5f, 0.0f, 0.0f, 1.0f );
v[1] = stVertexTex1( -2.0f, 0.5f, 0.0f, 0.0f, 0.0f );
v[2] = stVertexTex1( 2.0f, 0.5f, 0.0f, 1.0f, 0.0f );
v[3] = stVertexTex1( 2.0f, -0.5f, 0.0f, 0.0f, 1.0f );
void* pData;
pMesh->LockVertexBuffer( 0, (void**)&pData );
memcpy(pData, stVertexTex1, sizeof(v));
pMesh->UnlockVertexBuffer();

Hey there don't worry about the english... Your not actually copying the data into the vertex buffer
stVertexTex1* v = NULL;
v[0] = stVertexTex1( -2.0f, -0.5f, 0.0f, 0.0f, 1.0f );
v[1] = stVertexTex1( -2.0f, 0.5f, 0.0f, 0.0f, 0.0f );
v[2] = stVertexTex1( 2.0f, 0.5f, 0.0f, 1.0f, 0.0f );
v[3] = stVertexTex1( 2.0f, -0.5f, 0.0f, 0.0f, 1.0f );
void* pData;
pMesh->LockVertexBuffer( 0, (void**)&pData );
memcpy(pData, stVertexTex1, sizeof(v));
pMesh->UnlockVertexBuffer();



[font="Verdana"]First of All, Thanks your answer.[/font]
[font="Verdana"]I check that after your answer read.[/font]
[font="Verdana"]But VB is copying actually.[/font]
[font="Verdana"]VB is no problem.[/font]

[font="Verdana"]I check Like this..[/font]
[font="Verdana"]
stVertexTex1* vRead = NULL;
pMesh->LockVertexBuffer( D3DLOCK_READONLY, (void**)&vRead );
for( int i = 0; i < pMesh->GetNumVertices(); i++ )
{
string str = GetString( vRead.x ) + " " + GetString( vRead.y ) + " " + GetString( vRead.z ) + " " + GetString( vRead.tu ) + " " + GetString( vRead.tv );
::MessageBoxA( NULL, str.c_str(), "ObjectManager.cpp", 0 );
}
pMesh->UnlockVertexBuffer();
[/font]

[font="Verdana"]All Vertexs are copyed. ^^a[/font]

[font="Verdana"]Thank for your answer + re-think VB copy actully. ^^a[/font]

This topic is closed to new replies.

Advertisement