Sign in to follow this  
AquaMacker

Using 1 Large VB... Drawing Simple Rectangle

Recommended Posts

AquaMacker    255
[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 ??)

[code]
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]

Code + English...

If ( VB start offset moving )
{
vb->Lock( [b]0[/b] -----> vb->Lock( [b]10[/b]
}

Then Drawing Code is Change ?

{
Device->SetStreamSource( 0, vb , [b]0[/b], sizeof(stVertexTex1) ) -------> Drawing very well
----->
Device->SetStreamSource( 0, vb , [b]10[/b], 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]

Share this post


Link to post
Share on other sites
Six222    453
Hey there don't worry about the english... Your not actually copying the data into the vertex buffer
[code]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();
[/code]

Share this post


Link to post
Share on other sites
AquaMacker    255
[quote name='Six222' timestamp='1307329217' post='4819953']
Hey there don't worry about the english... Your not actually copying the data into the vertex buffer
[code]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();
[/code]
[/quote]

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

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

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this