Jump to content
  • Advertisement
Sign in to follow this  
sainimu78

Why the texture blurred ? I need it keeps the same resolution of the source image

This topic is 1373 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The source image is 1920x1200 px. 

 

Here is my render funtion:

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
    // shows in two windows
    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 );
}

What will be seen shows in the attach file

 

Why does the image the program displays look so blurred? How to set the texture to look better. The source image is 1920x1200 px !

Edited by sainimu78

Share this post


Link to post
Share on other sites
Advertisement

The image seems more like pixelated than blurred. How is your texture sampler set for drawing?

 

Cheers!

Share this post


Link to post
Share on other sites

Your texture looks pixelated to me rather than blurred. If you want it to look smooth, you should use a texture filtering mode other than point-sampling.

For your simple example, try linear sampling first, just to see the difference:

 

g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);

 

You could also use mipmapping to get even better results...

Share this post


Link to post
Share on other sites

Let's make it simple

Just how should I display the source image on the dx rendering scene, ignoring the displaying size.

 

 

Share this post


Link to post
Share on other sites

Well, it depends greatly on your needs ... since you can have any size of window, you can't expect the image to look the same in all the cases. Maybe you should add the sampler states as hinted earlier and tell us after it if the image looks the way you want it to look and enable mipmaps too if your haven't already.

 

Cheers!

Edited by kauna

Share this post


Link to post
Share on other sites

Well, it depends greatly on your needs ... since you can have any size of window, you can't expect the image to look the same in all the cases. Maybe you should add the sampler states as hinted earlier and tell us after it if the image looks the way you want it to look and enable mipmaps too if your haven't already.

 

Cheers!

 

I need a window displaying a image by using dx.

 

I added. 

these tow lines 

.........
g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
g_pd3dDevice->SetTexture( 0, g_pTexture );
..........

and they make no effects.

The image displaying on the window is blurred or, say, pixelated as before.

 

 

 

 

I don't know how to enable mipmaps, could you?

Share this post


Link to post
Share on other sites

How do you load the texture?

My program is modified from the sample code "texture" in dxsdk_june10.

 

This sample code load a texture using CreateTextureFromFile().

I substituted that function with CreateTexture() that loads a texture from memory

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!