public void DrawRect(SColorF color, SRectF rect, bool allMonitors = true) { int loops = 1; if (allMonitors) { loops = CConfig.Config.Graphics.NumScreens; } for (int i = 0; i < loops; i++) { SRectF newrect = rect; newrect.X += CSettings.RenderW * i; GL.Enable(EnableCap.Blend); GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); GL.Begin(PrimitiveType.Quads); GL.MatrixMode(MatrixMode.Color); GL.PushMatrix(); if (Math.Abs(newrect.Rotation) > 0.001) { GL.Translate(0.5f, 0.5f, 0); GL.Rotate(-newrect.Rotation, 0f, 0f, 1f); GL.Translate(-0.5f, -0.5f, 0); } GL.Vertex3(newrect.X, newrect.Y, newrect.Z + CGraphics.ZOffset); GL.Vertex3(newrect.X, newrect.Y + newrect.H, newrect.Z + CGraphics.ZOffset); GL.Vertex3(newrect.X + newrect.W, newrect.Y + newrect.H, newrect.Z + CGraphics.ZOffset); GL.Vertex3(newrect.X + newrect.W, newrect.Y, newrect.Z + CGraphics.ZOffset); GL.End(); GL.PopMatrix(); GL.Disable(EnableCap.Blend); } }
public void Render2D() { if (_rect.IsEmpty) { var te = _printer.Measure(_text, SystemFonts.MessageBoxFont, new RectangleF(0, 0, Viewport.Width, Viewport.Height)); _rect = te.BoundingBox; _rect.X += 5; _rect.Y += 2; _rect.Width += 5; _rect.Height += 2; } GL.Disable(EnableCap.CullFace); _printer.Begin(); if (_showing) { GL.Begin(PrimitiveType.Quads); GL.Color3(Viewport is Viewport3D ? View.ViewportBackground : Grid.Background); GL.Vertex2(0, 0); GL.Vertex2(_rect.Right, 0); GL.Vertex2(_rect.Right, _rect.Bottom); GL.Vertex2(0, _rect.Bottom); GL.End(); } _printer.Print(_text, SystemFonts.MessageBoxFont, _showing ? Color.White : Grid.GridLines, _rect); _printer.End(); GL.Enable(EnableCap.CullFace); }
private void MusicCirsle(double x, double y, double begin, double end) { for (int j = 0; j < 5; j++) { GL.Begin(PrimitiveType.TriangleFan); GL.Color4(firstColorSpectr.R, firstColorSpectr.G, firstColorSpectr.B, 0.8); if (j == 0) { spectrRadius[j] += _FFTSpectr[j] * glControl1.Width / 3; } else { spectrRadius[j] += _FFTSpectr[j] * glControl1.Width / Math.Sqrt(j + 10) + spectrRadius[j - 1]; } spectrRadius[j] /= 2; GL.Vertex3(x, y, (double)(1 - 0.1)); for (double i = begin; i < end; i += 0.05) { GL.Color4(secondColorSpectr[j].R, secondColorSpectr[j].G, secondColorSpectr[j].B, 0.8); GL.Vertex3(spectrRadius[j] * Math.Cos(i) + x, spectrRadius[j] * Math.Sin(i) + y, (double)(1 - 0.1)); GL.Vertex3(spectrRadius[j] * Math.Cos(i + 0.01) + x, spectrRadius[j] * Math.Sin(i + 0.01) + y, (double)(1 - 0.1)); } GL.End(); } }
public void DrawRectReflection(SColorF color, SRectF rect, float space, float height) { if (rect.H < height) { height = rect.H; } float rx1 = rect.X; float rx2 = rect.X + rect.W; float ry1 = rect.Y + rect.H + space; float ry2 = rect.Y + rect.H + space + height; if (rx1 < rect.X) { rx1 = rect.X; } if (rx2 > rect.X + rect.W) { rx2 = rect.X + rect.W; } if (ry1 < rect.Y + space) { ry1 = rect.Y + space; } if (ry2 > rect.Y + rect.H + space + height) { ry2 = rect.Y + rect.H + space + height; } GL.Enable(EnableCap.Blend); GL.MatrixMode(MatrixMode.Color); GL.PushMatrix(); if (Math.Abs(rect.Rotation) > 0.001) { GL.Translate(0.5f, 0.5f, 0); GL.Rotate(-rect.Rotation, 0f, 0f, 1f); GL.Translate(-0.5f, -0.5f, 0); } GL.Begin(PrimitiveType.Quads); GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); GL.Vertex3(rx2, ry1, rect.Z + CGraphics.ZOffset); GL.Color4(color.R, color.G, color.B, 0f); GL.Vertex3(rx2, ry2, rect.Z + CGraphics.ZOffset); GL.Vertex3(rx1, ry2, rect.Z + CGraphics.ZOffset); GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); GL.Vertex3(rx1, ry1, rect.Z + CGraphics.ZOffset); GL.End(); GL.PopMatrix(); GL.Disable(EnableCap.Blend); }
public void Draw() { GL.Translate(pos); GL.Begin(PrimitiveType.Quads); { // front face GL.Normal3(0, 0, 1.0f); GL.Vertex3(length * 0.5, -height * 0.5, width * 0.5); GL.Vertex3(length * 0.5 + offsetX, height * 0.5, width * 0.5); GL.Vertex3(-length * 0.5 + offsetX, height * 0.5, width * 0.5); GL.Vertex3(-length * 0.5, -height * 0.5, width * 0.5); // back face GL.Normal3(0, 0, -1.0f); GL.Vertex3(-length * 0.5, -height * 0.5, -width * 0.5); GL.Vertex3(-length * 0.5 + offsetX, height * 0.5, -width * 0.5); GL.Vertex3(length * 0.5 + offsetX, height * 0.5, -width * 0.5); GL.Vertex3(length * 0.5, -height * 0.5, -width * 0.5); // top face GL.Normal3(0f, 1.0f, 0); GL.Vertex3(length * 0.5 + offsetX, height * 0.5, width * 0.5); GL.Vertex3(length * 0.5 + offsetX, height * 0.5, -width * 0.5); GL.Vertex3(-length * 0.5 + offsetX, height * 0.5, -width * 0.5); GL.Vertex3(-length * 0.5 + offsetX, height * 0.5, width * 0.5); // bottom face GL.Normal3(0, -1.0f, 0); GL.Vertex3(-length * 0.5, -height * 0.5, width * 0.5); GL.Vertex3(-length * 0.5, -height * 0.5, -width * 0.5); GL.Vertex3(length * 0.5, -height * 0.5, -width * 0.5); GL.Vertex3(length * 0.5, -height * 0.5, width * 0.5); // right face GL.Normal3(Math.Sin(angle_), -Math.Cos(angle_), 0); GL.Vertex3(length * 0.5, -height * 0.5, -width * 0.5); GL.Vertex3(length * 0.5 + offsetX, height * 0.5, -width * 0.5); GL.Vertex3(length * 0.5 + offsetX, height * 0.5, width * 0.5); GL.Vertex3(length * 0.5, -height * 0.5, width * 0.5); // left face GL.Normal3(-Math.Sin(angle_), Math.Cos(angle_), 0); GL.Vertex3(-length * 0.5, -height * 0.5, width * 0.5); GL.Vertex3(-length * 0.5 + offsetX, height * 0.5, width * 0.5); GL.Vertex3(-length * 0.5 + offsetX, height * 0.5, -width * 0.5); GL.Vertex3(-length * 0.5, -height * 0.5, -width * 0.5); } GL.End(); GL.Translate(-pos); }
public void FillTriangle(RectangleF dstRect) { DrawBegin(dstRect); GL.Begin(PrimitiveType.Triangles); GL.Vertex2(0.0f, dstRect.Height); GL.Vertex2(dstRect.Width * 0.5f, 0); GL.Vertex2(dstRect.Width, dstRect.Height); GL.End(); DrawEnd(); }
public void FillRect(RectangleF dstRect) { DrawBegin(dstRect); GL.Begin(PrimitiveType.Quads); GL.Vertex2(0, 0); GL.Vertex2(dstRect.Width, 0); GL.Vertex2(dstRect.Width, dstRect.Height); GL.Vertex2(0, dstRect.Height); GL.End(); DrawEnd(); }
public void DrawTriangle(RectangleF dstRect) { GL.LineWidth(1.0f); DrawBegin(dstRect); GL.Begin(PrimitiveType.LineLoop); GL.Vertex2(0.0f, dstRect.Height); GL.Vertex2(dstRect.Width * 0.5f, 0); GL.Vertex2(dstRect.Width, dstRect.Height); GL.End(); DrawEnd(); }
void drawCollisionIntervals() { if (view == '0' || picked == -1) { return; } GL.LineWidth(4.0f); colors[picked % (colors.Count())][3] = 0.5f; GL.Color4(colors[picked % (colors.Count())]); Vector3 pos = bodies[picked].getPos(); Sphere bsphere = bodies[picked].getBSphere(); if (view == 'z') { GL.Begin(PrimitiveType.Lines); { GL.Vertex3(pos.X - bsphere.radius, -gizmosOffsetY, 10); GL.Vertex3(pos.X + bsphere.radius, -gizmosOffsetY, 10); GL.Vertex3(-gizmosOffsetX, pos.Y + bsphere.radius, 10); GL.Vertex3(-gizmosOffsetX, pos.Y - bsphere.radius, 10); } GL.End(); } else if (view == 'x') { GL.Begin(PrimitiveType.Lines); { GL.Vertex3(10, -gizmosOffsetY, pos.Z - bsphere.radius); GL.Vertex3(10, -gizmosOffsetY, pos.Z + bsphere.radius); GL.Vertex3(10, pos.Y + bsphere.radius, gizmosOffsetZ); GL.Vertex3(10, pos.Y - bsphere.radius, gizmosOffsetZ); } GL.End(); } else { GL.Begin(PrimitiveType.Lines); { GL.Vertex3(-gizmosOffsetX, 10, pos.Z + bsphere.radius); GL.Vertex3(-gizmosOffsetX, 10, pos.Z - bsphere.radius); GL.Vertex3(pos.X - bsphere.radius, 10, gizmosOffsetZ); GL.Vertex3(pos.X + bsphere.radius, 10, gizmosOffsetZ); } GL.End(); } GL.LineWidth(1.0f); }
protected override void _DrawTexture(COGLTexture texture, SDrawCoords dc, SColorF color, bool isReflection = false) { // Align textures to full pixels to reduce artefacts dc.Wx1 = (float)Math.Round(dc.Wx1); dc.Wy1 = (float)Math.Round(dc.Wy1); dc.Wx2 = (float)Math.Round(dc.Wx2); dc.Wy2 = (float)Math.Round(dc.Wy2); GL.BindTexture(TextureTarget.Texture2D, texture.Name); GL.Enable(EnableCap.Blend); GL.MatrixMode(MatrixMode.Texture); GL.PushMatrix(); if (Math.Abs(dc.Rotation) > float.Epsilon) { GL.Translate(0.5f, 0.5f, 0); GL.Rotate(-dc.Rotation, 0f, 0f, 1f); GL.Translate(-0.5f, -0.5f, 0); } GL.Begin(PrimitiveType.Quads); GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); GL.TexCoord2(dc.Tx1, dc.Ty1); GL.Vertex3(dc.Wx1, dc.Wy1, dc.Wz); if (isReflection) { GL.Color4(color.R, color.G, color.B, 0); } GL.TexCoord2(dc.Tx1, dc.Ty2); GL.Vertex3(dc.Wx1, dc.Wy2, dc.Wz); GL.TexCoord2(dc.Tx2, dc.Ty2); GL.Vertex3(dc.Wx2, dc.Wy2, dc.Wz); if (isReflection) { GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); } GL.TexCoord2(dc.Tx2, dc.Ty1); GL.Vertex3(dc.Wx2, dc.Wy1, dc.Wz); GL.End(); GL.PopMatrix(); GL.Disable(EnableCap.Blend); GL.BindTexture(TextureTarget.Texture2D, 0); }
public void DrawLine(Vector2 from, Vector2 to) { GL.LineWidth(1.0f); var minX = Math.Min(from.X, to.X); var minY = Math.Min(from.Y, to.Y); var minV = new Vector2(minX, minY); var sx = Math.Abs(from.X - to.X); var sy = Math.Abs(from.Y - to.Y); DrawBegin(new RectangleF(minX, minY, sx, sy)); GL.Begin(PrimitiveType.Lines); GL.Vertex2(from - minV); GL.Vertex2(to - minV); GL.End(); DrawEnd(); }
/// <summary> /// Render all the handles as squares or circles depending on class implementation /// </summary> /// <param name="viewport">The viewport to draw in</param> /// <param name="start">The start of the box</param> /// <param name="end">The end of the box</param> private void RenderHandles(Viewport2D viewport, Coordinate start, Coordinate end) { if (_currentTool == null) { return; } var circles = _currentTool.RenderCircleHandles; // Get the filtered list of handles, and convert them to vector locations var z = (double)viewport.Zoom; var handles = _currentTool.GetHandles(start, end, viewport.Zoom) .Where(x => _currentTool.FilterHandle(x.Item1)) .Select(x => new Vector2d((double)x.Item2, (double)x.Item3)) .ToList(); // Draw the insides of the handles in white GL.Color3(Color.White); foreach (var handle in handles) { GL.Begin(BeginMode.Polygon); if (circles) { GLX.Circle(handle, 4, z, loop: true); } else { GLX.Square(handle, 4, z, true); } GL.End(); } // Draw the borders of the handles in black GL.Color3(Color.Black); GL.Begin(BeginMode.Lines); foreach (var handle in handles) { if (circles) { GLX.Circle(handle, 4, z); } else { GLX.Square(handle, 4, z); } } GL.End(); }
public void FillEllipse(RectangleF dstRect) { var w = dstRect.Width / 2.0; var h = dstRect.Height / 2.0; DrawBegin(dstRect); GL.Begin(PrimitiveType.TriangleFan); GL.Vertex2(w, h); for (var i = 0.0; i <= 60.0; i++) { var rad = MathHelper.DegreesToRadians(i * 6.0); var s = Math.Sin(rad); var c = Math.Cos(rad); GL.Vertex2(w + c * w, h + s * h); } GL.End(); DrawEnd(); }
void MusicCirsle(object data) { for (int j = 0; j < 5; j++) { GL.Begin(PrimitiveType.TriangleFan); //GL.Color3(firstColorSpectr); GL.Color4(((tData)data).firstColorSpectr.R, ((tData)data).firstColorSpectr.G, ((tData)data).firstColorSpectr.B, 0.8); // spectrRadius[j] *= 3; if (j == 0) { ((tData)data).spectrRadius[j] += ((tData)data)._FFTSpectr[j] * ((tData)data).glControl1.Width / 3; } else { ((tData)data).spectrRadius[j] += ((tData)data)._FFTSpectr[j] * ((tData)data).glControl1.Width / Math.Sqrt(j + 10) + ((tData)data).spectrRadius[j - 1]; } ((tData)data).spectrRadius[j] /= 2; GL.Vertex3(((tData)data).x, ((tData)data).y, (double)(1 - 0.1 + j / 100)); for (double i = 0; i < 2 * Math.PI; i += 0.01) { //GL.Color3(secondColorSpectr[j]); GL.Color4(secondColorSpectr[j].R, secondColorSpectr[j].G, secondColorSpectr[j].B, 0.8); GL.Vertex3(((tData)data).spectrRadius[j] * Math.Cos(i) + ((tData)data).x, ((tData)data).spectrRadius[j] * Math.Sin(i) + ((tData)data).y, (double)(1 - 0.1 - j / 100)); GL.Vertex3(((tData)data).spectrRadius[j] * Math.Cos(i + 0.01) + ((tData)data).x, ((tData)data).spectrRadius[j] * Math.Sin(i + 0.01) + ((tData)data).y, (double)(1 - 0.1 - j / 100)); } GL.End(); } Console.WriteLine("asdf"); GL.Begin(PrimitiveType.Triangles); GL.Vertex3(0, 0, 0); GL.Vertex3(100, 0, 0); GL.Vertex3(0, 100, 0); GL.End(); }
void DrawImage(int textureID) { GL.MatrixMode(OpenTK.Graphics.OpenGL.MatrixMode.Projection); GL.PushMatrix(); GL.LoadIdentity(); //glOrtho(0.0, glutGet(GLUT_WINDOW_WIDTH), 0.0, glutGet(GLUT_WINDOW_HEIGHT), -1.0, 1.0); GL.MatrixMode(OpenTK.Graphics.OpenGL.MatrixMode.Modelview); GL.PushMatrix(); GL.LoadIdentity(); //GL.Disable(OpenTK.Graphics.OpenGL.EnableCap.Lighting); GL.Color3(1, 1, 1); //GL.Enable(OpenTK.Graphics.OpenGL.EnableCap.Texture2D); //GL.BindTexture(OpenTK.Graphics.OpenGL.EnableCap.Texture2D, textureID); // Draw a textured quad GL.Begin(OpenTK.Graphics.OpenGL.BeginMode.Quads); //GL.TexCoord2(0, 0); GL.Vertex3(0, 0, 1000); //GL.TexCoord2(0, 1); GL.Vertex3(0, 100, 1000); //GL.TexCoord2(1, 1); GL.Vertex3(100, 100, 1000); //GL.TexCoord2(1, 0); GL.Vertex3(100, 0, 1000); GL.End(); //GL.Disable(OpenTK.Graphics.OpenGL.EnableCap.Texture2D); GL.PopMatrix(); GL.MatrixMode(OpenTK.Graphics.OpenGL.MatrixMode.Projection); GL.PopMatrix(); GL.MatrixMode(OpenTK.Graphics.OpenGL.MatrixMode.Modelview); }
public void DrawRect(SColorF color, SRectF rect) { GL.Enable(EnableCap.Blend); GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); GL.Begin(PrimitiveType.Quads); GL.MatrixMode(MatrixMode.Color); GL.PushMatrix(); if (Math.Abs(rect.Rotation) > 0.001) { GL.Translate(0.5f, 0.5f, 0); GL.Rotate(-rect.Rotation, 0f, 0f, 1f); GL.Translate(-0.5f, -0.5f, 0); } GL.Vertex3(rect.X, rect.Y, rect.Z + CGraphics.ZOffset); GL.Vertex3(rect.X, rect.Y + rect.H, rect.Z + CGraphics.ZOffset); GL.Vertex3(rect.X + rect.W, rect.Y + rect.H, rect.Z + CGraphics.ZOffset); GL.Vertex3(rect.X + rect.W, rect.Y, rect.Z + CGraphics.ZOffset); GL.End(); GL.PopMatrix(); GL.Disable(EnableCap.Blend); }
public void Draw() { GL.Normal3(0f, 1f, 0f); GL.Begin(PrimitiveType.Polygon); { GL.Vertex3(vertices[0]); GL.Vertex3(vertices[1]); GL.Vertex3(vertices[2]); } GL.End(); GL.Normal3(-1f, 0f, 0f); GL.Begin(PrimitiveType.Polygon); { GL.Vertex3(vertices[0]); GL.Vertex3(vertices[2]); GL.Vertex3(vertices[3]); } GL.End(); GL.Normal3(0.5f, -0.5f, 0.5f); GL.Begin(PrimitiveType.Polygon); { GL.Vertex3(vertices[0]); GL.Vertex3(vertices[3]); GL.Vertex3(vertices[1]); } GL.End(); GL.Normal3(0f, 0f, -1f); GL.Begin(PrimitiveType.Polygon); { GL.Vertex3(vertices[3]); GL.Vertex3(vertices[2]); GL.Vertex3(vertices[1]); } GL.End(); }
private void RenderTransformBox(Viewport2D viewport) { if (!CurrentTransform.HasValue) { return; } var box = new Box(State.PreTransformBoxStart, State.PreTransformBoxEnd); var trans = CreateMatrixMultTransformation(CurrentTransform.Value); box = box.Transform(trans); var s = viewport.Flatten(box.Start); var e = viewport.Flatten(box.End); GL.Enable(EnableCap.LineStipple); GL.LineStipple(10, 0xAAAA); GL.Begin(PrimitiveType.Lines); GL.Color4(Color.FromArgb(64, BoxColour)); Coord(s.DX, s.DY, e.DZ); Coord(e.DX, s.DY, e.DZ); Coord(s.DX, e.DY, e.DZ); Coord(e.DX, e.DY, e.DZ); Coord(s.DX, s.DY, e.DZ); Coord(s.DX, e.DY, e.DZ); Coord(e.DX, s.DY, e.DZ); Coord(e.DX, e.DY, e.DZ); GL.End(); GL.Disable(EnableCap.LineStipple); RenderBoxText(viewport, s, e); }
public void Draw() { GL.Begin(PrimitiveType.Polygon); { GL.Vertex3(vertices[0]); GL.Vertex3(vertices[1]); GL.Vertex3(vertices[2]); } GL.End(); GL.Begin(PrimitiveType.Polygon); { GL.Vertex3(vertices[0]); GL.Vertex3(vertices[2]); GL.Vertex3(vertices[3]); } GL.End(); GL.Begin(PrimitiveType.Polygon); { GL.Vertex3(vertices[0]); GL.Vertex3(vertices[3]); GL.Vertex3(vertices[4]); } GL.End(); GL.Begin(PrimitiveType.Polygon); { GL.Vertex3(vertices[0]); GL.Vertex3(vertices[4]); GL.Vertex3(vertices[1]); } GL.End(); GL.Begin(PrimitiveType.Polygon); { GL.Vertex3(vertices[5]); GL.Vertex3(vertices[1]); GL.Vertex3(vertices[2]); } GL.End(); GL.Begin(PrimitiveType.Polygon); { GL.Vertex3(vertices[5]); GL.Vertex3(vertices[2]); GL.Vertex3(vertices[3]); } GL.End(); GL.Begin(PrimitiveType.Polygon); { GL.Vertex3(vertices[5]); GL.Vertex3(vertices[3]); GL.Vertex3(vertices[4]); } GL.End(); GL.Begin(PrimitiveType.Polygon); { GL.Vertex3(vertices[5]); GL.Vertex3(vertices[4]); GL.Vertex3(vertices[1]); } GL.End(); }
private void GlPaint(object sender, PaintEventArgs e) { if (!_glLoaded) { return; } // Color fonColor = Color.FromArgb(_soundColor.R, _soundColor.B, 0); _fonStrong = ((_fonStrong * 3) + _total) / 4; if (_fonStrong > 1) { _fonStrong = 1; } Color fonColor = Color.FromArgb((int)(255 * _fonStrong), (int)(255 * _fonStrong), (int)(255 * _fonStrong * 0.2)); GL.ClearColor(fonColor); // GL.ClearColor(1f, 1f, 1f, 1f); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.LoadIdentity(); GL.Disable(EnableCap.Lighting); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); //Прорисoвка круга if (Visual1.Colors.Count >= 10) { Color spin = new Color(); GL.Begin(PrimitiveType.TriangleFan); GL.Color3(Visual1.Colors[0]); GL.Color4(Visual1.Colors[0].R, Visual1.Colors[0].G, Visual1.Colors[0].B, (double)0.5); GL.Color4(Color.FromArgb(Visual1.Colors[0].A * 0, Visual1.Colors[0].R, Visual1.Colors[0].G, Visual1.Colors[0].B)); GL.Vertex3(-0, -0, -1); GL.Vertex3(Visual1.Coordinates[0].X, Visual1.Coordinates[0].Y, -1); for (int i = 0; i < Visual1.Coordinates.Count; i++) { if ((i % 4 == 0) && (i > 0)) { GL.End(); GL.Begin(PrimitiveType.TriangleFan); GL.Vertex3(-0, -0, (float)((double)i / Visual1.Coordinates.Count / 2 - 1)); for (int j = i - 3; j < i; j++) { GL.Vertex3(-Visual1.Coordinates[j - 1].X, -Visual1.Coordinates[j - 1].Y, (float)((double)j / Visual1.Coordinates.Count / 2 - 1)); } GL.End(); GL.Begin(PrimitiveType.TriangleFan); GL.Vertex3(-0, -0, (float)((double)i / Visual1.Coordinates.Count / 2 - 1)); GL.Vertex3(Visual1.Coordinates[i - 1].X, Visual1.Coordinates[i - 1].Y, (float)((double)i / Visual1.Coordinates.Count / 2 - 1)); } GL.Color3(Visual1.Colors[i]); GL.Color4(Visual1.Colors[i].R, Visual1.Colors[i].G, Visual1.Colors[i].B, (double)0.5); GL.Color4(Color.FromArgb((int)((double)i / Visual1.Coordinates.Count * TR * 255), Visual1.Colors[i].R, Visual1.Colors[i].G, Visual1.Colors[i].B)); GL.Vertex3(Visual1.Coordinates[i].X, Visual1.Coordinates[i].Y, (float)((double)i / Visual1.Coordinates.Count / 2 - 1)); } GL.End(); } //////конец прорисовки круга float[] diffuse = new float[3] { 0.5f, 0.5f, 0.5f }; GL.Light(LightName.Light0, LightParameter.Diffuse, diffuse); float[] ambient = new float[3] { 4, 4, 4 }; GL.Light(LightName.Light0, LightParameter.Ambient, ambient); float[] lightPos = new float[4] { -glControl1.Width, 0.0f, 10.0f, 1.0f }; GL.Light(LightName.Light0, LightParameter.Position, lightPos); float[] specular = new float[4] { 10, 10, 10, 1 }; GL.Light(LightName.Light0, LightParameter.Specular, specular); GL.Enable(EnableCap.Lighting); GL.Enable(EnableCap.Light0); GL.LightModel(LightModelParameter.LightModelTwoSide, 1); //звуковой спектр снизу в виде диаграмм Random rand = new Random(); for (int color = 0; color < 5; color++) { LoadTexture(bmpTex[color]); for (int j = 0; j < 50; j++) { if (_FFTnum[j] - 1 != color) { continue; } GL.Enable(EnableCap.Texture2D); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); GL.PolygonMode(MaterialFace.FrontAndBack, mode); GL.Begin(PrimitiveType.QuadStrip); double w = glControl1.Width / 25; float k = 0.5f; double r = 0.5; int n = 20; for (int i = 0; i <= n; ++i) { double a = Math.PI / n * i; double x = r * Math.Cos(a); double z = r * Math.Sin(a); GL.TexCoord2(0, 1); GL.Vertex3(x * w + w * j + (w / 2) - glControl1.Width, -glControl1.Height * (1 - _FFTSpectr[_FFTnum[j] - 1]), z); GL.TexCoord2(1, 0); GL.Vertex3(x * w + w * j + (w / 2) - glControl1.Width, -glControl1.Height, z); if (i > 0) { GL.Normal3(-(x - r * Math.Cos(a - 1)), (x - r * Math.Cos(a - 1)), 0); } } GL.End(); } } GL.Disable(EnableCap.Lighting); GL.Disable(EnableCap.Texture2D); //myThread t1 = new myThread("Thread 1", glControl1.Width, glControl1.Height, firstColorSpectr, spectrRadius, // _FFTSpectr, glControl1); //myThread t2 = new myThread("Thread 1", -glControl1.Width, glControl1.Height, firstColorSpectr, spectrRadius, // _FFTSpectr, glControl1); //myThread t3 = new myThread("Thread 1", glControl1.Width, -glControl1.Height, firstColorSpectr, spectrRadius, // _FFTSpectr, glControl1); //myThread t4 = new myThread("Thread 1", -glControl1.Width, -glControl1.Height, firstColorSpectr, spectrRadius, // _FFTSpectr, glControl1); MusicCirsle(glControl1.Width, glControl1.Height, Math.PI, 3 * Math.PI / 2); MusicCirsle(-glControl1.Width, glControl1.Height, 3 * Math.PI / 2, 2 * Math.PI); MusicCirsle(glControl1.Width, -glControl1.Height, Math.PI / 2, 2 * Math.PI); MusicCirsle(-glControl1.Width, -glControl1.Height, 0, Math.PI / 2); //GL.Disable(EnableCap.Lighting); GL.Disable(EnableCap.Blend); GL.Flush(); //GL.Finish(); glControl1.SwapBuffers(); }
void DrawGrid() { int half_fov = fov / 2; float offset; GL.Color4(1f, 0f, 0f, 1f); //grid y GL.Begin(PrimitiveType.LineLoop); { GL.Vertex3(-half_fov, -half_fov, half_fov); GL.Vertex3(half_fov, -half_fov, half_fov); GL.Vertex3(half_fov, -half_fov, -half_fov); GL.Vertex3(-half_fov, -half_fov, -half_fov); } GL.End(); for (int i = 1; i < tiles; i++) { offset = (float)grid_edge * i; GL.Begin(PrimitiveType.Lines); { GL.Vertex3(offset - half_fov, -half_fov, half_fov); GL.Vertex3(offset - half_fov, -half_fov, -half_fov); GL.Vertex3(-half_fov, -half_fov, offset - half_fov); GL.Vertex3(half_fov, -half_fov, offset - half_fov); } GL.End(); } GL.Color4(0f, 1f, 0f, 1f); //grid x GL.Begin(PrimitiveType.LineLoop); { GL.Vertex3(-half_fov, half_fov, half_fov); GL.Vertex3(-half_fov, half_fov, -half_fov); GL.Vertex3(-half_fov, -half_fov, -half_fov); GL.Vertex3(-half_fov, -half_fov, half_fov); } GL.End(); for (int i = 1; i < tiles; i++) { offset = (float)grid_edge * i; GL.Begin(PrimitiveType.Lines); { GL.Vertex3(-half_fov, -half_fov, offset - half_fov); GL.Vertex3(-half_fov, half_fov, offset - half_fov); GL.Vertex3(-half_fov, offset - half_fov, half_fov); GL.Vertex3(-half_fov, offset - half_fov, -half_fov); } GL.End(); } GL.Color4(0f, 0f, 1f, 1f); //grid z GL.Begin(PrimitiveType.LineLoop); { GL.Vertex3(-half_fov, -half_fov, -half_fov); GL.Vertex3(half_fov, -half_fov, -half_fov); GL.Vertex3(half_fov, half_fov, -half_fov); GL.Vertex3(-half_fov, half_fov, -half_fov); } GL.End(); for (int i = 1; i < tiles; i++) { offset = (float)grid_edge * i; GL.Begin(PrimitiveType.Lines); { GL.Vertex3(offset - half_fov, -half_fov, -half_fov); GL.Vertex3(offset - half_fov, half_fov, -half_fov); GL.Vertex3(-half_fov, offset - half_fov, -half_fov); GL.Vertex3(half_fov, offset - half_fov, -half_fov); } GL.End(); } }
public void Draw() { GL.PolygonMode(TK.MaterialFace.FrontAndBack, TK.PolygonMode.Fill); GL.Begin(PrimitiveType.Polygon); { GL.Vertex3(vertices[0]); GL.Vertex3(vertices[1]); GL.Vertex3(vertices[2]); GL.Vertex3(vertices[3]); GL.Vertex3(vertices[4]); } GL.End(); GL.Begin(PrimitiveType.Polygon); { GL.Vertex3(vertices[0]); GL.Vertex3(vertices[1]); GL.Vertex3(vertices[6]); GL.Vertex3(vertices[10]); GL.Vertex3(vertices[5]); } GL.End(); GL.Begin(PrimitiveType.Polygon); { GL.Vertex3(vertices[1]); GL.Vertex3(vertices[2]); GL.Vertex3(vertices[7]); GL.Vertex3(vertices[11]); GL.Vertex3(vertices[6]); } GL.End(); GL.Begin(PrimitiveType.Polygon); { GL.Vertex3(vertices[2]); GL.Vertex3(vertices[3]); GL.Vertex3(vertices[8]); GL.Vertex3(vertices[12]); GL.Vertex3(vertices[7]); } GL.End(); GL.Begin(PrimitiveType.Polygon); { GL.Vertex3(vertices[3]); GL.Vertex3(vertices[4]); GL.Vertex3(vertices[9]); GL.Vertex3(vertices[13]); GL.Vertex3(vertices[8]); } GL.End(); GL.Begin(PrimitiveType.Polygon); { GL.Vertex3(vertices[4]); GL.Vertex3(vertices[0]); GL.Vertex3(vertices[5]); GL.Vertex3(vertices[14]); GL.Vertex3(vertices[9]); } GL.End(); GL.Begin(PrimitiveType.Polygon); { GL.Vertex3(vertices[15]); GL.Vertex3(vertices[16]); GL.Vertex3(vertices[11]); GL.Vertex3(vertices[6]); GL.Vertex3(vertices[10]); } GL.End(); GL.Begin(PrimitiveType.Polygon); { GL.Vertex3(vertices[16]); GL.Vertex3(vertices[17]); GL.Vertex3(vertices[12]); GL.Vertex3(vertices[7]); GL.Vertex3(vertices[11]); } GL.End(); GL.Begin(PrimitiveType.Polygon); { GL.Vertex3(vertices[17]); GL.Vertex3(vertices[18]); GL.Vertex3(vertices[13]); GL.Vertex3(vertices[8]); GL.Vertex3(vertices[12]); } GL.End(); GL.Begin(PrimitiveType.Polygon); { GL.Vertex3(vertices[18]); GL.Vertex3(vertices[19]); GL.Vertex3(vertices[14]); GL.Vertex3(vertices[9]); GL.Vertex3(vertices[13]); } GL.End(); GL.Begin(PrimitiveType.Polygon); { GL.Vertex3(vertices[19]); GL.Vertex3(vertices[15]); GL.Vertex3(vertices[10]); GL.Vertex3(vertices[5]); GL.Vertex3(vertices[14]); } GL.End(); GL.Begin(PrimitiveType.Polygon); { GL.Vertex3(vertices[15]); GL.Vertex3(vertices[16]); GL.Vertex3(vertices[17]); GL.Vertex3(vertices[18]); GL.Vertex3(vertices[19]); } GL.End(); }