Jump to content
  • Advertisement
Sign in to follow this  
sevko

Directx3D Draw Sprite using RECT problem

This topic is 2399 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

Hello everyone.

I'm trying to make a minesweeper program using directx9 and to draw different squares i'm using sprites so i wouldn't need a different texture for different types of squares.

I use the following code to render:

void Board::Render(){
RECT drawRect;
drawRect.left=0;
drawRect.right=29;
drawRect.top=0;
drawRect.bottom=29;
HRESULT hr=gD3dDevice->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0f,0);
if (FAILED(hr))
return;

hr=gD3dDevice->BeginScene();
if (SUCCEEDED(hr)){
gSprite->Begin(D3DXSPRITE_ALPHABLEND);

for (int i=0;i<Visina[NastavljenaTezavnost];i++)
for (int j=0;j<Sirina[NastavljenaTezavnost];j++){
gSprite->Draw(gTexture,&drawRect,NULL,&Squares[j].Pos,0xFFFFFFFF);
}

gSprite->End();

gD3dDevice->EndScene();
gD3dDevice->Present(NULL,NULL,NULL,NULL);
}
}


If I set the rects like in the example the unopened tiles render fine. But the problem steps in if I try to increment the left and right values(of the RECT) to draw the second one(increment them by 30).
The texture that I'm using is tga format 390*30(30 pixels for each tile).

Render from the code example:
wtf.jpg

If I try to render the second tile by setting drawRect.left to 30 and drawRect.right to 59
wtf2.jpg

What's the problem? Looking forward to your replies.
I also attached the whole project but it's in the begining of development so it's not optimized and the code is horrible.
[attachment=5951:Minolovec.zip]

Share this post


Link to post
Share on other sites
Advertisement
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!