C++ DirectX9-> Full Screen Bitmap

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2008
Posts: 17
Reputation: 11silversurfer1 is an unknown quantity at this point 
Solved Threads: 0
11silversurfer1 11silversurfer1 is offline Offline
Newbie Poster

C++ DirectX9-> Full Screen Bitmap

 
0
  #1
Jul 18th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 401
Reputation: CoolGamer48 is on a distinguished road 
Solved Threads: 40
CoolGamer48's Avatar
CoolGamer48 CoolGamer48 is offline Offline
Posting Pro in Training

Re: C++ DirectX9-> Full Screen Bitmap

 
0
  #2
Jul 18th, 2008
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.
I'm a student. If my statements seem too absolute, feel free to coat them with "In my opinion..." or "I believe...".
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 17
Reputation: 11silversurfer1 is an unknown quantity at this point 
Solved Threads: 0
11silversurfer1 11silversurfer1 is offline Offline
Newbie Poster

Re: C++ DirectX9-> Full Screen Bitmap

 
0
  #3
Jul 18th, 2008
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).
  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
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 401
Reputation: CoolGamer48 is on a distinguished road 
Solved Threads: 40
CoolGamer48's Avatar
CoolGamer48 CoolGamer48 is offline Offline
Posting Pro in Training

Re: C++ DirectX9-> Full Screen Bitmap

 
0
  #4
Jul 18th, 2008
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.
I'm a student. If my statements seem too absolute, feel free to coat them with "In my opinion..." or "I believe...".
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 17
Reputation: 11silversurfer1 is an unknown quantity at this point 
Solved Threads: 0
11silversurfer1 11silversurfer1 is offline Offline
Newbie Poster

Re: C++ DirectX9-> Full Screen Bitmap

 
0
  #5
Jul 19th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 401
Reputation: CoolGamer48 is on a distinguished road 
Solved Threads: 40
CoolGamer48's Avatar
CoolGamer48 CoolGamer48 is offline Offline
Posting Pro in Training

Re: C++ DirectX9-> Full Screen Bitmap

 
1
  #6
Jul 19th, 2008
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.
I'm a student. If my statements seem too absolute, feel free to coat them with "In my opinion..." or "I believe...".
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 17
Reputation: 11silversurfer1 is an unknown quantity at this point 
Solved Threads: 0
11silversurfer1 11silversurfer1 is offline Offline
Newbie Poster

Re: C++ DirectX9-> Full Screen Bitmap

 
0
  #7
Jul 20th, 2008
thanks could you give me a small example? i'm finding it quite hard to get it working.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC