0

所以我在 DirectX 9 中编码,每当我在 2D 世界中放置一个精灵时。精灵图像 p 周围出现了一个白色的“光环”。我正在使用 PNG,精灵背后的背景是透明的。我也尝试过使用粉红色背景。光晕似乎只出现在像素的直线上,但只出现在某些边缘上。任何帮助是极大的赞赏!

m_d3d = Direct3DCreate9(D3D_SDK_VERSION); // create the Direct3D interface

D3DPRESENT_PARAMETERS d3dpp; // create a struct to hold various device information

ZeroMemory(&d3dpp, sizeof(d3dpp)); // clear out the struct for use
d3dpp.Windowed = windowed; // is program fullscreen, not windowed?
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;    // discard old frames
d3dpp.hDeviceWindow = hWnd;    // set the window to be used by Direct3D
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;    // set the back buffer format to 32-bit
d3dpp.BackBufferWidth = screenWidth;    // set the width of the buffer
d3dpp.BackBufferHeight = screenHeight;    // set the height of the buffer
d3dpp.EnableAutoDepthStencil = TRUE;       // automatically run the z-buffer for us
d3dpp.AutoDepthStencilFormat = D3DFMT_D16; // 16-bit pixel format for the z-buffer

// create a device class using this information and the info from the d3dpp stuct
m_d3d->CreateDevice(D3DADAPTER_DEFAULT,
                  D3DDEVTYPE_HAL,
                  hWnd,
                  D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                  &d3dpp,
                  &m_d3ddev);

D3DXCreateSprite(m_d3ddev, &m_d3dspt);    // create the Direct3D Sprite object

LPDIRECT3DTEXTURE9 texture;
D3DXCreateTextureFromFileEx(m_d3ddev, "DC.png", D3DX_DEFAULT, D3DX_DEFAULT,
D3DX_DEFAULT, NULL, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_DEFAULT, 
D3DX_DEFAULT, D3DCOLOR_XRGB(255, 0, 255), NULL, NULL, &texture);

m_d3ddev->BeginScene();

m_d3dspt->Begin(D3DXSPRITE_ALPHABLEND);    // begin sprite drawing with transparency

D3DXVECTOR3 center(0.0f, 0.0f, 0.0f), position((appropriate x), (appropriate y), 1);
m_d3dspt->Draw(texture, NULL, &center, &position, D3DCOLOR_ARGB(255, 255, 255, 255));

m_d3dspt->End();    // end sprite drawing

m_d3ddev->EndScene();

m_d3ddev->Present(NULL, NULL, NULL, NULL);

谢谢彼得

4

1 回答 1

0

当您从 sprite atlasing 搞砸了您的纹理坐标并且您不小心跑出了纹理或进入另一个纹理时,就会发生这种情况。

无论如何,最常见的是AFAIK。

于 2011-06-15T00:52:53.740 回答