# \[solved\] Window.MaxWidth default at 4000

**URL:** <https://forum.castle-engine.io/t/solved-window-maxwidth-default-at-4000/1845>\
**Category:** Uncategorized\
**Created:** [March 29, 2025, 1:18pm UTC](https://forum.castle-engine.io/t/solved-window-maxwidth-default-at-4000/1845 "2025-03-29T13:18:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DiggiDoggi](https://forum.castle-engine.io/letter_avatar_proxy/v4/letter/d/6a8cbe/32.png) [@DiggiDoggi](https://forum.castle-engine.io/u/DiggiDoggi)\
**Post date:** [March 29, 2025, 1:18pm UTC](https://forum.castle-engine.io/t/solved-window-maxwidth-default-at-4000/1845/1 "2025-03-29T13:18:34Z")

</div>

I was quite puzzled that whenever I go FullScreen on 4k display, there’s a border on the right side. I typically test on lower, windowed resolutions so I didn’t pay much attention to it so far. Apparently, the TCastleWindow has a default value MaxWidth = 4000, same for MaxHeight. I know it’s described in documentation but I never knew I’d have to check the meaning of the Width property 😆

The 4k displays are 4096 pixels, so it’s just little bit more than the default, and now I know I have to change it for every new app. But if it isn’t too much to ask for, could that value be changed in the CGE source (CastleWindow.pas) to better reflect modern display capabilities? I know you’re busy with other TODOs, so I don’t push, it’s just a small QoL thing anyway.

---

<div class="post-metadata">

**Author:** ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)\
**Post date:** [March 30, 2025, 11:32am UTC](https://forum.castle-engine.io/t/solved-window-maxwidth-default-at-4000/1845/2 "2025-03-30T11:32:18Z")

</div>

Ha, nice catch, thank you 🙂 I changed it to 1000 \* 1000 now ( [Increase default TCastleWindow.MaxWidth/Height to be million (1000 \* … · castle-engine/castle-engine@85a85d6 · GitHub](https://github.com/castle-engine/castle-engine/commit/85a85d64cc7d14e11a961b13f6418e61bc82e412) ).

I set this limit “4000” many years ago, probably thinking _“4000 is well beyond the possible resolution of any existing monitor”_ 🙂 4k displays didn’t exist back then probably, or I didn’t know about them. ( The whole reason why we need a non-zero number there at all is internal, we should instead allow “0” there to mean “no limit”, it would be cleaner. Some day I shall improve it. )

---

<div class="post-metadata">

**Author:** ![DiggiDoggi](https://forum.castle-engine.io/letter_avatar_proxy/v4/letter/d/6a8cbe/32.png) [@DiggiDoggi](https://forum.castle-engine.io/u/DiggiDoggi)\
**Post date:** [May 3, 2025, 5:12am UTC](https://forum.castle-engine.io/t/solved-window-maxwidth-default-at-4000/1845/3 "2025-05-03T05:12:48Z")

</div>

I didn’t have a chance to check if that works any earlier - kind of holiday. But when I finally did… it doesn’t work 🧐

Reason:

```auto
{ TCastleWindow ---------------------------------------------------------- }

constructor TCastleWindow.Create(AOwner: TComponent);
...
  minWidth := 100; ---> maxWidth := 4000;
  minHeight := 100; ---> maxHeight := 4000;

```

---

<div class="post-metadata">

**Author:** ![DiggiDoggi](https://forum.castle-engine.io/letter_avatar_proxy/v4/letter/d/6a8cbe/32.png) [@DiggiDoggi](https://forum.castle-engine.io/u/DiggiDoggi)\
**Post date:** [May 3, 2025, 6:56am UTC](https://forum.castle-engine.io/t/solved-window-maxwidth-default-at-4000/1845/4 "2025-05-03T06:56:53Z")

</div>

And while you’re inside the CastleWindow.pas. I see that `OpenCore` has

```auto
    if ( (AntiAliasing = aa2SamplesNicer) or
         (AntiAliasing = aa4SamplesNicer) ) and
       GLFeatures.NV_multisample_filter_hint then
      glHint(GL_MULTISAMPLE_FILTER_HINT_NV, GL_NICEST);

```

I’m not an expert in openGL, but shouldn’t `aa8 / aa16 SamplesNicer` be also included in the OR list? Or maybe the Nicest/Faster could be a property, but I like them being simple constants 🙂

---

<div class="post-metadata">

**Author:** ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)\
**Post date:** [May 4, 2025, 3:38pm UTC](https://forum.castle-engine.io/t/solved-window-maxwidth-default-at-4000/1845/5 "2025-05-04T15:38:36Z")

</div>

> [@DiggiDoggi](#):
>
> I didn’t have a chance to check if that works any earlier - kind of holiday. But when I finally did… it doesn’t work 🧐

Ups, thanks for catching, looks like I made a rookie mistake 🙂 And not even a month ago I was warning about this mistake [at modern Pascal course](https://castle-engine.io/wp/2025/04/14/modern-pascal-course-examples-and-slides-updates-to-modern-pascal-book-to-fully-support-both-delphi-and-fpc/).

Fixed in [Fix default TCastleWindow.MaxWidth/Height · castle-engine/castle-engine@2366e4c · GitHub](https://github.com/castle-engine/castle-engine/commit/2366e4ce80fc7351c998c3807ad5cb59a2b8bc72) .

> [@DiggiDoggi](#):
>
> I’m not an expert in openGL, but shouldn’t `aa8 / aa16 SamplesNicer` be also included in the OR list? Or maybe the Nicest/Faster could be a property, but I like them being simple constants 🙂

Thanks again, fixed in [https://github.com/castle-engine/castle-engine/commit/0190463440e4fdd287ed211a4b63c1b0884e4d35](https://github.com/castle-engine/castle-engine/commit/0190463440e4fdd287ed211a4b63c1b0884e4d35) .
