Not when your vertices are lower than about 100. If the number is less than 100 then internally Direct3D turns DrawPrimitiveUP into a DrawPrimitive call. In fact gamedev and beyond3d both recommend using DrawPrimitiveUP on batches of less than 100.This is slower than using vertex buffers but maybe it won't be significant for you.
Using DrawPrimitiveUP on small batches is faster than continually locking/unlocking vertex buffers.
Ideally you want to use a huge indexed vertex buffer and simply give your object a certain range of those indices to use - same for textures. Specify a huge texture and index into it with your u,v coords for the correct texture.
This is akin to the old days when they used tiled bitmaps to represent all animation frames and simply indexed into the bitmap to extract the correct image.
Incidentally try this instead of what you are using.
ID3DXSprite is much easier than creating your own class that pretty much does the same thing. I'm changing all the billboarding code and sprite code in both of my games to use ID3DXSprite.Code:class Object2D { ID3DXSprite *m_pSprite; IDirect3DTexture9 *m_pTexture; IDirect3DDevice9 *m_pDevice; D3DXVECTOR3 m_pPos; float m_fScale; public: Object2D(void):m_pSprite(NULL),m_pTexture(NULL),m_pDevice(NULL),m_pPos(D3DXVECTOR3(0.0f,0.0f,0.0f)) {} ~Object2D(void) { SAFE_RELEASE(m_pTexture); SAFE_RELEASE(m_pSprite); } void Create(IDirect3DDevice9 *_device,float _scale,D3DXVECTOR3 _pos,std::string _file) { m_pDevice=_device; m_fScale=_scale; m_pPos=_pos; //Load texture D3DXCreateTextureFromFile(m_pDevice,_file.c_str(),&m_pTexture); //Create Sprite interface D3DXCreateSprite(m_pDevice,&m_pSprite); } void UpdateAndDraw(void) { D3DXMATRIX trans; D3DXMATRIX scale; D3DXMATRIX world; //Translation D3DXMatrixTranslation(&trans,m_pPos.x,m_pPos.y,m_pPos.z); //Scaling D3DXMatrixScaling(&scale,m_fScale,m_fScale,1.0f); //Concatenate world=scale*trans; //Set transform m_pSprite->SetTransform(&world); //Draw sprite m_pSprite->Begin(D3DXSPRITE_ALPHABLEND); m_pSprite->Draw(Texture,NULL,NULL,NULL,0xFFFFFFFF); m_pSprite->End(); } };



LinkBack URL
About LinkBacks



