Jump to content
  • Advertisement
Sign in to follow this  
Kija

windowed pixel resolution

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

Hi all, my application should handle both windowed mode and fullscreen. But I just want to support standard resolutions, like 800x600, 1024x768 and so on. I create my window with WS_OVERLAPPED | WS_CAPTION as flags, so it's a bare minimum, it's a caption bar at the top, there is no minimize / maximize / close buttons and it isn't possible to resize the window. Just the way I want it. Except that the rendering area of the window is smaller than 1024x768 (or whatever my resolution is). This is because the topic / caption bar at the top and the borders of the window "steals" some pixels of the 1024x768 window. So how would I create a window that has a 1024x768 rendering / direct3d area? I guess one solution would be to calculate how many pixels in x and y direction the borders steal and increase the windowed size by that but ... it would be a horrible way to solve it. This is quite important since I want to load textures onto a equally big area of the screen so I get pixel accuracy. Say that I have a 256x256 pixel texture and load it onto a 256x256 pixel big quad in screen space coordinates. Then the texture looks just the way as it should look. But if the rendering area is smaller than 1024x768 the 256x256 quad will be a bit smaller too and the texture needs to be resized to fit the new, smaller quad. And to those of you who think that a 256x256 pixel quad will still be 256x256 pixels even if the "rendering part" of the window is smaller: It won't be in my case since I will be using shaders for transformations and then I need to convert all screen space coordinates to clip space coordinates. And that would make for example a 256 pixel wide quad to be (256.0f / 1024.0f) clip space coordinates wide. Right? :) And if the _real_ x width of the screen is less than 1024.0f this quad would be smaller than 256 pixels. I'm new to Direct3D and very new to shaders so please correct me on every point where I'm wrong :P

Share this post


Link to post
Share on other sites
Advertisement
That should do exactly what I want, but it doesn't? I may be wrong here but I tell it to do a 1024x768 window and I get 1021x746? Without it I get 1018x743, so the AdjustRect changes it 3x3 pixels.

Here's the code:

LPRECT rect = new RECT;
rect->left = rect->top = 40;
rect->right = 1024;
rect->bottom = 768;
int flags = (WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
AdjustWindowRect(rect, flags, FALSE);
hWnd = CreateWindow(APP_TITLE, APP_TITLE, flags, rect->left, rect->top, rect->right, rect->bottom, GetDesktopWindow(), NULL, windowClass.hInstance, NULL);

GetClientRect(hWnd, rect);
char s[1000];
sprintf(s, "width: %i && height: %i", rect->right, rect->bottom);
logger.Log(s);



As you see, I call GetClientRect right after to check it. What am I missing?

Share this post


Link to post
Share on other sites
left = top = 0 does not alter the result. Still the same. I just used 40 because of some reason the top title / caption field was above the screen when I used 0. So the direct3d rendering area started at 0,0. Instead of the top left corner of the title / caption field.

Share this post


Link to post
Share on other sites
Quote:
Original post by Kija
left = top = 0 does not alter the result. Still the same. I just used 40 because of some reason the top title / caption field was above the screen when I used 0. So the direct3d rendering area started at 0,0. Instead of the top left corner of the title / caption field.


That would happen because it is making the client part of the window the same size as the screen, which means the caption would go offscreen.

Share this post


Link to post
Share on other sites
RECT::right and RECT::bottom are not the width and height. They are the right and bottom. I can't see how the result's the same when using 0 for top and left (in which case right and bottom will be the width and height).

Sure you tried this?

RECT rect;
rect.left = 0;
rect.top = 0;
rect.bottom = 768;
rect.right = 1024;
DWORD flags = (WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
AdjustWindowRect(&rect, flags, FALSE);

Share this post


Link to post
Share on other sites
In your first post you say you're using WS_OVERLAPPED and WS_CAPTION for your flags, but when you call AdjustRect you don't specify them?

int flags = (WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX);

You forgot to say WS_OVERLAPPED, which would include WS_BORDER, which is probably where you're losing your three pixels (left, right and bottom borders).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Parameters

lpRect
[in, out] Pointer to a RECT structure that contains the coordinates of the top-left and bottom-right corners of the desired client area. When the function returns, the structure contains the coordinates of the top-left and bottom-right corners of the window to accommodate the desired client area.
dwstyle
[in] Specifies the window style of the window whose required size is to be calculated. Note that you cannot specify the WS_OVERLAPPED style.
bMenu
[in] Specifies whether the window has a menu.

Share this post


Link to post
Share on other sites
GroZZleR, I removed WS_OVERLAPPED since the MSDN tells me so:
Quote:
MSDN: AdjustWindowRect Function
dwstyle
[in] Specifies the window style of the window whose required size is to be calculated. Note that you cannot specify the WS_OVERLAPPED style.


Coder, yep, the result would be the same even if left and top were set to 0, however... Your post and especially njpauls post gave me the answer. AdjustWindowRect changes top and left too :)

I send this to it:
left: 0 top: 0 right: 1024 bottom: 768
and I get this:
left: -3 top: -22 right: 1027 bottom: 771

So if I use right - left as width and bottom - top as height, it all goes well. I should've realised this when the window went above the screen... Well well, as I said: I'm new to this :)

Thanks for the quick replies everyone

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!