I'm having some kind of issue with scaling my sprites, if they are scaled by for example value of 1.5f there are some spaces between them in rendered game image, first of all let me show you my drawing engine functions:
void D3D9_engine::BeginScene(){
g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0);
g_pd3dDevice->BeginScene();
gSprite->Begin(D3DXSPRITE_ALPHABLEND);
}
void D3D9_engine::SetScaleLevel(float scale){
scaleLevel = scale;
D3DXMatrixScaling(&matrix, scale, scale, 0.0f);
gSprite->SetTransform(&matrix);
}
float D3D9_engine::GetScaleLevel(){
return scaleLevel;
}
void D3D9_engine::PresentScene(){
gSprite->End();
g_pd3dDevice->EndScene();
g_pd3dDevice->Present(NULL, NULL, NULL, NULL);
}
void D3D9_engine::DrawSprite(uint16_t sprite, uint16_t x, uint16_t y){
uint16_t vectPos = sprite / spr_limits; // TODO for bitshift operator.
uint16_t spritePos = sprite & (spr_limits - 1);
RECT srcRect;
srcRect.top = spritePos << 5;
srcRect.left = 0;
srcRect.bottom = srcRect.top + 32;
srcRect.right = 32;
static D3DXVECTOR3 vCenter(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 vPosition(x, y, 0.0f);
gSprite->Draw(spritesVector[vectPos],
&srcRect,
&vCenter,
&vPosition,
D3DCOLOR_COLORVALUE(1.0f,1.0f,1.0f,1.0f));
}
Sprites are basically images of size 32x32 loaded into several textures, it works like charm and the memory usage as well as rendering speed is well above expected value.
I'm creating a Tibia game ( http://tibia.com ) client (old one, over 7 years old) just out of fun and the problem appears when I want to scale sprites using that SetScaleLevel function, sprites are not draw exactly as expected and there are some blank pixel lines between them:
Back to the blank pixel lines problem, CLAMP won't help at this point:
g_pd3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
g_pd3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
I'm stuck right now with this scaling problem (and I really need it but I think it might be problem with single precision numbers - hope not), hopefully you can help me.