943,692 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 3173
  • C++ RSS
Jul 18th, 2008
0

C++ DirectX9-> Full Screen Bitmap

Expand Post »
Hi I am having great trouble with making my bitmap fit properly on a 1024x768 full screen window. The length is correct but the vertical is too long. I have searched the net and it has said that the size goes up in squares eg 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024

but as 768 is not a square, it gets resized up to 1024, the closest size. This completely stuffs up my bitmap because it goes off screen.

i devided it into 3 vertically, which makes each bitmap 256 pixels high. (a square, so it worked) but i find this a real silly way having to make 3 bitmaps just for 1. I know there must be an easier way. Please help
Reputation Points: 10
Solved Threads: 0
Newbie Poster
11silversurfer1 is offline Offline
17 posts
since Jul 2008
Jul 18th, 2008
0

Re: C++ DirectX9-> Full Screen Bitmap

You may get better responses to DirectX specific questions in the Game Development forum, or in the XNA forums (it's mostly centered on using the XNA tools with C#, but there are some forums on DirectX, and I do believe it's supposed to be the official DirectX forum).

As to your problem, screen sizes are not perfect squares. The only real rule is that the ratio of width to height should be 4:3, or 16:9 for widescreen (and that the numbers are integers). So, if 1024 is your width, using algebra:

4:3 = 1024:height

1024*3 = 4*height

1024*0.75 = height = 768.

I'm not sure exactly what you're looking for, if that wasn't it. Some code would help.
Reputation Points: 77
Solved Threads: 40
Posting Pro in Training
CoolGamer48 is offline Offline
401 posts
since Jan 2008
Jul 18th, 2008
0

Re: C++ DirectX9-> Full Screen Bitmap

sorry i didn't see the other section i'm new

that sounds like a good answer but when i set the bitmap to 1024 by 768 it goes to 1024x1024 for some reason.

codethis is on full screen 1024x768-the bitmap should full the whole screen perfectly).
C++ Syntax (Toggle Plain Text)
  1. LPDIRECT3D9 pD3D = NULL;
  2. LPDIRECT3DDEVICE9 pd3dDevice = NULL;
  3.  
  4. LPDIRECT3DTEXTURE9 menupic;
  5. LPD3DXSPRITE pd3dspt; // the pointer to our Direct3D Sprite interface
  6.  
  7. D3DXCreateTextureFromFileEx(pd3dDevice, // the device pointer
  8. "res/menu/menu.bmp", // the new file name
  9. 1024, // width
  10. 768, // height -rounds to 1024
  11. D3DX_DEFAULT, // no mip mapping
  12. NULL, // regular usage
  13. D3DFMT_A8R8G8B8, // 32-bit pixels with alpha
  14. D3DPOOL_MANAGED, // typical memory handling
  15. D3DX_DEFAULT, // no filtering
  16. D3DX_DEFAULT, // no mip filtering
  17. D3DCOLOR_XRGB(200, 0, 200), // color key
  18. NULL, // no image info struct
  19. NULL, // not using 256 colors
  20. &menupic); // menu picture sprite
  21.  
  22.  
  23. pd3dspt->Begin(D3DXSPRITE_ALPHABLEND); // begin sprite drawing
  24.  
  25. D3DXVECTOR3 menu_center(0.0f, 0.0f, 0.0f); // center at the upper-left corner
  26. D3DXVECTOR3 menu_position(0.0f,0.0f,0.0f); // position at 50, 50 with no depth
  27.  
  28. pd3dspt->Draw(menupic, NULL, &menu_center, &menu_position, D3DCOLOR_ARGB(255, 255, 255, 255));
  29.  
  30. pd3dspt->End(); // end sprite drawing
Last edited by Tekmaven; Jul 19th, 2008 at 3:38 am. Reason: Code tags
Reputation Points: 10
Solved Threads: 0
Newbie Poster
11silversurfer1 is offline Offline
17 posts
since Jul 2008
Jul 18th, 2008
0

Re: C++ DirectX9-> Full Screen Bitmap

Oh, I see what you mean about powers of two (I thought you meant that screen sizes could only be powers of two). I believe I've loaded images whose width/height weren't powers of two, but I don't remember off hand exactly how I did it. I'll see if I can dig up the code can get back to you. You could also research this a bit: D3DX_DEFAULT_NONPOW2. That might help you out.
Reputation Points: 77
Solved Threads: 40
Posting Pro in Training
CoolGamer48 is offline Offline
401 posts
since Jan 2008
Jul 19th, 2008
0

Re: C++ DirectX9-> Full Screen Bitmap

WOW THANKS I Cant wait for you to get back to me! i will search that up in the mean time.

EDIT: Searched D3DX_DEFAULT_NONPOW2 up and i put it in instead of the default but it didnt change anything. I cant make it a power of two size because 1024 is too big and 512 is too big. Hope you find how you did it.
Last edited by 11silversurfer1; Jul 19th, 2008 at 3:59 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
11silversurfer1 is offline Offline
17 posts
since Jul 2008
Jul 19th, 2008
1

Re: C++ DirectX9-> Full Screen Bitmap

Trying using surfaces instead of textures. link I believe that surfaces are supposed to be used for backgrounds, like the one you're using, and textures should be used for sprites, which often do have widths and heights that are powers of two.
Reputation Points: 77
Solved Threads: 40
Posting Pro in Training
CoolGamer48 is offline Offline
401 posts
since Jan 2008
Jul 20th, 2008
0

Re: C++ DirectX9-> Full Screen Bitmap

thanks could you give me a small example? i'm finding it quite hard to get it working.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
11silversurfer1 is offline Offline
17 posts
since Jul 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: array help
Next Thread in C++ Forum Timeline: a problem with overloading (class Circle)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC