Original Post
I am making 2D space shooter and need some help on using D3D. My engine is now able to draw single textures loaded from png files and it creates separate texture for each object. Currently I have class CVisible which is then added to every class which needs to have a texture.
Problem: What kind of structure I should use to get as painlesly as possible multitexturing, animated textures and fast rendering. D3DSprite class is out of question I think, because it lacks in possibilities. Should I load all textures in initialization and then just point each objects LPDIRECT3DTEXTURE9 to right one? Animated textures are created by allocating multiple textures and then rotated between them if I am right? Should I just load them from separate png-files or is there some more clever method (mng?) doing this. Or should one texture contain all the frames and then change the u and v values? Speed is the issue in this code, so how should I make the rendering loop faster:
vidw_Device->Clear( 0, NULL, D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0), 1.0f, 0);
vidw_Device->BeginScene();
SetupCamera();
SetupPerspective(); // I use D3DXMatrixOrthoLH
// RenderBackGround();
// and for each object I call Visible->Render which does the
// following
D3DXMATRIX rotation, translation, transformation;
D3DXMatrixRotationZ(&rotation, parent->GetRotation());
D3DXMatrixTranslation(&translation, pos.x, pos.y, 0);
D3DXMatrixMultiply(&transformation, &rotation,&translation);
device->SetTransform(D3DTS_WORLD, &transformation);
device->SetStreamSource(0, vertexBuffer, 0, sizeof(ge_vertex_t));
device->SetVertexShader(NULL);
device->SetFVF(D3DFVF_CUSTOMVERTEX);
device->SetTexture(0, texture);
device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
vidw_Device->EndScene();
vidw_Device->Present( NULL, NULL, NULL, NULL);