| | |
C++ DirectX9-> Full Screen Bitmap
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2008
Posts: 17
Reputation:
Solved Threads: 0
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
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
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.
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...".
•
•
Join Date: Jul 2008
Posts: 17
Reputation:
Solved Threads: 0
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.
code
this is on full screen 1024x768-the bitmap should full the whole screen perfectly).
that sounds like a good answer but when i set the bitmap to 1024 by 768 it goes to 1024x1024 for some reason.
code
this is on full screen 1024x768-the bitmap should full the whole screen perfectly). C++ Syntax (Toggle Plain Text)
LPDIRECT3D9 pD3D = NULL; LPDIRECT3DDEVICE9 pd3dDevice = NULL; LPDIRECT3DTEXTURE9 menupic; LPD3DXSPRITE pd3dspt; // the pointer to our Direct3D Sprite interface D3DXCreateTextureFromFileEx(pd3dDevice, // the device pointer "res/menu/menu.bmp", // the new file name 1024, // width 768, // height -rounds to 1024 D3DX_DEFAULT, // no mip mapping NULL, // regular usage D3DFMT_A8R8G8B8, // 32-bit pixels with alpha D3DPOOL_MANAGED, // typical memory handling D3DX_DEFAULT, // no filtering D3DX_DEFAULT, // no mip filtering D3DCOLOR_XRGB(200, 0, 200), // color key NULL, // no image info struct NULL, // not using 256 colors &menupic); // menu picture sprite pd3dspt->Begin(D3DXSPRITE_ALPHABLEND); // begin sprite drawing D3DXVECTOR3 menu_center(0.0f, 0.0f, 0.0f); // center at the upper-left corner D3DXVECTOR3 menu_position(0.0f,0.0f,0.0f); // position at 50, 50 with no depth pd3dspt->Draw(menupic, NULL, &menu_center, &menu_position, D3DCOLOR_ARGB(255, 255, 255, 255)); pd3dspt->End(); // end sprite drawing
Last edited by Tekmaven; Jul 19th, 2008 at 3:38 am. Reason: Code tags
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...".
•
•
Join Date: Jul 2008
Posts: 17
Reputation:
Solved Threads: 0
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.
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.
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...".
![]() |
Other Threads in the C++ Forum
- Previous Thread: array help
- Next Thread: a problem with overloading (class Circle)
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news node output parameter pointer problem program programming project proxy python read recursion recursive reference return rpg string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





