开发者

DirectX: Antialiasing doesn´t work

开发者 https://www.devze.com 2023-03-02 02:33 出处:网络
I just want to enable Antialiasing in DirectX9, but it doesn´t seem to do much, and the text drawn with ID3DXFont.DrawText(...) looks jagged too.

I just want to enable Antialiasing in DirectX9, but it doesn´t seem to do much, and the text drawn with ID3DXFont.DrawText(...) looks jagged too.

Here is the initialization-part

pDirect3D = Direct3DCreate9( D3D_SDK_VERSION);
memset(&presentParameters, 0, sizeof(_D3DPRESENT_PARAMETERS_));
presentParameters.BackBufferCount = 1;
presentParameters.BackBufferWidth = 800;
presentParameters.BackBufferHeight = 500;

presentParameters.MultiSampleType = D3DMULTISAMPLE_NONMASKABLE;
开发者_如何转开发presentParameters.MultiSampleQuality = 2;

presentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
presentParameters.hDeviceWindow = hWnd;
presentParameters.Flags = 0;
presentParameters.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
presentParameters.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
presentParameters.BackBufferFormat = D3DFMT_R5G6B5;
presentParameters.EnableAutoDepthStencil = TRUE;
presentParameters.AutoDepthStencilFormat = D3DFMT_D16;
presentParameters.Windowed = TRUE;
pDirect3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING, &presentParameters, &pDevice);
pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);

pDevice->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, TRUE);

Is there something I do wrong?

ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);


First, text isn't anti-aliased by mutli-sampling, secondly a MultiSampleQuality of 2 is barely noticeable. Try a 4 or 8 ensure that the result is achieved, try toggling and watch the jagged edges.

You should checkout the AntiAlias sample provided in the DirectX SDK for details about setting this up properly.


I am creating text with meshes (D3DXCreateTextW), and I notice a significant difference when MultiSampling, even at low quality levels. With any kind of MultiSampling, the text and other lines are smooth, whereas they are jagged without MultiSampling.

Use CheckDeviceMultiSampleType to confirm that your video card does accept the type and level that you are requesting.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号