Jump to content
  • Advertisement
Sign in to follow this  

Can't add background with sprite

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

I'm trying to add background with sprite on all screen (640x480) and then I add 640x480 image, it bacomes larger and other part cuts, if I make it smaller a bit nothing changes only then I make it very small the border shows on the screen and then I make it larger and draw it sprite becomes on all screen, I tried dds bmp formats but nothing changes. Is there other way to draw background, not using sprite ? I'm using Draw method:

hr = D3DXCreateTextureFromFile(d3ddev,"w.bmp",&sprites[3].sprite); // loads sprite

// sets sprite possition (top left corner)
sprites[3].pos.x= 0;
sprites[3].pos.y = 0;
sprites[3].pos.z = 0;


// draws sprite
hr = d3dspt->Draw(sprites[3].sprite,NULL,NULL,&spritai[3].pos, allColor);

d3ddev->Present(NULL, NULL, NULL, NULL);

P.S. Thanks in advance

Share this post

Link to post
Share on other sites
Hello ... do you use AdjustWindowRect() or AdjustWindowRectEx() when you create your window ?
If you don't ... you should.

Take a look at this article on msdn.

Also, take a look at this discussion here on how to use the two functions.

By using one of these functions, your client area will be the same size as your back buffer so you won't have any problems when displaying your sprite.

Share this post

Link to post
Share on other sites
Thanks for links, they make good start for me, but I still have problems with code:

SIZE sizeWindow;
RECT rc;
rc.top = rc.left = 0;
rc.right = 640;
rc.bottom = 480;
AdjustWindowRectEx(&rc, dwStyle, false,NULL);
sizeWindow.cx = rc.right - rc.left;
sizeWindow.cy = rc.bottom - rc.top;

hWnd = CreateWindowEx(NULL,
"Our Direct3D Program",
sizeWindow.cx, sizeWindow.cy,

ShowWindow(hWnd, nCmdShow);

I made everything as in tutorial but still not working :( Can someone help with this?

Share this post

Link to post
Share on other sites
Can we get a screenshot of the problem (You can upload an image to a free site like photobucket or imageshack and then link it here using HTML img tags)?

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!