Skip to main content
gamedev.net
🔒 Locked

Buffer problem

Started by Keba Jan 11, 2005 at 2:28 PM 1 replies 1.2k views
Original Post
Keba
Keba
what if i got this situation: * 2 objects * each object have X vertices and Y indicies * Objects got same material(same textures, and other stuff) * objects got same FVF * objekt 1 got vertices in a range of 0 - 500 and indicies in a range of 0 - 800 * object 2 got vertices in a range of 0 - 200 and indicies in a range of 0 - 500. ... now i going to put this vertices/index data in buffers, i want to render both objects in one DIP, no problem since same FVF and material properties: with a static VB and Dynamic IB: from object 1 | from object 2 VB: [ 0,1,2,3,4.......500,0,1,2,3,4...........200 ] first i put object 1s vertices in the buffer(0 - 500) then i put object 2s vertices in the buffer(0 - 200) now i save the offset(position 501 in VB) of the second 0:vertices so that i can use this offset for the indicies in the second object... so: for(all indicies in second object):c indicies[c] += offset; then i put all the indicies in one indexbuffer. Nice, this should work, right? Now i can render both these object with one DIP call. This could be done when loading the objects from a file or something, once.. but what if i use dynamic vertexbuffers? from object 1 | from object 2 VB first render: [0,1,2,3,4.......500,0,1,2,3,4.......200] from object 2 | from object 1 VB second render: [0,1,2,3,4.......200,0,1,2,3,4.......500] i can't loop through each indices and add a offset each rendering, that would be a real pain.... i want to render these 2 objects in one DIP, is that possible? any tip of a workaround? Using 2 IB wouldn't be a problem, but what about 1 IB? Thanks
nerdboy80
nerdboy80
When filling the VB you need the offset anyway (to tell DX where to lock), so just use that and keep a variable for each object which is that object's offset into the VB, The go ahead a re-fill the IB.
Keba
Keba
yes that would work i do something like this whne filling the ibs:


    for(each object):e    {         for(each indicies in object e):d         {                  IB[currentindex] = Object[e].indicies[d] + Object[e].offset;         }    }


but i got all my indicies and vertices wrapped up in nice datastructures so i do this:

memcpy(pIB,pdata,sizeof(data));

... then i had to itterate thorough all indicies and sett offset and then do the mempcy, not that effecinet.

Topic Locked

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

Sign in to reply to this topic.