public void Invalidate() { if (glview != null) { glview.Invalidate(); } }
public static void SubscribeControl(WindowsFormsHost glControlHost) { Exceptions.CheckArgumentNull(glControlHost, "glControlHost"); GLControl glControl = glControlHost.Child as GLControl; if (glControl == null) { throw new ArgumentException("glControlHost"); } SubscribeContext subscribeContext = new SubscribeContext { OnInvalidateControlRequestRecived = () => glControl.Invalidate(), OnViewportDesiredSizeChanged = (dw, dh) => glControlHost.Dispatcher.BeginInvoke(new Action(() => { glControlHost.Width = dw; glControlHost.Height = dh; glControl.Width = dw; glControl.Height = dh; })) }; if (!SubscribeContexts.TryAdd(glControlHost, subscribeContext)) { throw new Exception("Элемент управления уже зарегистрирован."); } InvalidateControlRequestRecived += subscribeContext.OnInvalidateControlRequestRecived; ViewportDesiredSizeChanged += subscribeContext.OnViewportDesiredSizeChanged; glControl.Invalidate(); }
/// <summary> /// Плохое завершение игры /// </summary> public void Finish() { finish = true; LogEvent?.Invoke("Игрок проиграл", player.Pos.X, player.Pos.Y); //Сообщение GL.ClearColor(Color.Black); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.LoadIdentity(); GL.PushMatrix(); GL.Translate(15, 15, 0); GL.Color3(Color.Black); GL.Begin(PrimitiveType.TriangleFan); GL.Vertex2(0, 0); GL.Vertex2(0, screen.Height); GL.Vertex2(screen.Width, screen.Height); GL.Vertex2(screen.Width, 0); GL.End(); GL.Color3(Color.Wheat); TextGame.Print2DText(50, (float)(screen.Height - 200), "Вы проиграли! Мир захватил электронный разум, вышедший из под контроля своих создателей."); TextGame.Print2DText(50, (float)(screen.Height - 350), "Неужели это конец?"); TextGame.Print2DText(50, (float)(screen.Height - 500), "Мастер, готовы ли вы к перерождению во имя победы?"); GL.PopMatrix(); // дожидаемся завершения визуализации кадра GL.Flush(); // сигнал для обновление элемента реализующего визуализацию. glControl.Invalidate(); }
private void CompositionTarget_Rendering(object sender, EventArgs e) { var time = DateTime.Now; var diff = (time - prevTime).TotalSeconds / 6; prevTime = time; if (checkT == true) { t += coef * diff; } if (t < 0) { t = 0; coef = 1; } if (t > 1) { t = 1; coef = -1; } long ticks = Stopwatch.GetTimestamp(); var ticksBetween = ticks - prevTick; var secondsBetween = TimeSpan.FromTicks(ticksBetween).TotalSeconds; fpsText.Text = "FPS: " + (1 / secondsBetween).ToString(); prevTick = ticks; glControl.Invalidate(); }
private new void Update() { bool directionX = true; bool directionZ = true; float step = 0.000004f; while (true) { switch (directionX) { case true: while (shader.lightPostion.X < 4) { shader.lightPostion.X += step; panel.Invalidate(); } break; case false: while (shader.lightPostion.X > -4) { shader.lightPostion.X -= step; panel.Invalidate(); } break; default: break; } switch (directionZ) { case true: while (shader.lightPostion.Z < 3) { shader.lightPostion.Z += step; panel.Invalidate(); } break; case false: while (shader.lightPostion.Z > -3) { shader.lightPostion.Z -= step; panel.Invalidate(); } break; default: break; } directionX = !directionX; directionZ = !directionZ; } }
public void UpdateViewport() { if (!Runtime.OpenTKInitialized) { return; } glControl1.Invalidate(); }
private void Animator_Tick(object sender, EventArgs e) { AnimGrp.AdvanceFrame(); AnimSeekBar.Value = AnimGrp.Frame; UpdateAnimationTransforms(); Viewport.Invalidate(); }
private void GlControl_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { if (captGlShape != null) { (captGlShape).Node.SetPosition(new Vector2d(e.X, e.Y)); (captGlShape).Node.UpdateRelativePos(false); glControl.Invalidate(); } }
private void GLControl_MouseMove(object sender, MouseEventArgs e) // перетаскивание объекта мышью { Vector2 mouseCoord = GetOpenGLMouseCoord(new Vector2(e.X, e.Y)); float currentMouseXPos = mouseCoord.X; float currentMouseYPos = mouseCoord.Y; if (_isRightDown) { //Console.WriteLine(string.Format("({0}, {1})", e.X - _mouseClickXPos, _mouseClickYPos - e.Y)); _objectXPos = currentMouseXPos; _objectYPos = currentMouseYPos; } _glControl.Invalidate(); }
private void Resize(object sender, EventArgs e) { if (!glLoaded) { return; } glControl.MakeCurrent(); GL.Viewport(0, 0, glControl.Width, glControl.Height); GL.MatrixMode(MatrixMode.Projection); GL.LoadIdentity(); float tangent = (float)Math.Tan(verticalFoV / 2f); float aspect = (float)glControl.Width / glControl.Height; float height = nearPlane * tangent; float width = height * aspect; GL.Frustum(-width, width, -height, height, nearPlane, farPlane + mesh.boundingBox.Length); frustumCenter.Z = -(farPlane - nearPlane) / 2f - nearPlane; glControl.Invalidate(); }
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { int countOfElements = _operations.Count; switch (keyData) { case Keys.Up: _operationIndex++; if (countOfElements == _operationIndex) { _operationIndex--; break; } ConfigureOperation(_operations[_operationIndex]); _graphicsCore.Initialize(); GLControl.Invalidate(); break; case Keys.Down: _operationIndex--; if (_operationIndex < 0) { _operationIndex++; break; } ConfigureOperation(_operations[_operationIndex]); _graphicsCore.Initialize(); GLControl.Invalidate(); break; } return(base.ProcessCmdKey(ref msg, keyData)); }
/// <summary> /// Timer tick event to refresh graphics. /// </summary> private void formUpdateTimer_Tick(object sender, EventArgs e) { //lock (this) { glControl1.Invalidate(); } }
/** * Fait avancer la scène de `elapsed` millisecondes */ public void update(int elapsed) { //Met à jour la position du mur wall.update(elapsed); //Théoriquement, on devrait ici appeler une méthode update() sur le joueur. //Cependant, Kinect s'occupe de mettre à jour automatiquement les données via l'évènement DepthFrameReady et ce n'est donc pas nécessaire //player.update(elapsed); //Forcer une mise à jour OpenGl en invalidant les données précédemment dessinnées glControl.Invalidate(); //Le mur est-il en bout de rail ? if (wall.atEndOfLine()) { //Déterminer le pourcentage du joueur dans le mur et hors du mur : int[] percent = player.percentValues(wall); Console.WriteLine("In " + percent[0] + " | Out " + percent[1]); //Enregistrer le dernier score pour l'afficher dans le HUD lastScore = Math.Max(0, percent[0] - (percent[1] - 20) / 2); totalScore += lastScore; currentWall++; //Lever le flag demandant une mise à jour du HUD. hudIsDirty = true; } }
private void PlaybackTimer_Tick(object sender, System.EventArgs e) { if (SelectedBank == null || !playing) { return; } currentFrame++; if (currentFrame >= SelectedBank.FrameCount) { currentFrame = 0; } textBoxFrameNumber.Text = currentFrame.ToString(); display.Invalidate(); }
/// <summary> /// Fired when the mouse is scrolled while the GLControl has focus /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void glControl_MouseWheel(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Delta != 0) { int delta = e.Delta / 120; renderControl.Zoom(delta); glControl.Invalidate(); } }
private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { LineCount = (int)e.NewValue; if (glc != null) { glc.Invalidate(); } }
public void glControl_KeyPress(object sender, KeyEventArgs e) { switch (e.KeyData) { case Keys.W: viewInfo.PanY += movePoint; break; case Keys.S: viewInfo.PanY -= movePoint; break; case Keys.A: viewInfo.PanX += movePoint; break; case Keys.D: viewInfo.PanX -= movePoint; break; case Keys.Q: viewInfo.AngleX -= movePoint; if (viewInfo.AngleX < 0) { viewInfo.AngleX += 360; } break; case Keys.E: viewInfo.AngleX += movePoint; if (viewInfo.AngleX > 360) { viewInfo.AngleX -= 360; } break; case Keys.R: viewInfo.AngleY -= movePoint; if (viewInfo.AngleX < 0) { viewInfo.AngleX += 360; } break; case Keys.F: viewInfo.AngleY += movePoint; if (viewInfo.AngleY > 360) { viewInfo.AngleY -= 360; } break; default: break; } glControl.Invalidate(); }
private new void Update() { bool dirX = true; bool dirZ = true; float step = 0.00001f; while (true) { if (dirX) { while (shader.lightPostion.X < 4) { shader.lightPostion.X += step; panel.Invalidate(); } } else { while (shader.lightPostion.X > -4) { shader.lightPostion.X -= step; panel.Invalidate(); } } if (dirZ) { while (shader.lightPostion.Z < 3) { shader.lightPostion.Z += step; panel.Invalidate(); } } else { while (shader.lightPostion.Z > -3) { shader.lightPostion.Z -= step; panel.Invalidate(); } } dirX = !dirX; dirZ = !dirZ; } }
private void OnTick(object sender, EventArgs e) { if (!HasRenderLoop) { return; } _glControl.Invalidate(); }
private void OnRender(object sender, PaintEventArgs e) { // Maybe somehow I can remove this trick AdjustMouseCursor(); m_renderQueueFunction(); GLControl.SwapBuffers(); GLControl.Invalidate(); }
public void glControl_MouseDown(object sender, MouseEventArgs e) { if (drawRefInfo.IsDrawLine) { switch (e.Button) { case MouseButtons.Left: drawRefInfo.VertexAdd = true; glControl.Invalidate(); break; case MouseButtons.Right: drawRefInfo.VertexDelete = true; glControl.Invalidate(); break; } } }
private void GlControl_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { switch (e.Button) { case System.Windows.Forms.MouseButtons.Left: double dx = e.X - mousePos.x; double dy = mousePos.y - e.Y; Matrix4 Yaw = Matrix4.CreateFromAxisAngle(top, (float)dx / 100); Matrix4 Pitch = Matrix4.CreateFromAxisAngle(OpenTK.Vector3.Cross(ViewDirection, top), (float)dy / 100); Matrix4 rot = Yaw * Pitch; ViewDirection = OpenTK.Vector3.TransformVector(ViewDirection, rot); top = OpenTK.Vector3.TransformVector(top, rot); mousePos.x = e.X; mousePos.y = e.Y; glControl.Invalidate(); break; case System.Windows.Forms.MouseButtons.Right: dx = e.X - mousePos.x; dy = mousePos.y - e.Y; eye += OpenTK.Vector3.Multiply(OpenTK.Vector3.Cross(ViewDirection, top), (float)dx / 100); eye += OpenTK.Vector3.Multiply(top, (float)dy / 5); mousePos.x = e.X; mousePos.y = e.Y; glControl.Invalidate(); break; case System.Windows.Forms.MouseButtons.Middle: dx = e.X - mousePos.x; dy = mousePos.y - e.Y; eye += OpenTK.Vector3.Multiply(ViewDirection, (float)dy / 100); mousePos.x = e.X; mousePos.y = e.Y; glControl.Invalidate(); break; default: mousePos.x = e.X; mousePos.y = e.Y; break; } VMatrix = Matrix4.LookAt(eye, eye + ViewDirection, top); }
void Application_Idle(object sender, EventArgs e) { if (User32.IsApplicationActivate()) { while (m_gl.IsIdle) { m_gl.Invalidate(); } } }
private void IterateRotate() { if (m_currentTwist == null) { return; } InvalidateTextures(m_currentTwist.IdentifiedTwistData); if (m_currentTwist.IdentifiedTwistDataEarthquake != null) { InvalidateTextures(m_currentTwist.IdentifiedTwistDataEarthquake); } if (m_puzzle.HasSurfaceConfig) { m_renderToTexture.InvalidateTexture(PuzzleRenderer.SurfaceTexture1); m_renderToTexture.InvalidateTexture(PuzzleRenderer.SurfaceTexture2); } int order = m_currentTwist.IdentifiedTwistDataEarthquake == null ? m_currentTwist.IdentifiedTwistData.Order : 10; m_rotation += R3.Core.Utils.DegreesToRadians(m_settings.RotationStep(order)); //Trace.WriteLine( "rotation " + m_rotation ); if (m_rotation > m_currentTwist.Magnitude) { m_rotation = m_currentTwist.Magnitude; FinishRotate(); // Special handling if we are solving. if (this.Solving) { // Start the next undo, if we can. if (!UndoInternal()) { this.Solving = false; // Do this so auto-solves won't beep when complete. m_twistHistory.Scrambled = false; } } } m_glControl.Invalidate(); }
/// <summary> /// Invoked when a plugin should be refreshed and repainted. /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event data</param> private void PluginManager_Refresh(object sender, Core.PluginEventArgs e) { if (e.Plugin.Type == Plugins.PluginType.Visualizer) { Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate() { canvas.Invalidate(); })); } }
private void tmrAxisRefresh_Tick(object sender, EventArgs e) { plotAxisHorz.Refresh(); plotAxisVert.Refresh(); this.Invalidate(); this.Update(); this.Refresh(); _glctrl.Invalidate(); _glctrl.Update(); _glctrl.Refresh(); }
private void LevelControl_MouseMove(object sender, MouseEventArgs e) { Point pos = getPos(e.Location); if (leftDown) { pos2 = pos; leftDown = true; control.Invalidate(); } }
public void GLContext_MouseMove(object sender, MouseEventArgs e) { Timeline timeline = Program.MainTimeline; if (timeline.SelectedKeyframe == null || timeline.SelectedLayer == null) { return; } Point location = RoundMousePos(UnprojectMousePos(e.Location)); if (ActiveDragObject == null) { Cursor = timeline.SelectedLayer.Data.TryManipulate(timeline.SelectedKeyframe.State, location, e.Button, ModifierKeys) != null ? Cursors.Hand : Cursors.Default; } else { Cursor = Cursors.Hand; timeline.SelectedLayer.Data.ManipulateUpdate(ActiveDragObject, ActiveDragParams, location); GLContext.Invalidate(); } }
private void Application_Idle(object sender, EventArgs e) { while (glControl.IsIdle) { if (DateTime.Now >= timeStamp) { label1.Text = frames + ""; frames = 0; timeStamp = DateTime.Now.AddSeconds(1); } glControl.Invalidate(); } }
private void Draw() { var frameTime = stopwatch.ElapsedMilliseconds / 1000f; stopwatch.Restart(); Camera.Tick(frameTime); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); Paint?.Invoke(this, new RenderEventArgs { FrameTime = frameTime, Camera = Camera }); glControl.SwapBuffers(); glControl.Invalidate(); }