public override void Render(float deltaTime) { var deltaX = PrevX + (X - PrevX) * deltaTime; var deltaY = PrevY + (Y - PrevY) * deltaTime; var deltaSize = PrevSize + (Size - PrevSize) * deltaTime; var deltaAlpha = Math.Min(1, Math.Max(0, PrevAlpha + (Alpha - PrevAlpha) * deltaTime)); var deltaAngle = PrevAngle + (Angle - PrevAngle) * deltaTime; var c = Hue.Create(deltaX / Game.Instance.Width * 360); // GL.PushAttrib(AttribMask.LineBit); GL.PushMatrix(); //GL.LineWidth(deltaSize / StartSize); GL.Translate(deltaX, deltaY, 0); GL.Rotate(deltaAngle, 0, 0, 1); GL.Scale(deltaSize, deltaSize, 0); GL.Begin(PrimitiveType.Polygon); GL.Color4(c.X, c.Y, c.Z, deltaAlpha * 0.15); VertexUtil.PutCircle(0, 0, 1, 20); GL.End(); GL.Begin(PrimitiveType.LineLoop); GL.Color4(c.X, c.Y, c.Z, deltaAlpha); VertexUtil.PutCircle(0, 0, 1, 20); GL.End(); GL.PopMatrix(); //GL.PopAttrib(); }
protected override void OnRenderFrame(FrameEventArgs e) { if (!_canUpdate || _closing) { return; } _desktopFocused = IsDesktopFocused(); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); //GL.ClearColor(0, 0, 0, 0); //GL.Enable(EnableCap.CullFace); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha); GL.BlendEquation(BlendEquationMode.FuncAdd); //GL.CullFace(CullFaceMode.Back); GL.LineWidth(1f); var deltaTime = (float)_updateTimer.Elapsed.TotalMilliseconds / 50; if (Settings.Default.DrawSineWave) { DrawSine(25, 25, 0.5f, Height, deltaTime); } _particleManager.Render(deltaTime); var mouseDown = _down.Contains(MouseButtons.Left); if (mouseDown) { _desktopFocused = IsDesktopFocused(); } if (mouseDown && _desktopFocused) { if (Settings.Default.SpawnOnClick) { SpawnParticles(_lastMouse, 2); } if (Settings.Default.SelectionRect) { var color1 = Hue.Create(_lastMouseDown.X / (float)Width * 360); var color2 = Hue.Create(_lastMouse.X / (float)Width * 360); GL.LineWidth(2f); GL.Begin(PrimitiveType.Polygon); //filled rectangle GL.Color4(color1.X, color1.Y, color1.Z, .2f); GL.Vertex2(_lastMouseDown.X, _lastMouseDown.Y); GL.Vertex2(_lastMouseDown.X, _lastMouse.Y); GL.Color4(color2.X, color2.Y, color2.Z, .2f); GL.Vertex2(_lastMouse.X, _lastMouse.Y); GL.Vertex2(_lastMouse.X, _lastMouseDown.Y); GL.End(); GL.Begin(PrimitiveType.LineLoop); //outline GL.Color4(color1.X, color1.Y, color1.Z, 1f); GL.Vertex2(_lastMouseDown.X, _lastMouseDown.Y); GL.Vertex2(_lastMouseDown.X, _lastMouse.Y); GL.Color4(color2.X, color2.Y, color2.Z, 1f); GL.Vertex2(_lastMouse.X, _lastMouse.Y); GL.Vertex2(_lastMouse.X, _lastMouseDown.Y); GL.End(); //the filled circles GL.Color4(color1.X, color1.Y, color1.Z, 1f); GL.Begin(PrimitiveType.Polygon); VertexUtil.PutCircle(_lastMouseDown.X, _lastMouseDown.Y, 6, 16); GL.End(); GL.Begin(PrimitiveType.Polygon); VertexUtil.PutCircle(_lastMouseDown.X, _lastMouse.Y, 6, 16); GL.End(); GL.Color4(color2.X, color2.Y, color2.Z, 1f); GL.Begin(PrimitiveType.Polygon); VertexUtil.PutCircle(_lastMouse.X, _lastMouse.Y, 6, 16); GL.End(); GL.Begin(PrimitiveType.Polygon); VertexUtil.PutCircle(_lastMouse.X, _lastMouseDown.Y, 6, 16); GL.End(); } } SwapBuffers(); //glEnable GL_ALPHA_TEST //glEnable GL_COLOR_MATERIAL //Transparent-OpenGL-window //glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA }