Jump to content
  • Advertisement
Sign in to follow this  
AquaMacker

Using 1 Large VB... Drawing Simple Rectangle

This topic is 2598 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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();

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!