Ejemplo n.º 1
0
 public void CreatePrimitiveWindow(VierportAnchor anchor, string title = null)
 {
     Window = new GameWindow {
         Title = title
     };
     SetupInputHandler();
     LoadLayoutAndRegisterSaveHook();
     InitializeResizeHandler(anchor);
     RegisterWindowSceneIndirections();
 }
Ejemplo n.º 2
0
        void InitializeResizeHandler(VierportAnchor anchor)
        {
            Window.Resize += (sender, args) => {
                GL.Viewport(0, 0, Window.Width, Window.Height);
                GL.LoadIdentity();
                switch (anchor)
                {
                case VierportAnchor.Horizontal:
                    var aspectH = Window.Width / (float)Window.Height;
                    GL.Scale(1, aspectH, 1);
                    break;

                case VierportAnchor.Vertical:
                    var aspectV = Window.Height / (float)Window.Width;
                    GL.Scale(aspectV, 1, 1);
                    break;

                default:
                    throw new ArgumentException("Invalid " + typeof(VierportAnchor).Name);
                }
            };
        }