Archived

This topic is now archived and is closed to further replies.

D_JildQuantum

Excessive?

Recommended Posts

Just trying to render a scene of 4 pyramids, and i can get it to work, but isnt it a little excessive to have a vertex buffer for every object in the scene? is there some way i can put multiple objects in one vertex buffer? any tutorials that tell me how? Im willing to put in hard work to achieve "Almost" proffesional work... Thank you... p.s.: was gamedev down earlier? Quantum

Share this post


Link to post
Share on other sites
Impacient, aren''t we? Due to the fact of gamedev being down people figured it would be down for a while and didn''t bother checking back.

Anyway, yes, having a vertex buffer for every object is ''excessive'' (its inefficient). How you actually batch objects together into one vertex buffer is up to you though.

Share this post


Link to post
Share on other sites
You can easily put different objects into the same vertex buffer. Especially with static objects where you dont have to lock the buffer every frame if you put them into the same buffer then when rendering static objects if batched correctly you only have on vertex buffer switch for all the static objects. Although depending on how many static objects you have, you might want to

To do this all you would have to do is create a buffer big enough, then lock it and just fill it with objects end to end.

Of course you would need to store an object''s starting index in the buffer, render method, and how many vertexs it has outside the buffer in per object.

Share this post


Link to post
Share on other sites
My problem is, how do i write them end to end? something like this:

BYTE* pVerticeLock=0;
g_hr=g_pQuantumVertexBuffer->Lock(0, sizeof(CQVQuad), &pVerticeLock, 0);
if(FAILED(g_hr))
return false;
//Quad

CopyMemory(pVerticeLock, &CQVQuad, sizeof(CQVQuad));
//Triangle

CopyMemory(pVerticeLock, &CQVTriangle, sizeof(CQVTriangle));
//Terrain

CopyMemory(pVerticeLock, &CQVTerrain, sizeof(CQVTerrain));
//SkyBoxEast

CopyMemory(pVerticeLock, &CQVSkyBoxEast, sizeof(CQVSkyBoxEast));

wont work, because it keeps over riding it...

Quantum

Share this post


Link to post
Share on other sites
...umm Im going to help explain this but afterwards I suggest you do some homework on pointers and pointer math.

//Quad
CopyMemory(pVerticeLock, &CQVQuad, sizeof(CQVQuad));
pVerticeLock+=sizeof(CQVQuad);

//Triangle
CopyMemory(pVerticeLock, &CQVTriangle, sizeof(CQVTriangle));
pVerticeLock+=sizeof(CQVTriangle);

//Terrain
CopyMemory(pVerticeLock, &CQVTerrain, sizeof(CQVTerrain));
pVerticeLock+=sizeof(CQVTerrain);

//SkyBoxEast
CopyMemory(pVerticeLock, &CQVSkyBoxEast, sizeof(CQVSkyBoxEast));

Share this post


Link to post
Share on other sites
Thats fine, I taught myself vb and I know what its like to try to teach yourself something. Just pointers are very vital to a lot of game programming so I thought Id try and point you in the right direction... as apposed to your general thought of what people here think of you, most of us dont mind helping but sometimes people just seem to get over their head before they fully cover the basics.

Share this post


Link to post
Share on other sites