0

Right now im making a bowling game for school project with visual studio C++ directx 9, the problem is, i tried to load a lot of bowling pins, and its make the game very lag. is there any way to makes the game optimized(not lagging)? Im doing it like this

D3DXMATERIAL* tempMaterials_pin =
    (D3DXMATERIAL*)bufshipMaterial_pin->GetBufferPointer();

materials_pin = new D3DMATERIAL9[numMaterials_pin];

textures_pin = new LPDIRECT3DTEXTURE9[numMaterials_pin];

for (DWORD i = 0; i < numMaterials_pin; i++) {
    materials_pin[i] = tempMaterials_pin[i].MatD3D;
    materials_pin[i].Ambient = D3DXCOLOR(0.7f, 0.7f, 0.7f, 1.0f);
    materials_pin[i].Diffuse = D3DXCOLOR(1.0f, 1.0f, 1.0f, 0.2f);
    if (FAILED(
        D3DXCreateTextureFromFileA(d3ddev, tempMaterials_pin[i].pTextureFilename, &textures_pin[i]))) {
        textures_pin[i] = NULL;
    }
}
for (DWORD i = 0; i < numMaterials_pin; i++) {
            d3ddev->SetMaterial(&materials_pin[i]);
            if (textures_pin[i] != NULL) {
                d3ddev->SetTexture(0, textures_pin[i]);
            }
        }

        D3DXMATRIX matTranslate_pin;
        for (int j = 0; j < 10; j++) {
            D3DXMatrixTranslation(&matTranslate_pin, 0.0f, 0.0f, 0.0f);
            d3ddev->SetTransform(D3DTS_WORLD, &(matTranslate_pin));

            for (DWORD i = 0; i < numMaterials_pin; i++) {
                mesh_pin[j]->DrawSubset(i);
            }
        }

i havent set the coordinates yet since i still trying to load the mesh and its make the game become laggy am i doing this wrong?

0 Answers0