Defines the arguments for frame events. A FrameEventArgs instance is only valid for the duration of the relevant event; do not store references to FrameEventArgs outside this event.
Inheritance: System.EventArgs
Exemplo n.º 1
0
        public void Render(FrameEventArgs e)
        {
            UpdateControl();

            int x = 100;
            int y = 110;

            GL.Disable(EnableCap.Texture2D);
            Draw.FilledRectangle(x, y, game.Width - x * 2, game.Height - y * 2, new Color4(32, 32, 32, 255));
            Draw.Rectangle(x, y, game.Width - x * 2, game.Height - y * 2, new Color4(96, 96, 96, 255));

            font.Options.Colour = Color4.LightGray;
            font.Print(@"On the other hand, we denounce with righteous indignation and
            dislike men who are so beguiled and demoralized by the
            charms of pleasure of the moment, so blinded by desire,
            that they cannot foresee the pain and trouble that are
            bound to ensue; and equal blame belongs to those who fail
            in their duty through weakness of will, which is the same as saying
            through shrinking from toil and pain. These cases are perfectly
            simple and easy to distinguish. In a free hour, when our
            power of choice isuntrammelled and when nothing prevents our
            being able to do what we like best, every pleasure is to be
            welcomed and every pain avoided. But in certain circumstances
            and owing to the claims of duty or the obligations of business
            it will frequently occur that pleasures have to be repudiated
            and annoyances accepted. The wise man therefore always holds in
            these matters to this principle of selection: he rejects
            pleasures to secure other greater pleasures, or else he
            endures pains to avoid worse pains.", new Vector2(x + 10, y + 10));

            font.Options.Colour = Color4.Orange;
            font.Print("<< Back", new Vector2(x + 10, 450));
        }
Exemplo n.º 2
0
        public override void Update(OpenTK.FrameEventArgs e)
        {
            base.Update(e);

            if (_spriteTimer > 0)
            {
                _spriteTimer -= (float)e.Time;
            }

            KeyboardState keyState = Keyboard.GetState();

            bool running = false;

            if (keyState.IsKeyDown(Key.LShift) && _mapPlayer.GetPlayerPacket().Data.Stamina > 0)
            {
                running = true;
            }

            if (!Moving())
            {
                SetXFrame(0);
            }
            else
            {
                if (_spriteTimer <= 0)
                {
                    _spriteTimer = _spriteTimerMax;
                    if (running)
                    {
                        _spriteTimer /= 3.0f;
                    }
                    IncrementXFrame();
                }
            }
        }
Exemplo n.º 3
0
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            physics.Update((float)e.Time);

            if (Keyboard[OpenTK.Input.Key.Escape] || Keyboard[OpenTK.Input.Key.Q])
                Exit();
        }
Exemplo n.º 4
0
        private void OnRenderFrame(object sender, OpenTK.FrameEventArgs e)
        {
            // set up viewport
            GL.Viewport(0, 0, Width, Height);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            SetupPerspective();

            // determinate object view rotation vectors and apply them
            _objectView = _baseView;
            var rotation = _rotateVectors[_rotateIndex];

            if (rotation != Vector3.Zero)
            {
                _objectView *= Matrix4.CreateFromAxisAngle(_rotateVectors[_rotateIndex], (float)(_stopwatch.Elapsed.TotalSeconds * 1.0));
            }

            // set transformation matrix
            _textureProgram.Use();
            _textureProgram.ModelViewProjectionMatrix.Set(_objectView * ModelView * Projection);

            // render cube with texture
            _cubeVao.Bind();
            _cubeVao.DrawArrays(_cube.DefaultMode, 0, _cube.VertexBuffer.ElementCount);

            // swap buffers
            SwapBuffers();
        }
Exemplo n.º 5
0
        protected override void OnRenderFrame(OpenTK.FrameEventArgs e)
        {
            Title = $"Forge {versionNum} FPS: {1f / e.Time:0} Map: {currentMap}";

            //Clear screen
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            //TODO move to seperate file
            //Tell OpenGL to use our shaders
            if (_useShaded)
            {
                GL.UseProgram(_shadedShaderProgram);
            }
            else
            {
                GL.UseProgram(_defaultShaderProgram);
            }


            //Send projection matrix to shader
            GL.UniformMatrix4(
                20,                                    //Match location in shader
                false,                                 //don't transpose
                ref cam.projectionMatrix               //use projection matrix
                );

            //Send view matrix to shader
            GL.UniformMatrix4(21, false, ref cam.viewMatrix);

            //Send model matrix to shader
            GL.UniformMatrix4(22, false, ref cam.modelMatrix);

            //Render Grid
            if (drawGrid)
            {
                grid.Bind();
                grid.Render(PrimitiveType.Lines);
            }

            //Render each object in object array
            foreach (RenderObject renderObject in renderObjects)
            {
                renderObject.Bind();
                renderObject.Render(PrimitiveType.TriangleFan);
            }

            ////Depth color pass
            //foreach (RenderObject renderObject in renderObjects)
            //{
            //	GL.UseProgram(_lineShaderProgram);
            //	renderObject.Bind();
            //	renderObject.Render(PrimitiveType.LineStrip);
            //}

            //Render ImGUI gui
            //RenderGui();

            //Display new frame
            SwapBuffers();
        }
Exemplo n.º 6
0
        /*public void SetBallPositions (ZertzBallRenderer[] balls) {
         *      float z1 = HALF_WIDTH-2.0f*ZertzBallRenderer.RADIUS, x = HALF_WIDTH+0.5f*THICKNESS, y = this.ballheight, dz = 3.0f*ZertzBallRenderer.RADIUS;
         *      float z2 = -z1, z3 = z1;
         *      Vector3 v;
         *      foreach(ZertzBallRenderer zbr in balls) {
         *              switch(zbr.Type) {
         *                      case ZertzBallType.White :
         *                              v = new Vector3(-x,y,z1);
         *                              z1 -= dz;
         *                              break;
         *                      case ZertzBallType.Gray :
         *                              v = new Vector3(-x,y,z2);
         *                              z2 += dz;
         *                              break;
         *                      case ZertzBallType.Black :
         *                              v = new Vector3(x,y,z3);
         *                              z3 -= dz;
         *                              break;
         *                      default :
         *                              v = Vector3.Zero;
         *                              break;
         *              }
         *              zbr.RenderMover = RenderMoveManager.GenerateStaticMover(v);
         *      }
         * }*/
        /*public void SetRingPositions (ZertzRingRenderer[] rings) {
         *      int mask = ~0x01;
         *      float r = HALF_WIDTH+0.5f*THICKNESS, y0 = ZertzRingRenderer.THICKNESS+BORDER_HEIGHT+CORNER_HEIGHT;
         *      float moveHeight = BORDER_HEIGHT+CORNER_HEIGHT+ZertzTileRenderer.TILE_HEIGHT;
         *      for(int i = 0x00; i < rings.Length; i++) {
         *              rings[i].TileLocation = new Vector3(r,2.0f*ZertzRingRenderer.THICKNESS*(i&mask)+y0,r);
         *              rings[i].MoveHeight = moveHeight;
         *              r = -r;
         *      }
         * }*/
        public void Render(OpenTK.FrameEventArgs e)
        {
            GL.Color3(0.4f, 0.2f, 0.0f);
            this.ztra.Render(e);
            this.ztrb.Render(e);
            GL.PushClientAttrib(ClientAttribMask.ClientAllAttribBits);
            GL.EnableClientState(ArrayCap.VertexArray);
            GL.EnableClientState(ArrayCap.NormalArray);
            GL.EnableClientState(ArrayCap.TextureCoordArray);
            GL.BindBuffer(BufferTarget.ArrayBuffer, cupBuff);
            int stride = sizeof(float) << 0x03;

            GL.VertexPointer(0x03, VertexPointerType.Float, stride, 0x00);
            GL.NormalPointer(NormalPointerType.Float, stride, 0x03 * sizeof(float));
            GL.TexCoordPointer(0x02, TexCoordPointerType.Float, stride, 0x06 * sizeof(float));
            GL.DrawArrays(BeginMode.Quads, 0x00, cupN);

            /*GL.PushAttrib(AttribMask.EnableBit);
             * GL.Color3(1.0f,1.0f,1.0f);
             * GL.Enable(EnableCap.Texture2D);
             * GL.BindTexture(TextureTarget.Texture2D,glT);
             * GL.BindBuffer(BufferTarget.ArrayBuffer,glBuff);
             * GL.BindBuffer(BufferTarget.ElementArrayBuffer,glIdBuff);
             * GL.VertexPointer(0x03,VertexPointerType.Float,stride,0x00);
             * GL.NormalPointer(NormalPointerType.Float,stride,0x03*sizeof(float));
             * GL.TexCoordPointer(0x02,TexCoordPointerType.Float,stride,0x06*sizeof(float));
             * GL.DrawElements(BeginMode.QuadStrip,glN,DrawElementsType.UnsignedInt,0x00);
             * GL.PopAttrib();//*/

            GL.PopClientAttrib();
            GL.Color3(0.09f, 0.275f, 0.17f);
            //ws.Render(e);
        }
Exemplo n.º 7
0
 protected override void OnUpdateFrame(OpenTK.FrameEventArgs e)
 {
     if (Keyboard[Key.Escape] || Keyboard[Key.Q])
     {
         Exit();
     }
 }
 public override void OnUpdateFrame(FrameEventArgs e)
 {
     base.OnUpdateFrame(e);
     count++;
     if (count >= maxCount)
         TestSuccess();
 }
Exemplo n.º 9
0
        /// <summary>
        /// Called when the frame is updated.
        /// </summary>
        protected override void OnUpdateFrame(OpenTK.FrameEventArgs e)
        {
            base.OnUpdateFrame(e);

            Hue1024++;

            float h = Hue1024 / 1024f;
            var   c = OpenTK.Graphics.Color4.FromHsv(new Vector4(h, Sat, Value, 1));

            GL.ClearColor(c);



            // バッファの初期化
            int sampleCount  = 256;
            int bufferLength = sampleCount * 2;

            wavebuffer = new int[sampleCount];

            // バッファのコピー (1024byte = 512sample)
            this.AudioCapture.ReadSamples(wavebuffer, bufferLength);


            // Rotation Right On
            if (this.RotationRight == true)
            {
                //GL.Rotate(-1, 0, 0, 1);
            }
        }
Exemplo n.º 10
0
        public override void Update(OpenTK.FrameEventArgs e)
        {
            base.Update(e);
            if (!_mapEvent.Enabled)
            {
                return;
            }

            if (_mapEvent.UpdateMovement((float)e.Time))
            {
                SetRealPosition();
            }

            SetYFrame((int)_mapEvent.EventDirection);

            if (_spriteTimer > 0)
            {
                _spriteTimer -= (float)e.Time;
            }

            if (!_mapEvent.Moving())
            {
                SetXFrame(0);
            }
            else
            {
                if (_spriteTimer <= 0)
                {
                    _spriteTimer = _spriteTimerMax;
                    IncrementXFrame();
                }
            }
        }
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            if (_synchronizeCameras)
            {
                _lodCamera.Position = _camera.Position;
                _lodCamera.Target   = _camera.Target;
                _lodCamera.Up       = _camera.Up;
                _lodCamera.Width    = _camera.Width;
                _lodCamera.Height   = _camera.Height;
            }

            _frameTimeCounter.UpdateFrameTime(e.Time);

            GL.Clear(ClearBufferMask.DepthBufferBit);

            foreach (var system in _systems)
            {
                system.Update(ElapsedTime.TotalSeconds, _entityManager);
            }

            _terrain.Render(_camera, _lodCamera, _entityManager.GetComponent <PositionalLightComponent>(_entityManager.GetEntitiesWithComponent <PositionalLightComponent>().Single()).Position);
            _cube.Render(_camera, _entityManager.GetComponent <PositionalLightComponent>(_entityManager.GetEntitiesWithComponent <PositionalLightComponent>().Single()).Position);

            SwapBuffers();
        }
Exemplo n.º 12
0
        private void GWindow_RenderFrame(object sender, OpenTK.FrameEventArgs e)
        {
            GL.ClearColor(1, 0, 0, 1);
            GL.Clear(ClearBufferMask.ColorBufferBit);
            GL.Clear(ClearBufferMask.DepthBufferBit);

            GL.LoadIdentity();

            double xtrans    = -xpos;
            double ztrans    = -zpos;
            double sceneroty = 360.0f - yrot;

            GL.Rotate(lookupdown, 1.0f, 0.0, 0.0);
            GL.Rotate(sceneroty, 0, 1.0f, 0);

            GL.Translate(xtrans, 0.25f, ztrans);

            foreach (var renderable in renderables)
            {
                renderable.Render();
            }

            GL.Flush();

            gWindow.SwapBuffers();
        }
 public override void OnRenderFrame(FrameEventArgs e)
 {
     base.OnRenderFrame(e);
     //our loaded vertex sets now represent on-screen objects that can be drawn
     foreach (VertexSet v in loadedVertexSets) {
         v.Draw();
     }
 }
Exemplo n.º 14
0
 public void Draw(FrameEventArgs e)
 {
     if (Visible)
       {
     foreach(GameComponent g in this.Components)
       g.Draw(e);
     DoDraw(e);
       }
 }
Exemplo n.º 15
0
        private void OnInternalUpdate(object sender, OpenTK.FrameEventArgs e)
        {
            UpdateFrameEventArgs args = new UpdateFrameEventArgs(e.Time * 1000D);

            Time = args.Time;

            OnUpdateFrame(this, args);
            UpdateFrame?.Invoke(this, args);
        }
Exemplo n.º 16
0
        public override void OnRenderFrame(OpenTK.FrameEventArgs e)
        {
            myCamera.UpdateViewMatrix();

            myShader.StartBatch();
            myCell.Render(myShader, RenderLayer.Base);
            myCell.Render(myShader, RenderLayer.Alpha1);
            myCell.Render(myShader, RenderLayer.Alpha2);
            myShader.EndBatch();
        }
Exemplo n.º 17
0
        private void onRenderFrame(object sender, OpenTK.FrameEventArgs args)
        {
            _renderFrameArgs.Time = args.Time;
            var renderFrame = RenderFrame;

            if (renderFrame != null)
            {
                renderFrame(sender, _renderFrameArgs);
            }
        }
Exemplo n.º 18
0
        private void onUpdateFrame(object sender, OpenTK.FrameEventArgs args)
        {
            _updateFrameArgs.Time = args.Time;
            var updateFrame = UpdateFrame;

            if (updateFrame != null)
            {
                updateFrame(sender, _updateFrameArgs);
            }
        }
Exemplo n.º 19
0
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            physics.Update((float)e.Time);

            KeyboardState state = OpenTK.Input.Keyboard.GetState();
            if (state.IsKeyDown(Key.Escape) || state.IsKeyDown(Key.Q))
            {
                Exit();
            }
        }
Exemplo n.º 20
0
        internal override void Render(FrameEventArgs e)
        {
            base.Render(e);

            GL.PushMatrix();
            GL.Translate(Coords.Xf, Coords.Yf, Coords.Zf);
            GL.Rotate(WorldHost.RotationCounter, -Vector3.UnitY);
            DisplayList.RenderDisplayList(DisplayList.BlockQuarterId, Block.FaceTexture(BlockType, Face.Top));
            GL.PopMatrix();
        }
Exemplo n.º 21
0
 public void Render(OpenTK.FrameEventArgs e)
 {
     lock (objects) {
         foreach (KeyValuePair <int, IRenderable> ir in this.objects)
         {
             GL.LoadName(ir.Key);
             ir.Value.Render(e);
         }
         GL.LoadName(-0x01);
     }
 }
Exemplo n.º 22
0
 private void BasicGameWindow_UpdateFrame(object sender, OpenTK.FrameEventArgs e)
 {
     if (States.CurrentState == null)
     {
         Exit();
     }
     else
     {
         States.Update(TimeSpan.FromSeconds(e.Time));
     }
 }
Exemplo n.º 23
0
        protected override void OnUpdateFrame(OpenTK.FrameEventArgs e)
        {
            OpenTK.Input.KeyboardState input = OpenTK.Input.Keyboard.GetState();

            if (input.IsKeyDown(OpenTK.Input.Key.Escape))
            {
                Exit();
            }

            base.OnUpdateFrame(e);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Aktualizace herního okna.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UpdateFrame(object sender, FrameEventArgs e)
        {
            frames++;

            if (ElapsedMilliseconds > 1000)
            {
                fps = frames * 1000 / ElapsedMilliseconds;
                frames = 0;
                Restart();
            }
        }
Exemplo n.º 25
0
 public void Render(OpenTK.FrameEventArgs e)
 {
     GL.PushClientAttrib(ClientAttribMask.ClientAllAttribBits);
     GL.EnableClientState(ArrayCap.VertexArray);
     GL.EnableClientState(ArrayCap.NormalArray);
     GL.BindBuffer(BufferTarget.ArrayBuffer, this.glRef);
     GL.BindBuffer(BufferTarget.ElementArrayBuffer, this.glInd);
     GL.VertexPointer(0x03, VertexPointerType.Float, Vector3.SizeInBytes, 0x00);
     GL.NormalPointer(NormalPointerType.Float, Vector3.SizeInBytes, m * n * Vector3.SizeInBytes);
     GL.DrawElements(BeginMode.QuadStrip, this.glN, DrawElementsType.UnsignedShort, 0x00);
     GL.PopClientAttrib();
 }
Exemplo n.º 26
0
        private void _window_RenderFrame(object sender, OpenTK.FrameEventArgs e)
        {
            GL.LoadIdentity();
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            for (int i = 0; i < _drawingList.Count; i++)
            {
                _drawingList[i].Draw();
            }

            _window.SwapBuffers();
        }
 private static void Gw_RenderFrame(object sender, OpenTK.FrameEventArgs e)
 {
     GL.ClearColor(Color4.Black);
     GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
     GL.BindBuffer(BufferTarget.ArrayBuffer, lineVertexBuffer);
     GL.UseProgram(shaderProgram);
     GL.BindVertexArray(vertexInfo);
     GL.DrawArrays(PrimitiveType.LineStrip, 0, vertexCount);
     GL.BindVertexArray(0);
     GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
     GL.UseProgram(0);
     gw.SwapBuffers();
 }
Exemplo n.º 28
0
 public override void OnRenderFrame(OpenTK.FrameEventArgs e)
 {
     GL.ClearColor(Color.Green);
     GL.Clear(ClearBufferMask.ColorBufferBit);
     the3d.OrthoMode(window.Width, window.Height);
     for (int i = 0; i < 7; i++)
     {
         the3d.Draw2dText("Hello!", 50, 100 + i * 50, 8 + i * 6, colors[i]);
     }
     for (int i = 0; i < 16; i++)
     {
         the3d.Draw2dText(colorCodes[i] + "Color" + "&f & " + colorCodes[i][1], 300, 100 + i * 30, 14, null);
     }
 }
Exemplo n.º 29
0
        /// <summary>
        /// Called when the frame is updated.
        /// </summary>
        protected override void OnUpdateFrame(OpenTK.FrameEventArgs e)
        {
            base.OnUpdateFrame(e);
            Console.WriteLine("On Update");

            count++;
            //image[count] = count / (float)(N*N);

            if (count > N * N)
            {
                count = 0;
            }
            image[count] = 1f;
        }
Exemplo n.º 30
0
        private void DoorBehaviour_Updated(object sender, OpenTK.FrameEventArgs e)
        {
            float dt = (float)e.Time;

            this.initialRotation = this.initialRotation ?? this.Detail.Rotation;

            float targetRotation = (this.isOpen ? 1.0f : 0.0f);

            float delta = targetRotation - this.fOpen;

            this.fOpen += Math.Sign(delta) * Math.Min(Math.Abs(delta), dt);

            this.Detail.Rotation = this.initialRotation.Value * Quaternion.FromAxisAngle(Vector3.UnitY, 0.7f * MathHelper.Pi * this.fOpen);
        }
Exemplo n.º 31
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            frameTime += (float)e.Time;
            fps++;
            if (frameTime >= 1)
            {
                frameTime = 0;
                Title = "BulletSharp OpenTK Demo, FPS = " + fps.ToString();
                fps = 0;
            }

            GL.Viewport(0, 0, Width, Height);

            float aspect_ratio = Width / (float)Height;
            Matrix4 perspective = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, aspect_ratio, 0.1f, 100);
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadMatrix(ref perspective);

            Matrix4 lookat = Matrix4.LookAt(new Vector3(10, 20, 30), Vector3.Zero, Vector3.UnitY);
            GL.MatrixMode(MatrixMode.Modelview);

            GL.Rotate(angle, 0.0f, 1.0f, 0.0f);
            angle += (float)e.Time*100;

            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            InitCube();

            foreach (RigidBody body in physics.World.CollisionObjectArray)
            {
                Matrix4 modelLookAt = Convert(body.MotionState.WorldTransform) * lookat;
                GL.LoadMatrix(ref modelLookAt);

                if ("Ground".Equals(body.UserObject))
                {
                    DrawCube(Color.Green, 50.0f);
                    continue;
                }

                if (body.ActivationState == ActivationState.ActiveTag)
                    DrawCube2(Color.Orange, 1);
                else
                    DrawCube2(Color.Red, 1);
            }

            UninitCube();

            SwapBuffers();
        }
Exemplo n.º 32
0
        protected override void OnUpdateFrame(OpenTK.FrameEventArgs e)
        {
            animator.Update(e.Time);

            if (isPlotUpdated)
            {
                isPlotUpdated = false;
                plotSurface.RedrawPlotSurface();
            }

            if (isStatusTextChanged)
            {
                isStatusTextChanged = false;
                PositionStatusText();
            }
        }
Exemplo n.º 33
0
        private void OnRenderFrame(object sender, OpenTK.FrameEventArgs e)
        {
            // Rotate the position of the camera around to make sure I'm not
            // running into any weird orientation issues.
            sininput += .01f;
            motionZ   = (float)Math.Sin((double)sininput) * 10;
            motionX   = (float)Math.Cos((double)sininput) * 10;
            camera.SetPosition(new Vector3(motionX, 3, motionZ));
            // For monitoring:
            Debug.WriteLine("current motion x:{0}, y:3, z:{1}", motionX, motionZ);

            GL.Clear(ClearBufferMask.ColorBufferBit);
            // Raise the draw event
            Draw?.Invoke(this, EventArgs.Empty);
            GL.Flush();
            Program.window.SwapBuffers();
        }
Exemplo n.º 34
0
        private void RenderFrame(object sender, OpenTK.FrameEventArgs e)
        {
            this.Renderer.Prepare();

            switch (this.Mode)
            {
            case 1:
                this.Render3D();
                break;

            case 2:
                this.Render2D();
                break;
            }

            this.Display.Update();
        }
Exemplo n.º 35
0
        public void Render(OpenTK.FrameEventArgs e)
        {
            //GL.PushAttrib
            GL.PushClientAttrib(ClientAttribMask.ClientAllAttribBits);
            GL.PushMatrix();
            GL.Translate(v);
            GL.BindBuffer(BufferTarget.ArrayBuffer, dataBuff);
            int stride = sizeof(float) << 0x03;

            GL.EnableClientState(ArrayCap.VertexArray);
            GL.EnableClientState(ArrayCap.NormalArray);
            GL.VertexPointer(0x03, VertexPointerType.Float, stride, 0x00);
            GL.NormalPointer(NormalPointerType.Float, stride, 0x03 * sizeof(float));
            GL.DrawArrays(BeginMode.QuadStrip, 0x00, dataN);
            GL.PopMatrix();
            GL.PopClientAttrib();
        }
Exemplo n.º 36
0
        private void OnInternalRender(object sender, OpenTK.FrameEventArgs e)
        {
            if (!_fpsTimer.IsRunning)
            {
                _fpsTimer.Start();
            }

            RenderFrameEventArgs args = new RenderFrameEventArgs(e.Time * 1000D);

            OnRenderFrame(this, args);
            RenderFrame?.Invoke(this, args);

            if (!_isEventPolled && _isStarted)
            {
                _fps++;
                CheckWindowFPS();
            }
        }
Exemplo n.º 37
0
        //Updates every frame
        protected override void OnUpdateFrame(OpenTK.FrameEventArgs e)
        {
            //Get keyboard inputs
            PollKeyboard();

            //Get horizontal and vertical angles TODO move to own function?
            if (camActive)
            {
                cam.HorizontalAngle += (Mouse.X - (Width / 2)) * e.Time * cam.mouseSensitivity;
                cam.VerticalAngle   += -(Mouse.Y - (Height / 2)) * e.Time * cam.mouseSensitivity;

                CenterMouse();
            }

            //Calculate the front facing vector
            cam.CalcFront();

            cam.viewMatrix = Matrix4.LookAt(cam.Position, cam.Position + Vector3.Normalize(cam.front), cam.up).Normalized();
        }
Exemplo n.º 38
0
 //int xi = 0;
 //int yi = 0;
 protected override void OnRenderFrame(OpenTK.FrameEventArgs e)
 {
     //Console.WriteLine($"xi:{xi}, yi:{yi}, c:{count}");
     GL.Begin(PrimitiveType.Points);
     {
         for (int i = 0; i < N * N; i++)
         {
             int x = (int)((float)i % N);
             int y = (int)((float)i / N);
             //float c = image[i];
             float c = 1f;
             GL.Color3(c, 0f, 0f);
             GL.Vertex2(x, y);
             //Console.WriteLine($"xi:{x}, yi:{y}, c:{c}");
         }
     }
     GL.End();
     this.SwapBuffers();
     base.OnRenderFrame(e);
 }
Exemplo n.º 39
0
        private void _window_RenderFrame(object sender, OpenTK.FrameEventArgs e)
        {
            //exit window if escape pressed
            KeyboardState input = Keyboard.GetState();

            if (input.IsKeyDown(Key.Escape))
            {
                _window.Exit();
            }

            GL.LoadIdentity();
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            for (int i = 0; i < _drawingList.Count; i++)
            {
                _drawingList[i].Draw();
            }

            _window.SwapBuffers();
        }
Exemplo n.º 40
0
        /// <summary>Projectile explodes on decay.</summary>
        internal void OnItemDecay(FrameEventArgs e)
        {
            if (Config.IsServer || Config.IsSinglePlayer)
            {
                var positions = Coords.AdjacentPositions;
                var removeBlocks = new List<RemoveBlock>();
                var addBlockItems = new List<AddBlockItem>();
                Settings.ChunkUpdatesDisabled = true;
                foreach (var position in positions)
                {
                    var block = position.GetBlock();
                    if (block.Type != Block.BlockType.Air && block.Type != Block.BlockType.Water)
                    {
                        WorldData.PlaceBlock(position, Block.BlockType.Air);
                        var tempPosition = position; //copy to pass by ref
                        removeBlocks.Add(new RemoveBlock(ref tempPosition));

                        if (!block.IsTransparent && position.IsValidItemLocation)
                        {
                            var tempCoords = position.ToCoords(); //copy to pass by ref
                            var newBlockItem = new BlockItem(ref tempCoords, block.Type);
                            addBlockItems.Add(new AddBlockItem(ref newBlockItem.Coords, ref newBlockItem.Velocity, newBlockItem.BlockType, newBlockItem.Id));
                        }
                    }
                }
                Settings.ChunkUpdatesDisabled = false;

                if (Config.IsServer && removeBlocks.Count > 0)
                {
                    foreach (var player in Server.Controller.Players.Values)
                    {
                        var removeBlockMulti = new RemoveBlockMulti {ConnectedPlayer = player};
                        removeBlockMulti.Blocks.AddRange(removeBlocks);
                        removeBlockMulti.BlockItems.AddRange(addBlockItems);
                        removeBlockMulti.Send();
                    }
                }
            }
        }
Exemplo n.º 41
0
 protected override void DoDraw(FrameEventArgs e)
 {
 }
Exemplo n.º 42
0
 public virtual void Draw(FrameEventArgs e)
 {
 }
Exemplo n.º 43
0
 private void RotationBehaviour_Updated(object sender, FrameEventArgs e)
 {
     this.Detail.Rotation *= Quaternion.FromAxisAngle(Vector3.UnitY, (float)e.Time);
 }
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            if (_synchronizeCameras)
            {
                _lodCamera.Position = _camera.Position;
                _lodCamera.Target = _camera.Target;
                _lodCamera.Up = _camera.Up;
                _lodCamera.Width = _camera.Width;
                _lodCamera.Height = _camera.Height;
            }

            _frameTimeCounter.UpdateFrameTime(e.Time);

            GL.Clear(ClearBufferMask.DepthBufferBit);

            foreach (var system in _systems)
            {
                system.Update(ElapsedTime.TotalSeconds, _entityManager);
            }

            _terrain.Render(_camera, _lodCamera, _entityManager.GetComponent<PositionalLightComponent>(_entityManager.GetEntitiesWithComponent<PositionalLightComponent>().Single()).Position);
            _cube.Render(_camera, _entityManager.GetComponent<PositionalLightComponent>(_entityManager.GetEntitiesWithComponent<PositionalLightComponent>().Single()).Position);

            SwapBuffers();
        }
Exemplo n.º 45
0
        private void Game_RenderFrame(object sender, FrameEventArgs e)
        {
            GL.Viewport(0, 0, Width, Height);

            GL.MatrixMode(MatrixMode.Projection);
            GL.PushMatrix();
            GL.LoadIdentity();
            GL.Ortho(0, Width, Height, 0, -1, 1);

            GL.Disable(EnableCap.DepthTest);
            GL.Enable(EnableCap.Blend);
            GL.Enable(EnableCap.Texture2D);

            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();

            GL.ClearColor(OpenTK.Graphics.Color4.CornflowerBlue);
            GL.Clear(ClearBufferMask.ColorBufferBit);

            Camera.Begin();

            _map.Draw();

            _ui.Draw();

            Camera.End();

            SwapBuffers();
        }
Exemplo n.º 46
0
 void OnRender(object sender, FrameEventArgs e)
 {
     switch (gameState)
     {
         case GameState.LEVEL:
             stars.Render();
             level.Render();
             player.Render();
             break;
     }
 }
Exemplo n.º 47
0
Arquivo: Map.cs Projeto: aevv/Biscuit
        public void OnUpdateFrame(FrameEventArgs args)
        {
            foreach (var chunk in _chunks)
            {
                chunk.OnUpdateFrame(args);
            }

            foreach (var entity in _entities)
            {
                entity.OnUpdateFrame(args);
            }

            _self.OnUpdateFrame(args);
        }
Exemplo n.º 48
0
 internal static void Update(FrameEventArgs e)
 {
     if (OnUpdate != null) {
         OnUpdate();
     }
 }
 public override void OnRenderFrame(FrameEventArgs e)
 {
     base.OnRenderFrame(e);
     count++;
 }
Exemplo n.º 50
0
        public override void Update(FrameEventArgs e)
        {
            base.Update(e);
            if (!focused) return;
            time += e.Time;
            if (time > toggleCursorTime)
            {
                time = 0;
                if (textAppearence.AppendText == "|")
                    textAppearence.AppendText = "";
                else
                    textAppearence.AppendText = "|";

                Singleton<GUI>.INSTANCE.Dirty = true;
            }
        }
 protected override void OnRenderFrame(FrameEventArgs e)
 {
     base.OnRenderFrame(e);
     Draw();
 }
Exemplo n.º 52
0
 protected abstract void DoDraw(FrameEventArgs e);
Exemplo n.º 53
0
        internal static void OnUpdateFrame(FrameEventArgs e)
        {
            //Check Animation
            Rotation.Update((float)e.Time);

            //Keyboard movement
            Camera.CameraKeyboardMove((float)e.Time);
        }
Exemplo n.º 54
0
 protected abstract void DoUpdate(FrameEventArgs e);
Exemplo n.º 55
0
        private void Game_UpdateFrame(object sender, FrameEventArgs e)
        {
            PreviousMouseState = MouseState;
            PreviousKeyboardState = KeyboardState;

            MouseState = OpenTK.Input.Mouse.GetState();
            KeyboardState = OpenTK.Input.Keyboard.GetState();

            PreviousMousePosition = MousePosition;

            #if GRAPHMAKER
            XDocument doc = new XDocument();
            doc.Add(new XElement("Waypoints"));
            if (MouseState.LeftButton == ButtonState.Pressed && PreviousMouseState.LeftButton == ButtonState.Released) {
            int x = Camera.X + MousePosition.X;
            int y = Camera.Y + MousePosition.Y;

            if (MouseState.LeftButton == ButtonState.Pressed && PreviousMouseState.LeftButton == ButtonState.Released && MousePosition.X > 40) {
               doc.Element("Waypoints").Add(new XElement("Waypoint", new XAttribute("X", x), new XAttribute("Y", y)));
               minID++;
               Minion markerMinion = new Minion(new List<Sprite>() { new Sprite(new List<string>() { "Images/BlueMinion.png" }), new Sprite(new List<string>() { "Images/BlueMinion0.png", "Images/BlueMinion1.png" }) }, minID);
                markerMinion.Pos.X = x;
                markerMinion.Pos.Y = y;
                _player1.AddMinion(markerMinion);
              // doc.Save("TestWaypoint.xml");
            XDocument doc = new XDocument();
            doc.Add(new XElement("Waypoints"));
            if (MouseState.LeftButton == ButtonState.Pressed && PreviousMouseState.LeftButton == ButtonState.Released) {
            }

            if (MouseState.RightButton == ButtonState.Pressed && PreviousMouseState.RightButton == ButtonState.Released && MousePosition.X > 40)
            {
                switch (rightClicks)
                {
                    case 0: clicks[0] = x;
                        clicks[1] = y;
                        break;

                    case 1:
                        clicks[2] = x;
                        clicks[3] = y;
                         minID++;
                         Minion markerMinion = new Minion(new List<Sprite>() { new Sprite(new List<string>() { "Images/square.png" }), new Sprite(new List<string>() { "Images/square.png", "Images/square.png" }) }, minID);
                         WaypointNode waypoint1 = graph.GetClosestWaypoint(clicks[0], clicks[1]);
                         WaypointNode waypoint2 = graph.GetClosestWaypoint(clicks[2], clicks[3]);
                         markerMinion.Pos.X = waypoint1.X + (waypoint2.X - waypoint1.X) / 2;
                         markerMinion.Pos.Y = waypoint1.Y + (waypoint2.Y - waypoint1.Y) / 2;
                _player1.AddMinion(markerMinion);
                graph.ConnectNodes(waypoint1, waypoint2);
                        Console.Write("Added neighbor");
                        break;
                }
                rightClicks++;
                rightClicks = rightClicks % 2;
                graph.WriteGraph("TestWaypointNeighbors.xml");
            }

            _scrollBar.Update(e.Time);
            #else

            _map.Update(e.Time);

            _ui.Update(e.Time);

            #endif
            }

            private void Mouse_Move(object sender, MouseMoveEventArgs e)
            {
            MousePosition = e.Position;
            }
            }
        }
 public override void OnRenderFrame(FrameEventArgs e)
 {
     base.OnRenderFrame(e);
     sprites.Draw();
 }
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            ProcessMouseInput();

            ProcessKeyboardInput();
        }
Exemplo n.º 58
0
 public void Update(FrameEventArgs e)
 {
     if (Enabled)
       {
     foreach(GameComponent g in this.Components)
       g.Update(e);
     DoUpdate(e);
       }
 }
Exemplo n.º 59
0
 protected override void DoUpdate(FrameEventArgs e)
 {
 }
Exemplo n.º 60
0
 public virtual void Update(FrameEventArgs e)
 {
 }