Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Window client size is incorrect due not using AdjustWindowRect #11

Open
silbinarywolf opened this issue Jul 31, 2021 · 1 comment
Open

Comments

@silbinarywolf
Copy link

silbinarywolf commented Jul 31, 2021

The problem

When you create a window using the Win32 API, it assumes you're giving the width / height including border sizes. This means when you create a window, it ends up being off by a few pixels or so.

image
The above is a screenshot of the static_triangle sample. The size here is: 624x441 not the expected 640x480.

Found the solution via this stack overflow answer:

The solution

Examples should be updated to make this API call so that the client window size is correct.
If we do that, then the window will be correct.

image
Size of this image is 640x480

@gonutz
Copy link
Owner

gonutz commented Aug 1, 2021

You are right, the borders are not taken into account by the 640x480 given to CreateWindow. In this case though, that was actually my intent. I have tried this library on virtual Windows XP machines with 640x480 resolution. In this setup the window should not be larger than the screen, I actually really mean a 640x480 window, not client here. For this basic example the thing to show is how to get a triangle up on the screen. It is not intended to show inane Windows API quirks. They annoy me, I know about them, but this is not the place for them I think.

But thanks for the suggestion. I guess a way to solve this is to have multiple tutorials/examples, going from small-scale to large. We could have a nice tutorial with all these real-world problems that someone will face trying to create a real desktop 3D application, concentrating on one topic at a time. Unfortunately this is very time consuming and the thing I do not have right now is time...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants