Sign in to follow this  

Index&Vertex Buffers, need advice!

This topic is 4108 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

Hello! I have a problem with using Idex buffer with Vertex one. U can see that my compiled results are very strange: http://childrenofvoid.ho.com.ua/GAME/prev_LINELIST.jpg http://childrenofvoid.ho.com.ua/GAME/prev_TRIANGLELIST.jpg Maybe im using iBuffer wrong? I really need help with this. Plz give me an advice what i do wrong! *I have 4 cells, 2 in each row. 9 verts and 6 per ech cell of index values = 24.
[INDEX DUMP] [24]
0,1,3,3,1,4,
1,2,4,4,2,5,
3,4,6,6,4,7,
4,5,7,7,5,8,
[END]

[MAP DUMP] [9]
0: -2.5,0,2.5
1: 0,0,2.5
2: 2.5,0,2.5
3: -2.5,0,0
4: 0,0,0
5: 2.5,0,0
6: -2.5,0,-2.5
7: 0,0,-2.5
8: 2.5,0,-2.5
[END]


Share this post


Link to post
Share on other sites
Your coordinates and indices seem okay, so check other things, like whether the buffers you allocate are of the correct size and what parameters you provide for rendering.

Share this post


Link to post
Share on other sites
Quote:
Original post by ET3D
Your coordinates and indices seem okay, so check other things, like whether the buffers you allocate are of the correct size and what parameters you provide for rendering.


Yea, i cant understand where i should search the problem!
Theese are usual functions:

void _Ter::CreateIndexBuffer()
{
if(FAILED(pDD->CreateIndexBuffer( this->indexcount * sizeof(int) * pHg->verttotal,
0, D3DFMT_INDEX16, D3DPOOL_DEFAULT,&pIB, NULL))) pDBG->PutMessage("index buf failed");
//Блокируем
VOID* pBI;
if(FAILED(pIB->Lock( 0, 0, (void**)&pBI, 0 ))) pDBG->PutMessage("index locking failed");
//Копируем
memcpy( pBI, index, this->indexcount * sizeof(int) );
// Разблокируем
pIB->Unlock();

}




void _Ter::CreateVertexBuffer()
{
//Создание буфера вершин
if(FAILED(pDD->CreateVertexBuffer(sizeof(vertex)*pHg->verttotal,D3DUSAGE_DYNAMIC,D3DFVF_VERTEX,D3DPOOL_DEFAULT,&pVB,NULL)))
pDBG->PutMessage("Vertex Buffer creation failed");;
void* pBV = NULL;
if(FAILED(pVB->Lock(0,0,(void**)&pBV,0))) pDBG->PutMessage("Failed vertex locking");
memcpy(pBV,this->ter,sizeof(vertex)*pHg->verttotal);
pVB->Unlock();
}



Every forum says "Yea boy, buffers are correct!". But what the hell???

Share this post


Link to post
Share on other sites
if(FAILED(pDD->CreateIndexBuffer( this->indexcount * sizeof(int) * pHg->verttotal, 0, D3DFMT_INDEX16, D3DPOOL_DEFAULT,&pIB, NULL))) pDBG->PutMessage("index buf failed");


sizeof(int) != D3DFMT_INDEX16

sizeof(short) == D3DFMT_INDEX16
sizeof(int) == D3DFMT_INDEX32


:)

Share this post


Link to post
Share on other sites
Quote:
Original post by bit64
if(FAILED(pDD->CreateIndexBuffer( this->indexcount * sizeof(int) * pHg->verttotal, 0, D3DFMT_INDEX16, D3DPOOL_DEFAULT,&pIB, NULL))) pDBG->PutMessage("index buf failed");


sizeof(int) != D3DFMT_INDEX16

sizeof(short) == D3DFMT_INDEX16
sizeof(int) == D3DFMT_INDEX32


:)


You cant even imagine what u just did!!! Its works fine with D3DFMT_INDEX32!!!
Thanx man! Im appreciate

Share this post


Link to post
Share on other sites

This topic is 4108 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.

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