为什么纹理模糊?我需要它保持源图像的相同分辨率

时间:2014-08-18 08:14:44

标签: textures direct3d

源图像为1920x1200像素。

这是我的渲染功能:

VOID Render()
{
    // Clear the backbuffer and the zbuffer
    g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
                     D3DCOLOR_XRGB( 0, 0, 255 ), 1.0f, 0 );

    // Begin the scene
    if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
    {

        g_pd3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER);
        g_pd3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER);
        g_pd3dDevice->SetSamplerState(0, D3DSAMP_BORDERCOLOR, 0x000000ff);
        g_pd3dDevice->SetTexture( 0, g_pTexture );

        // Render the vertex buffer contents
        g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof( CUSTOMVERTEX ) );
        g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
        g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 2);//2 * 50 - 2 );

        // End the scene
        g_pd3dDevice->EndScene();
    }

    // Present the backbuffer contents to the display
    // show in two window
    g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
    HWND hWnd = WindowFromDC(g_hDc);
    RECT rc; rc.bottom = 600, rc.left = 100, rc.right = 600, rc.top = 100;
    //RECT rc; rc.bottom = in->height, rc.left = 0, rc.right = in->width, rc.top = 0;
    g_pd3dDevice->Present( NULL, &rc, hWnd, NULL );
}

将在这里看到的内容: http://uploads.gamedev.net/monthly_08_2014/post-222996-0-85945200-1408348655.jpg

为什么程序显示的图像看起来如此模糊?如何设置纹理看起来更好。源图像为1920x1200像素!

1 个答案:

答案 0 :(得分:0)

当您调整窗口大小时,也许您的后备缓冲区没有调整大小?

如果您处理用于调整窗口大小的Windows消息,请确保将d3d属性的高度和宽度设置更改为新设置,然后重置设备。

在我的一个旧的directx程序中,我的msgProc函数处理windows消息,使用md3dPP作为我的d3d属性,

 case WM_SIZE:
    if( gd3dDevice )
    {
    mbTimeReset = true;
    md3dPP.BackBufferWidth = LOWORD(lParam);
    md3dPP.BackBufferHeight = HIWORD(lParam);

当用户完成调整大小时,它应该发送WM_EXITSIZEMOVE消息。然后,重置您的设备(我的设备名为gd3dDevice)

    gd3dDevice->Reset(&md3dPP);

多年来没有做过多的图形编程,那就是DX9,所以可能是错误的/生锈的。

希望这有助于:)