Skip to main content
GameDev.net gamedev.net
🔒 Locked

Blurry Textures

Started by suckxez Jan 17, 2007 at 9:17 AM 5 replies 700+ views
Original Post
suckxez
suckxez
Hi! I wonder why my textures are that extremely blurry even when the cam isn't that far away from them. Take a look at it: http://home.arcor.de/suckxez/blurry.jpg I use these settings: float aspect = (float)800 / (float)600; D3DXMatrixPerspectiveFovLH( &projection, D3DX_PI / 4, aspect, 1.0f, 1000.0f ); AutoDepthStencilFormat = D3DFMT_D24S8 Another question: What's to do when you have a sprite which dimensions have not the power of 2? For example: I've got a 200x400 sprite, do I have to use a 400x400 texture? :/
suckxez
suckxez
yes, the textures are a power of 2 size

I'm drawing them like that:


if( FAILED(D3DXCreateTextureFromFileEx(Woah_System::GetInterface()->m_pGraphics.GetDevice(), filename, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT,
0, D3DFMT_A4R4G4B4, D3DPOOL_MANAGED, D3DX_FILTER_TRIANGLE | D3DX_FILTER_MIRROR, D3DX_FILTER_TRIANGLE | D3DX_FILTER_MIRROR,
0xff000000, NULL, NULL, &pTexture)))
exit(1);

float w = width;
float h = height;

TVertex v[] =
{ //x y z color r g b u v
{-1.0f, 0.0f, fZPos, D3DCOLOR_XRGB( 255, 255, 255 ), 0.0f, 0.0f},// 0
{0.0f, 0.0f, fZPos, D3DCOLOR_XRGB( 255, 255, 255 ), 1.0f, 0.0f},// 1
{ -1.0f, -1.0f, fZPos, D3DCOLOR_XRGB( 255, 255, 255 ), 0.0f, 1.0f},// 2
{ 0.0f, -1.0f, fZPos, D3DCOLOR_XRGB( 255, 255, 255 ), 1.0f, 1.0f}// 3
};

USHORT g_Indices[] = { 0, 1, 2, 1, 3, 2 };

pVertexBuf.CreateBuffer(Woah_System::GetInterface()->m_pGraphics.GetDevice(), 4, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1, sizeof( TVertex ), 0 );
pVertexBuf.SetData( 4, v , 0);
pIndexBuf.CreateBuffer( Woah_System::GetInterface()->m_pGraphics.GetDevice(), 6, D3DFMT_INDEX16 );
pIndexBuf.SetData( 6, g_Indices, 0);
pVertexBuf.SetIndexBuffer( &pIndexBuf );

/* D3DXMATRIX identity;
D3DXMatrixIdentity( &identity );
Woah_System::GetInterface()->m_pGraphics.GetDevice()->SetTransform( D3DTS_WORLD, &identity );
Woah_System::GetInterface()->m_pGraphics.GetDevice()->SetTransform( D3DTS_VIEW, &identity );
*/

}

void Woah_Sprite::Render(float xpos, float ypos, float zpos, double angle)
{
Woah_System::GetInterface()->m_pGraphics.GetDevice()->SetTexture(0, pTexture);
//D3DXMatrixRotationYawPitchRoll( &m_matRotate, 0, 0, angle);
D3DXMatrixTranslation( &m_matTranslate, xpos, ypos, zpos );
D3DXMatrixRotationZ( &m_matRotate, angle); //degree *(D3DX_PI/180)
Woah_System::GetInterface()->m_pGraphics.GetDevice()->SetTransform(D3DTS_WORLD, &(m_matRotate * m_matTranslate));

pVertexBuf.Render(Woah_System::GetInterface()->m_pGraphics.GetDevice(), 2, D3DPT_TRIANGLELIST);
}

suckxez
suckxez
Ok, I've found out that texture are only blurry in windowed mode. They seem to be pretty clear in fullscreen mode. Idea anyone?
PinguinDude
PinguinDude
Your window in the screenshot is larger than 800x600, so directx will most likely resize your rendered image to fit the window's size.
http://sourceforge.net/projects/pingux/ <-- you know you wanna see my 2D Engine which supports DirectX and OpenGL or insert your renderer here :)
suckxez
suckxez
Quote:
Original post by PinguinDude
Your window in the screenshot is larger than 800x600, so directx will most likely resize your rendered image to fit the window's size.


That doesnt matter. It's even blurry when it's 800x600
TheAdmiral
TheAdmiral
Quote:
Original post by suckxez
It's even blurry when it's 800x600

Are those the dimensions of the window, the client RECT or the back-buffer?
Show us the code you use to create the IDirect3DDevice9. It's possible that your back-buffer is a different size to the render area.

Admiral
Ring3 Circus - Diary of a programmer, journal of a hacker.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.