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); }
static void DrawRight(double height, int x, int y, Color col, double sideheight) { var c2 = Color.FromArgb(col.A, (int)(col.R * 0.8), (int)(col.G * 0.8), (int)(col.B * 0.8)); var c3 = Color.FromArgb(col.A, (int)(col.R * 0.9), (int)(col.G * 0.9), (int)(col.B * 0.9)); GL.Color3(c2); GL.Vertex3(x + 0.5, y + 0.5, height); GL.Vertex3(x + 0.5, y - 0.5, height); GL.Color3(c3); GL.Vertex3(x + 0.5, y - 0.5, sideheight); GL.Vertex3(x + 0.5, y + 0.5, sideheight); }
/// <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(); }
static void DrawTop(double height, int x, int y, Color col) { //var h = -height * 0.25; //double dx = 0, dy = 0; //dx += (x / 2.0) + (y / -2.0); //dy += (y / 4.0) + (x / 4.0); GL.Color3(col); //GL.Vertex3(dx, -0.25 + h + dy, 0); //GL.Vertex3(0.5 + dx, dy + h, 0); //GL.Vertex3(dx, 0.25 + h + dy, 1); //GL.Vertex3(-0.5 + dx, dy + h, 1); GL.Vertex3(x + 0.5, y + 0.5, height); GL.Vertex3(x + 0.5, y - 0.5, height); GL.Vertex3(x - 0.5, y - 0.5, height); GL.Vertex3(x - 0.5, y + 0.5, height); }
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); }
protected override void OnRenderFrame(FrameEventArgs e) { base.OnRenderFrame(e); #if TEST #else GL.Clear(TK.ClearBufferMask.DepthBufferBit | TK.ClearBufferMask.ColorBufferBit); if (ortho) { modelView = Matrix4.CreateOrthographic(width, height, -height, height); GL.MatrixMode(TK.MatrixMode.Projection); GL.PushMatrix(); GL.LoadMatrix(ref modelView); GL.Scale(scale_factor, scale_factor, scale_factor); } else { modelView = Matrix4.LookAt(eye, target, up); GL.MatrixMode(TK.MatrixMode.Modelview); GL.PushMatrix(); GL.LoadMatrix(ref modelView); } GL.PushMatrix(); GL.Rotate(offsetX, 0.0f, 1.0f, 0.0f); GL.Rotate(offsetY, 1.0f, 0.0f, 0.0f); DrawGrid(); #region Draw 3D Polyhedrons GL.Color3(0.0, 0.5, 1.0); GL.Enable(TK.EnableCap.Light0); GL.Enable(TK.EnableCap.Lighting); int i = 0; foreach (Body body in bodies) { float[] color = colors[i % colors.Count()]; color[3] = 0.9f; GL.Color4(color); body.Draw(); color[3] = 0.25f; GL.Color4(color); body.getBSphere().Draw(); i++; } if (picked != -1) { GL.Color3(colors[picked % colors.Count()]); GL.PolygonMode(TK.MaterialFace.FrontAndBack, TK.PolygonMode.Line); foreach (Body body in bodies.ElementAt(picked).getBSphere().cells) { body.Draw(); } GL.PolygonMode(TK.MaterialFace.FrontAndBack, TK.PolygonMode.Fill); } GL.Disable(TK.EnableCap.Lighting); GL.Disable(TK.EnableCap.Light0); #endregion #region Draw Gizmos drawCollisionIntervals(); #endregion GL.PopMatrix(); GL.PopMatrix(); SwapBuffers(); showFPS(); //showInfo(); #endif }
public static void Color3(Vector3 color) { GL.Color3(color.X, color.Y, color.Z); }
#pragma warning disable 3019 #pragma warning disable 1591 #pragma warning disable 1572 #pragma warning disable 1573 // Note: Mono 1.9.1 truncates StringBuilder results (for 'out string' parameters). // We work around this issue by doubling the StringBuilder capacity. #region public static void Color[34]() overloads public static void Color3(System.Drawing.Color color) { GL.Color3(color.R, color.G, color.B); }
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(); }
#pragma warning disable 3019 #pragma warning disable 1591 #pragma warning disable 1572 #pragma warning disable 1573 // Note: Mono 1.9.1 truncates StringBuilder results (for 'out string' parameters). // We work around this issue by doubling the StringBuilder capacity. #region public static void Color[34]() overloads public static void Color3(Color color) { GL.Color3(color.R, color.G, color.B); }