Example #1
0
 internal extern static BOOL GetWindowRect(HWND windowHandle, out Rectangle windowRectangle);
Example #2
0
 internal extern static BOOL GetClientRect(HWND windowHandle, out Rectangle clientRectangle);
Example #3
0
 internal static Rectangle From(System.Drawing.Size value)
 {
     Rectangle rect = new Rectangle();
     rect.left = 0;
     rect.right = value.Width;
     rect.top = 0;
     rect.bottom = value.Height;
     return rect;
 }
Example #4
0
 internal static Rectangle From(System.Drawing.Rectangle value)
 {
     Rectangle rect = new Rectangle();
     rect.left = value.Left;
     rect.right = value.Right;
     rect.top = value.Top;
     rect.bottom = value.Bottom;
     return rect;
 }
Example #5
0
 internal static extern bool AdjustWindowRectEx(ref Rectangle lpRect, WindowStyle dwStyle, bool bMenu, ExtendedWindowStyle dwExStyle);
        public void CreateWindow(DisplayMode windowMode, out IGLContext context)
        {
            Debug.Print("Creating native window with mode: {0}", windowMode.ToString());
            Debug.Indent();

            CreateParams cp = new CreateParams();
            cp.ClassStyle =
                (int)WindowClassStyle.OwnDC |
                (int)WindowClassStyle.VRedraw |
                (int)WindowClassStyle.HRedraw |
                (int)WindowClassStyle.Ime;
            cp.Style =
                (int)WindowStyle.Visible |
                (int)WindowStyle.ClipChildren |
                (int)WindowStyle.ClipSiblings |
                (int)WindowStyle.OverlappedWindow;

            Rectangle rect = new Rectangle();
            rect.top = rect.left = 0;
            rect.bottom = windowMode.Height;
            rect.right = windowMode.Width;
            Functions.AdjustWindowRect(ref rect, WindowStyle.OverlappedWindow, false);

            // Not used
            Top = 0;
            Left = 0;
            Right = windowMode.Width;
            Bottom = windowMode.Height;
            // --------

            top_border = -rect.top;
            left_border = -rect.left;
            bottom_border = rect.bottom - windowMode.Height;
            right_border = rect.right - windowMode.Width;

            cp.Width = rect.right - rect.left;
            cp.Height = rect.bottom - rect.top;
            cp.Caption = "OpenTK Game Window";

            // Keep in mind that some construction code runs in WM_CREATE,
            // which is raised CreateHandle()
            CreateHandle(cp);

            if (this.Handle != IntPtr.Zero)
            {
                Debug.WriteLine("Window creation succesful.");
                //context.Info = new OpenTK.Platform.WindowInfo(this);
                //context.CreateContext();
                //Debug.WriteLine("Context creation successful.");
                exists = true;
            }
            else throw new ApplicationException(String.Format(
                    "Could not create native window and/or context. Handle: {0}",
                    this.Handle));

            Functions.SetWindowPos(this.Handle, WindowPlacementOptions.TOP, Left, Top, cp.Width, cp.Height, SetWindowPosFlags.SHOWWINDOW);

            //context = new GLContext(mode, window);
            //context.CreateContext();

            context = new WinGLContext();
            (context as IGLContextCreationHack).SetWindowHandle(window.Handle);
            (context as IGLContextCreationHack).SelectDisplayMode(mode, window);
            context.CreateContext(true, null);

            Debug.Unindent();
        }