.:Antialias Direct3D NONMASKABLE and MULTISAMPLE_X_SAMPLES:.

A forum to store posts deemed exceptionally wise and useful
Post Reply
Ishtm
Posts: 37
Joined: Mon May 09, 2005 8:03 pm

.:Antialias Direct3D NONMASKABLE and MULTISAMPLE_X_SAMPLES:.

Post by Ishtm »

This code is for enable antialias in D3D9 driver for tow types of video cards,
those that support D3DMULTISAMPLE_X_SAMPLES or D3DMULTISAMPLE_NONMASKABLE like mine... Radeon 9000 IGP.

CVideoDirectX9.cpp after these lines:
D3DDEVTYPE devtype = D3DDEVTYPE_HAL;
#ifdef _IRR_D3D_SHADER_DEBUGGING
devtype = D3DDEVTYPE_REF;
#endif
you put:

Code: Select all

// check antialias capability for multisample_nonmaskable or //multisample_2_samples
DWORD quality;
bool antialias = false;
if( SUCCEEDED(pID3D->CheckDeviceMultiSampleType(            D3DADAPTER_DEFAULT, 
                     devtype , d3ddm.Format, present.Windowed, 
                     D3DMULTISAMPLE_NONMASKABLE, &quality ) ) )
        {       
            present.SwapEffect         = D3DSWAPEFFECT_DISCARD;
            present.MultiSampleType    = D3DMULTISAMPLE_NONMASKABLE;
            present.MultiSampleQuality = quality - 1; //return value star in 0
            antialias = true;
        }
    else if( SUCCEEDED(pID3D->CheckDeviceMultiSampleType( D3DADAPTER_DEFAULT, 
                     devtype , d3ddm.Format, present.Windowed, 
                     D3DMULTISAMPLE_2_SAMPLES, NULL ) ) )//2 can be 4....
        {       
            present.SwapEffect         = D3DSWAPEFFECT_DISCARD;
            present.MultiSampleType    = D3DMULTISAMPLE_2_SAMPLES;
            antialias = true;
        }
    else
        {
            os::Printer::log("Device dont support 2 antialias samples or multisample nonmaskable.", ELL_WARNING);    
        }
..and after
// get caps
pID3DDevice->GetDeviceCaps(&Caps);
we put:

Code: Select all

//enable antialias
if(antialias) 
{ 
   pID3DDevice->SetRenderState( D3DRS_MULTISAMPLEANTIALIAS , TRUE); 
}

I hope that be usefull
Post Reply