Exemplo n.º 1
0
        private void WorkerMain()
        {
            if (!Initialized)
            {
                throw new InvalidOperationException("The OpenGL Library bindings are not initialized.");
            }

            if (TargetWindow == null)
            {
                CreateMainWindow(WindowTitle);
            }

            _systemTimer.Start();

            TargetWindow.MakeCurrent();

            ViewportSize = new Size(TargetWindow.ClientSize.X, TargetWindow.ClientSize.Y);

            if (WireframeMode)
            {
                WireframeMode = true; // Recall
            }
            if (AutoSetViewport)
            {
                Gl.Viewport(0, 0, ViewportSize.Width, ViewportSize.Height);
            }


            if (VerticalSync)
            {
                TargetWindow.SwapInterval = 1;
            }
            else
            {
                TargetWindow.SwapInterval = 0;
            }

            if (AutoEnableCaps.HasFlag(AutoEnableCapabilitiesFlags.Blend))
            {
                Gl.Enable(EnableCap.Blend);
            }

            OnContextCreated();

            _lastFrameTimeValue = 0;
            _timeSinceLastFrame = 0;
            _frameIndex         = 0;

            _currFrameTimerValue = _lastFrameTimeValue;

            if (Asynchronous)
            {
                while (!TargetWindow.IsExiting && !AbortFlag)
                {
                    AdvanceFrame();
                }

                AbortFlag = true;
            }
        }
 private void TargetWindow_Resize(OpenToolkit.Windowing.Common.ResizeEventArgs obj)
 {
     Gl.Viewport(0, 0, obj.Width, obj.Height);
 }