Exemplo n.º 1
0
        private void LoadingScreenLoop()
        {
            GL.MatrixMode(MatrixMode.Projection);
            GL.PushMatrix();
            GL.LoadIdentity();
            GL.Ortho(0.0, (double)Screen.Width, (double)Screen.Height, 0.0, -1.0, 1.0);
            GL.Viewport(0, 0, Screen.Width, Screen.Height);

            while (!Loading.Complete && !Loading.Cancel)
            {
                CPreciseTimer.GetElapsedTime();
                this.ProcessEvents();
                if (this.IsExiting)
                {
                    Loading.Cancel = true;
                }

                Renderer.DrawLoadingScreen();
                Program.currentGameWindow.SwapBuffers();

                if (Loading.JobAvailable)
                {
                    while (jobs.Count > 0)
                    {
                        lock (jobLock)
                        {
                            var currentJob = jobs.Dequeue();
                            var locker     = locks.Dequeue();
                            currentJob();
                            lock (locker)
                            {
                                Monitor.Pulse(locker);
                            }
                        }
                    }
                    Loading.JobAvailable = false;
                }
                double time = CPreciseTimer.GetElapsedTime();
                double wait = 1000.0 / 60.0 - time * 1000 - 50;
                if (wait > 0)
                {
                    Thread.Sleep((int)(wait));
                }
            }
            if (!Loading.Cancel)
            {
                GL.PopMatrix();
                GL.MatrixMode(MatrixMode.Projection);
                SetupSimulation();
            }
            else
            {
                this.Exit();
            }
        }
        // Penguin
        private void GlcontrolOnPaint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            this.glcontrol.MakeCurrent();

            GL.MatrixMode(OpenTK.Graphics.OpenGL.MatrixMode.Projection);
            GL.LoadIdentity();
            float halfWidth  = (float)(this.glcontrol.Width / 2);
            float halfHeight = (float)(this.glcontrol.Height / 2);

            GL.Ortho(-halfWidth, halfWidth, halfHeight, -halfHeight, 1000, -1000);
            GL.Viewport(this.glcontrol.Size);

            this.renderer.Render();

            GL.Finish();

            this.glcontrol.SwapBuffers();

            this.frames++;
        }
Exemplo n.º 3
0
        public void DrawGraph()
        {
            if (!_canvasReady)
            {
                return;
            }

            CanvasManager.SimpleShader2D.UseProgram();
            GL.MatrixMode(OpenTK.Graphics.OpenGL.MatrixMode.Modelview);
            GL.Clear(ClearBufferMask.ColorBufferBit);

            GL.Viewport((int)CanvasManager.CanvasLocationX, (int)CanvasManager.CanvasLocationY, (int)CanvasManager.CanvasWidth, (int)CanvasManager.CanvasHeight);
            GL.Scissor((int)CanvasManager.CanvasLocationX, (int)CanvasManager.CanvasLocationY, (int)CanvasManager.CanvasWidth, (int)CanvasManager.CanvasHeight);
            GL.Enable(EnableCap.ScissorTest);

            var scale = new GraphScaleData(_scaleData);

            if (_transitionState == 1) //reposition
            {
                float factor = _transitionCounter / Interval;
                //x difference
                scale.XShift = _scaleData.XShift + (_transitionCanvas.ScaleData.XShift - _scaleData.XShift) * factor;
                //scale difference
                scale.BaseScale = _scaleData.BaseScale + (_transitionCanvas.ScaleData.BaseScale - _scaleData.BaseScale) * factor;
            }
            else if (_transitionState == 2)
            {
                scale.XShift    = _transitionCanvas.ScaleData.XShift;
                scale.BaseScale = _transitionCanvas.ScaleData.BaseScale;
            }
            else
            {
                scale.XShift    = _scaleData.XShift;
                scale.BaseScale = _scaleData.BaseScale;
            }

            if (_transitionState == 2) //blend colors
            {
                //DataVolume.AlphaBlend = 1 - _transitionCounter / Interval;
                //PacketCount.AlphaBlend = 1 - _transitionCounter / Interval;
                CanvasCollection.AlphaBlend(1 - _transitionCounter / Interval);
            }

            _background.Draw(scale.XShift);

            ////draw data volume
            //DataVolume.Draw(scale);
            ////draw packet count
            //PacketCount.Draw(scale);
            //
            CanvasCollection.DrawCollection(scale);

            if (_transitionState == 2)
            {
                //DataVolume.DrawBackBuffer(scale.BaseScale, _transitionCanvas.ScaleData.MaxData, scale.XShift);
                //PacketCount.DrawBackBuffer(scale.BaseScale, _transitionCanvas.ScaleData.MaxCount, scale.XShift);
                CanvasCollection.DrawCollectionBackBuffer(scale);
            }

            //////reset viewport
            GL.Viewport(0, 0, CanvasManager.ControlWidth, CanvasManager.ControlHeight);
            GL.Disable(EnableCap.ScissorTest);

            Matrix4 transform = CanvasManager.ViewportTransform;

            GL.UniformMatrix4(CanvasManager.SimpleShader2D.UniformTransform, false, ref transform);
            GL.Uniform4(CanvasManager.SimpleShader2D.UniformColor, Color4.Black);
            GL.LineWidth(2f);

            Border.BeginDraw();
            Border.Draw(BeginMode.LineLoop);
            Border.EndDraw();

            //transform.Invert();
            //float left = -(transform.M11 - transform.M41);
            //float right = transform.M11 + transform.M41;
            _yAxis.Draw(_scaleData.MaxData);
            _xAxis.Draw(scale.XShift, scale.BaseScale);
        }