# Defined Resolution and Pixel Location -vs- Actual (???)

## Recommended Posts

Hey all, I'm having a fairly newbie problem. First of all, I'm quite certain that the solution/problem are simple and basic, so please don't be put off by my post's length. I realize that this is similar to Odoacer's post, and I apologize for that, but I felt I needed some clarification beyond any he got. Right now I'm using vertices with an RHW so that I can remake Tetris using pixel locations. It's the first game I've ever made, and whether or not this is the best way to go or not, it's the way I've gone. My issue is that I've defined the window to be 600x600, and yet it doesn't seem to correspond to a 600x600 amount of pixels. What I mean is, to start off simple I created a 600x600 texture of my background and applied it to a square polygon made up of 4 vertices whose XYZ locations are defined at 0,0,0; 600,0,0; 0,600,0; and 600,600,0. My thought is that I have 600x600 window, so a 600x600 textured-polygon should fit snugly inside. It doesn't though. It fills the window, and then a tad bit more on both the bottom and right edges (away from the 0,0 screen window position). I know that most books say textures have to be (2^X x 2^Y) in resolution, but the RPG book by Jim Adams used a 600x600 texture for particles at one point, so I figured it was okay. If this is somehow the reason, what's the solution? I don't feel as if that's the reason though. When I increase my window size to 700x700, I get the entire textured bachground in the window, but with black bars (the CLEAR color) on the bottom and right (which makes sense). The interesting thing is that the black bars are not of equal thickness on the bottom and right sides. The right edge is thicker than the bottom. I guess my question is what are the details of window sizes and using the RHW vertex format? Is the defined window size the actual, usable space, or is it the size of the entire window, blue borders included? That latter almost seems to be the case, and would explain why the bottom black bar was smaller than the right, due to the larger blue border on top. It still doesn't explain why 0,0 would be the upper-left of the usable window space. I would post code, but what I need is to understand what is happening, not just how to fix it for this one case. This is mostly because my code right now is only place holder without using functions that will be put in later. Also, like I said, everything I've done to create my background has been based on exact pixel locations so that when DirectX draws pieces on top, everything looks slick. But now that the image appears off, well... Any help would be greatly appreciated. I look forward to understanding enough of the vast amount of knowledge on here to one day answer someone else's question for once. Eric ::EDIT:: I didn't post pics because I had a feeling this was a common newbie question, but if they'd help, let me know.

##### Share on other sites
Telastyn    3777
To my knowledge, the window size includes the title bar, and the border, hence the actual renderable area is slightly less than 600x600.

GetClientRect() will return the actual renderable size.

##### Share on other sites
Thanks for the info and function. In that case, anyone know the thicknesses of the title and borders so that I can add that amount and get a 600x600 renderable area?

::EDIT::

A window area of 608 x 634 seems to fit the 600x600 polygon now. I'm going to continue working off the assumption that I now have a 600x600 renderable area with 0,0 in the upper-left of the usable window and 600,600 in the lower-right. If any of those assumptions are wrong, let me know and I'll check back often. Thanks.

##### Share on other sites
Mastaba    761
Those assumptions can be very wrong for people that use large fonts. You need to use AdjustWindowRectEx to calculate the proper size of the window for a given client window size.

##### Share on other sites
JoeyBlow2    100
As Mastaba says, you need to use the AdjustWindowRect function to calculate the real size of the window.

For example... Lets say you want your 600 x600 view area. You would want to pass that into the function with all the window flags you use to create the window with. It will return you the real size of the window. Which would be the 600x600 + any room needed for the titlebar and window border. You then use that for the CreateWindow command.

  RECT rect;  rect.left = 0;  rect.top = 0;  rect.right = 600;  rect.bottom = 600;  AdjustWindowRect(&rect, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME, FALSE);      p_hWindow = CreateWindow(p_AppInit->ShortName.c_str(),                                           p_AppInit->LongName.c_str(),                                 WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME,                                                  0,                                          0,                                            (int)(abs(rect.right) + abs(rect.left)),                                                      (int)(abs(rect.bottom) + abs(rect.top)),                                 NULL,                                                     NULL,                                                     p_AppInit->hInstance,                                                 NULL);

##### Share on other sites
Good to know ahead of time. Thanks for the information, guys.

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account