private void DrawSquare() { if (square.Point1X == 0f && square.Point1Y == 0f && square.Point2X == 0f && square.Point2Y == 0f) { return; } Gl.PushMatrix(); Gl.LoadIdentity(); Gl.Translate(Wight / 2 + moveX, -Height / 2 - moveY, -1f); Gl.Begin(OpenGL.GL_LINE_STRIP); Gl.Color(0f, 0f, 0f); Gl.Vertex(square.Point1X, square.Point1Y); Gl.Vertex(square.Point2X, square.Point1Y); Gl.Vertex(square.Point2X, square.Point2Y); Gl.Vertex(square.Point1X, square.Point2Y); Gl.Vertex(square.Point1X, square.Point1Y); Gl.End(); Gl.PopMatrix(); }
public void Test_Draw() { //moveX = 20000; //moveY = -20000; //Gl.Translate(moveX * c * kX, -moveY * c * kY, -1f); Gl.Translate(moveX, -moveY, -1f); double _scale = Scale; Gl.Scale(_scale, _scale, 1.0); Gl.Color(0f, 1f, 0f); Gl.Begin(OpenGL.GL_LINE_STRIP); Gl.Vertex(2d, -1000000); Gl.Vertex(2d, 1000000); Gl.End(); Gl.Color(0f, 0f, 1f); Gl.Begin(OpenGL.GL_LINE_STRIP); Gl.Vertex(500d, 0); Gl.Vertex(15000d, 1000000); Gl.End(); Gl.Color(1f, 0f, 0f); Gl.Begin(OpenGL.GL_LINE_STRIP); Gl.Vertex(-1000000, 2); //659 Gl.Vertex(1000000, 2); Gl.End(); }
public void DrawRectangle(Pen pen, RectangleF r) { Gl.PolygonMode(Gl.GL_FRONT, Gl.GL_LINE); Gl.LineWidth(pen.Width); Gl.Color(pen.Color); Gl.Begin(Gl.GL_QUADS); Gl.Vertex(r.Left, r.Top); Gl.Vertex(r.Left, r.Bottom); Gl.Vertex(r.Right, r.Bottom); Gl.Vertex(r.Right, r.Top); Gl.End(); }
private void Draw_grid() { double intervalY = Height / 6; double intervalX = Wight / 7; Gl.PushMatrix(); Gl.LoadIdentity(); Gl.Translate(Wight / 2, -Height / 2, -1f); // Указываем цвет вершин Gl.Color(0.8f, 0.8f, 0.8f); for (int j = 1; j <= 7; j++) { Gl.Begin(OpenGL.GL_LINE_STRIP); Gl.Vertex((intervalX * j - Wight * 0.5), -Height / 2); Gl.Vertex((intervalX * j - Wight * 0.5), Height / 2); Gl.End(); } for (int j = 1; j <= 6; j++) { Gl.Begin(OpenGL.GL_LINE_STRIP); Gl.Vertex(-Wight / 2, (-intervalY * j + Height * 0.5)); Gl.Vertex(Wight / 2, (-intervalY * j + Height * 0.5)); Gl.End(); } Gl.Color(0f, 0f, 0f); Gl.DrawText(0, (int)intervalY * 5, 0, 0, 0, "", 11, ((-intervalY * 1 + moveY + Height * 0.5) / ScaleY).ToString("N3")); Gl.DrawText(0, (int)intervalY * 4, 0, 0, 0, "", 11, ((-intervalY * 2 + moveY + Height * 0.5) / ScaleY).ToString("N3")); Gl.DrawText(0, (int)intervalY * 3, 0, 0, 0, "", 11, ((-intervalY * 3 + moveY + Height * 0.5) / ScaleY).ToString("N3")); Gl.DrawText(0, (int)intervalY * 2, 0, 0, 0, "", 11, ((-intervalY * 4 + moveY + Height * 0.5) / ScaleY).ToString("N3")); Gl.DrawText(0, (int)intervalY * 1, 0, 0, 0, "", 11, ((-intervalY * 5 + moveY + Height * 0.5) / ScaleY).ToString("N3")); Gl.DrawText((int)intervalX * 1, 0, 0, 0, 0, "", 11, ((intervalX * 1 - moveX - Wight * 0.5) / (ScaleX * 1000)).ToString("N3")); Gl.DrawText((int)intervalX * 2, 0, 0, 0, 0, "", 11, ((intervalX * 2 - moveX - Wight * 0.5) / (ScaleX * 1000)).ToString("N3")); Gl.DrawText((int)intervalX * 3, 0, 0, 0, 0, "", 11, ((intervalX * 3 - moveX - Wight * 0.5) / (ScaleX * 1000)).ToString("N3")); Gl.DrawText((int)intervalX * 4, 0, 0, 0, 0, "", 11, ((intervalX * 4 - moveX - Wight * 0.5) / (ScaleX * 1000)).ToString("N3")); Gl.DrawText((int)intervalX * 5, 0, 0, 0, 0, "", 11, ((intervalX * 5 - moveX - Wight * 0.5) / (ScaleX * 1000)).ToString("N3")); Gl.DrawText((int)intervalX * 6, 0, 0, 0, 0, "", 11, ((intervalX * 6 - moveX - Wight * 0.5) / (ScaleX * 1000)).ToString("N3")); Gl.PopMatrix(); }
private void Draw_Markers() { int s = 0; Gl.Color(1f, 0f, 0f); foreach (double mark in markers.LMarkers) { s++; Gl.Begin(OpenGL.GL_LINE_STRIP); //Gl.Color(0f, 0f, 0f); Gl.Vertex(mark * 1000, (-Height / 2 + moveY) / ScaleY); Gl.Vertex(mark * 1000, (Height / 2 + moveY) / ScaleY); //Gl.Vertex(0.001, -Height / 2 + moveY); //Gl.Vertex(0.001, Height / 2 + moveY); Gl.End(); } }
public void DrawImage(GlImage image, float x, float y, float w, float h, float ix, float iy, float iw, float ih) { if (ix < 0) { x += -w * ix / iw; ix = 0; } if (ix + iw > image.Width) { w -= (ix + iw - image.Width) * w / iw; iw = image.Width - ix; } if (iy < 0) { y += -h * iy / ih; iy = 0; } if (iy + ih > image.Height) { h -= (iy + ih - image.Height) * h / ih; ih = image.Height - iy; } Gl.UseProgram(image.ShaderProgram); Gl.ActiveTexture(Gl.GL_TEXTURE0); Gl.BindTexture(Gl.GL_TEXTURE_2D, image.Id); Gl.Uniform1(Gl.GetUniformLocation(image.ShaderProgram, "tex"), 0); var vert = (uint)Gl.GetAttribLocation(image.ShaderProgram, "vert"); var tvert = (uint)Gl.GetAttribLocation(image.ShaderProgram, "vertTexCoord"); var projectionMatrix = new float[16]; Gl.GetFloat(Gl.GL_PROJECTION_MATRIX, projectionMatrix); Gl.UniformMatrix4(Gl.GetUniformLocation(image.ShaderProgram, "projectionMatrix"), 1, false, projectionMatrix); Gl.PolygonMode(Gl.GL_FRONT, Gl.GL_FILL); Gl.Color(Color.Transparent); Gl.Enable(Gl.GL_TEXTURE_2D); Gl.Begin(Gl.GL_QUADS); Gl.VertexAttrib2(vert, x, y); Gl.VertexAttrib2(tvert, ix / image.Width, iy / image.Height); Gl.VertexAttrib2(vert, x, y + h); Gl.VertexAttrib2(tvert, ix / image.Width, (iy + ih) / image.Height); Gl.VertexAttrib2(vert, x + w, y + h); Gl.VertexAttrib2(tvert, (ix + iw) / image.Width, (iy + ih) / image.Height); Gl.VertexAttrib2(vert, x + w, y); Gl.VertexAttrib2(tvert, (ix + iw) / image.Width, iy / image.Height); Gl.End(); Gl.Disable(Gl.GL_TEXTURE_2D); Gl.BindTexture(Gl.GL_TEXTURE_2D, 0); Gl.UseProgram(0); Gl.Flush(); }
public void Draw() { //if (Selected == null) // return; Initialize(); if (Arr == null) { return; } //Gl.Color(1.0f, 0, 0); // Двигаем перо вглубь экрана //moveX = 100; //moveY = 100; //Gl.Translate(moveX * c * kX, -moveY * c * kY, -1f); //Gl.Color(0f, 1f, 0f); //Gl.Begin(OpenGL.GL_LINE_STRIP); //Gl.Vertex(1, -1000000); //Gl.Vertex(1, 1000000); //Gl.End(); //Gl.Color(1f, 0f, 0f); //Gl.Begin(OpenGL.GL_LINE_STRIP); //Gl.Vertex(-1000000, 0); //659 //Gl.Vertex(1000000, 0); //Gl.End(); Draw_grid(); //Gl.Color(0.7f, 0f, 0.7f); //Gl.Begin(OpenGL.GL_LINE_STRIP); //Gl.Vertex(10, -1000000d); //Gl.Vertex(10, 1000000d); //Gl.End(); Draw_Markers(); // Указываем цвет вершин Gl.Color(0f, 0f, 1f); int i = 0; double[,] colors = new double[5, 3] { { 0d, 0d, 1d }, { 0d, 1d, 0d }, { 0.8d, 0.8d, 0d }, { 0.8d, 0d, 0.8d }, { 0d, 0.8d, 0.8d }, }; //for(int j = 0; j < 6; j++) //{ // colors[j, 0] = 1d; //} //for (int j = 0; j < Arr.y.Count; j++) //Arr.y.Count int t = 0; foreach (double[] d in Arr.y) { Gl.Begin(OpenGL.GL_LINE_STRIP); Gl.Color((float)colors[t, 0], (float)colors[t, 1], (float)colors[t, 2], 0.9f); for (i = 0; i < Arr.n; i++) { //if (i == h) { h = 9999; } //double y = //Gl.Vertex(i * 0.25 * Scale, Math.Sin(i * 0.25) * Scale); Gl.Vertex(Arr.x[i], d[i]); } Gl.End(); t++; } if (square.Visible) { DrawSquare(); } //for (i = 0; i < 100; i++) //{ // Gl.Vertex((Selected.x[999] + i * 1000 + 1000)* Scale * 45, Selected.y[999] * Scale); //} Gl.PushMatrix(); Gl.LoadIdentity(); Gl.Translate(Wight / 2 + moveX, -Height / 2 - moveY, -1f); Gl.Color(0f, 0f, 0f); Gl.Begin(OpenGL.GL_LINE_STRIP); Gl.Vertex(-Wight / 2 - moveX, 0d); //1276 Gl.Vertex(Wight / 2 - moveX, 0d); Gl.End(); Gl.Begin(OpenGL.GL_LINE_STRIP); Gl.Vertex(0d, -Height / 2 + moveY); //659 Gl.Vertex(0d, Height / 2 + moveY); Gl.End(); Gl.PopMatrix(); Gl.Flush(); }