Skip to main content
GameDev.net gamedev.net
🔒 Locked

Index&Vertex Buffers, need advice!

Started by meekman Sep 17, 2006 at 2:50 PM 4 replies 2.1k views
Original Post
meekman
meekman
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]


location: Russia
ET3D
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.
meekman
meekman
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???

location: Russia
bit64
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


:)
Don't be afraid to be yourself. Nobody else ever will be.
meekman
meekman
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

location: Russia
bit64
bit64
Glad I could help. :)
Don't be afraid to be yourself. Nobody else ever will be.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.