OpenTK adds extra width and height to the window

Viewed 121

I am creating a little OpenTK app, and I have noticed just now that some extra pixels are added the the actual width and height of the window.

I have the window set to be 400x400, but when I print the width and height from the screen instance's code, it says the ClientSize is 442x442. And this is not fixed 42 pixels, if I raise the resolution to 800x800, it then is changed to 883x883. Why is this change happening? I can't find any information about it, not even on opentk.net, and I event looked at the source code and I couldn't find a reason for the change.

1 Answers

I haven't been able to find a solution for this exact problem, but I have found out that in the Screen constructor I can use the line ClientSize = new System.Drawing.Size(width, height); and it will work just fine.

Final result looks like this:

using System;
using System.Drawing;
using OpenTK;
using OpenTK.Graphics;

namespace Engine
{
    class Screen : GameWindow
    {
        public Screen(int width, int height, string title) : base(width, height, GraphicsMode.Default, title) 
        {
            // This line will correct the window size to be the one passed to the constructor
            ClientSize = new Size(width, height);
        }
    }
}
Related