Jump to content
  • Advertisement
Sign in to follow this  
-justin-

Direct3d 2d graphic problem

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

Hey everyone, so I FINALLY started programming again after a bit of a hiatus. I am starting a 2d pong game (for kicks and giggles). However I've run into a problem. I'm trying to use one BIG graphic with all the tiles on it, and then break up all the tiles into smaller graphics. My big graphic (shown below): Image Hosted by ImageShack.us is 208 x 150. My first paddle should be 29 x 75. However when I do the dimensions in C++ it is wrong! Here's a snippet from my code:
		RECT P1;
		P1.left = 0;
		P1.right = 48;
		P1.top = 0;
		P1.bottom = 120;

		gSprite->Begin(D3DXSPRITE_ALPHABLEND);

		// build the translation matrix
		D3DXVECTOR2 trans=D3DXVECTOR2(0.0f,barP1y);
		D3DXMATRIX mat;
		D3DXMatrixTransformation2D(&mat,NULL,0.0,NULL,NULL,NULL,&trans);

		// set the transform
		gSprite->SetTransform(&mat);

		// draw to the screen
		gSprite->Draw(gTexture, &P1, NULL, NULL, 0xFFFFFFFF);



can someone tell me what is wrong, with the image or the code?

Share this post


Link to post
Share on other sites
Advertisement
does it actually render an image from that textur, and the RECT is just off, is it not rendering, or does it get an error?

try D3DCOLOR_RGBA(255,255,255,255); instead of 0xFFFFFFFF
other than that, make sure that gtexture is loaded properly

Share this post


Link to post
Share on other sites
Quote:
Original post by -justin-
My first paddle should be 29 x 75.

RECT P1;
P1.left = 0;
P1.right = 48;
P1.top = 0;
P1.bottom = 120;


Share this post


Link to post
Share on other sites
not sure what you meant by the last post...

but yea, the rectangle is off... not sure why :/

i'll try what you said, thanx :)

Share this post


Link to post
Share on other sites
I believe he meant that if your first paddle is supposed to be 29x75, and P1 is your first paddle, then it looks like you've made that paddle 48x120 instead.

Share this post


Link to post
Share on other sites
yes i know, but that is my problem...

i should define it as 29x75... however, for whatever reason, if i define it like that then it comes up short (it doesn't show the whole image, just a small piece of that) only when i use 48x120 do i get the WHOLE image!

Share this post


Link to post
Share on other sites
Your image is probably being resized to a power of 2 when it's loaded, in this case 256x256. That would throw off your coordinates. You should make your master image dimensions powers of 2 so that the resizing doesn't occur. You can just fill any unused space with your background/transparent color.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!