Example #1
0
        static public void DrawCenterText(int y, string text, IntPtr font)
        {
            int x = Glut.glutBitmapLength(font, text);

            x = Globals.ScreenWidthOver2 - x / 2;
            Gl.glRasterPos2f(x, y);
            for (int i = 0; i < text.Length; i++)
            {
                Glut.glutBitmapCharacter(font, text[i]);
            }
        }
Example #2
0
        static public void DrawCenterText(int y, string text, IntPtr font, Color color)
        {
            Gl.glColor3ub(color.R, color.G, color.B);
            int x = Glut.glutBitmapLength(font, text);

            x = Globals.ScreenWidthOver2 - x / 2;
            Gl.glRasterPos2f(x, y);
            for (int i = 0; i < text.Length; i++)
            {
                Glut.glutBitmapCharacter(font, text[i]);
            }
            Gl.glColor3f(1, 1, 1);
        }
Example #3
0
        static void Write(string str, float x, float y, int r, int g, int b, float size)
        {
            Gl.glPushMatrix();
            Gl.glColor3f(r, g, b);
            Glut.glutBitmapLength(Glut.GLUT_BITMAP_8_BY_13, str);
            Gl.glRasterPos2f(x, y);

            for (int i = 0; i < str.Length; i++)
            {
                Glut.glutBitmapCharacter(Glut.GLUT_BITMAP_8_BY_13, str[i]);
            }

            Gl.glPopMatrix();
        }
        public void DrawSystem()
        {
            if (n > 0)
            {
                // очищаем буфер цвета
                Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);

                // очищаем текущую матрицу
                Gl.glLoadIdentity();

                // устанавливаем текущий цвет - красный
                Gl.glColor3i(0, 0, 0);

                //отрисовка ограничивающего прямоугольника

                Gl.glBegin(Gl.GL_LINE);
                Gl.glVertex2d(min_x, min_y);
                Gl.glVertex2d(max_x, min_y);
                Gl.glVertex2d(max_x, max_y);
                Gl.glVertex2d(min_x, max_y);
                Gl.glEnd();


                int    i, j;
                double x1, x2, y1, y2;
                double hx5, hy5;

                //чёрточки жирные
                Gl.glLineWidth(1);
                Gl.glBegin(Gl.GL_LINES);

                //ось oy
                hx5 = hx / 5.0;
                hy5 = hy / 5.0;
                //левая часть прямоугольника
                x1 = x2 = min_x;
                double lsx;
                lsx = 11 * prx;
                x1  = x1 - lsx / 2;
                x2  = x2 + lsx / 2;

                Gl.glVertex2d((x1 + x2) / 2, min_y);
                Gl.glVertex2d((x1 + x2) / 2, max_y);

                for (j = 0; j < ny + 1; j++)
                {
                    //крупная чёрточка
                    y2 = y1 = min_y + j * hy;
                    Gl.glVertex2d(x1, y1);
                    Gl.glVertex2d(x2, y2);

                    //мелкие чёрточки
                    if (j < ny)
                    {
                        for (i = 1; i < 5; i++)
                        {
                            y2 = y1 = min_y + j * hy + i * hy5;
                            Gl.glVertex2d(min_x + lsx / 4, y1);
                            Gl.glVertex2d(min_x - lsx / 4, y2);
                        }
                    }
                }

                //правая часть прямоугольника
                x1 = x2 = max_x;
                x2 = x2 - lsx / 2;

                Gl.glVertex2d(x1, min_y);
                Gl.glVertex2d(x1, max_y);

                for (j = 0; j < ny + 1; j++)
                {
                    y2 = y1 = min_y + j * hy;
                    Gl.glVertex2d(x1, y1);
                    Gl.glVertex2d(x2, y2);

                    //мелкие чёрточки
                    if (j < ny)
                    {
                        for (i = 1; i < 5; i++)
                        {
                            y2 = y1 = min_y + j * hy + i * hy5;
                            Gl.glVertex2d(max_x - lsx / 4, y1);
                            Gl.glVertex2d(max_x, y2);
                        }
                    }
                }

                //ось ox

                //нижняя часть прямоугольника
                double lsy;
                lsy = pry * 11;
                y1  = y2 = min_y;
                y1  = y1 - lsy / 2;
                y2  = y2 + lsy / 2;
                Gl.glVertex2d(min_x, (y1 + y2) / 2);
                Gl.glVertex2d(max_x, (y1 + y2) / 2);
                for (j = 0; j < nx + 1; j++)
                {
                    x2 = x1 = min_x + j * hx;
                    Gl.glVertex2d(x1, y1);
                    Gl.glVertex2d(x2, y2);

                    //мелкие чёрточки
                    if (j < nx)
                    {
                        for (i = 1; i < 5; i++)
                        {
                            x2 = x1 = min_x + j * hx + i * hx5;
                            Gl.glVertex2d(x1, min_y - lsy / 4);
                            Gl.glVertex2d(x2, min_y + lsy / 4);
                        }
                    }
                }

                //верхняя часть прямоугольника
                y1 = y2 = max_y;
                y2 = y2 - lsy / 2;
                Gl.glVertex2d(min_x, max_y);
                Gl.glVertex2d(max_x, max_y);
                for (j = 0; j < nx + 1; j++)
                {
                    x2 = x1 = min_x + j * hx;
                    Gl.glVertex2d(x1, y1);
                    Gl.glVertex2d(x2, y2);
                    //мелкие чёрточки
                    if (j < nx)
                    {
                        for (i = 1; i < 5; i++)
                        {
                            x2 = x1 = min_x + j * hx + i * hx5;
                            Gl.glVertex2d(x1, max_y - lsy / 2);
                            Gl.glVertex2d(x2, max_y);
                        }
                    }
                }

                Gl.glEnd();

                //надписи
                //ось oy
                string value;
                int    hmark, lmark;
                hmark = Glut.glutBitmapHeight(Glut.GLUT_BITMAP_HELVETICA_18);

                x1 = min_x;
                for (j = 0; j < ny + 1; j++)
                {
                    //значение
                    y1    = min_y + j * hy - 5 * pry;
                    value = (Math.Round((min_y + j * hy), Convert.ToInt32(Math.Abs(pow_x) + 1))).ToString();
                    lmark = Glut.glutBitmapLength(Glut.GLUT_BITMAP_HELVETICA_18, value);
                    Gl.glRasterPos2d(x1 - lmark * prx - 6 * prx, y1);    // Set the position for the string (text)
                    Glut.glutBitmapString(Glut.GLUT_BITMAP_HELVETICA_18, value);
                }
                //подпись оси oy
                //y1 = min_y + j * hy - 5 * pry;
                //value = name_y;
                //lmark = Glut.glutBitmapLength(Glut.GLUT_BITMAP_HELVETICA_18, value);
                //Gl.glRasterPos2d(x1 - lmark * prx - 6 * prx, y1);    // Set the position for the string (text)
                //Glut.glutBitmapString(Glut.GLUT_BITMAP_TIMES_ROMAN_24, value);

                creatLabelY();
                LoadTexture(labelY);
                Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR);
                Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR);
                Gl.glEnable(Gl.GL_TEXTURE_2D);
                y1 = min_y + j * hy - hy + 31 * pry;

                Gl.glColor3f(255, 255, 255);
                Gl.glBegin(Gl.GL_QUADS);
                Gl.glTexCoord2d(1, 0); Gl.glVertex2d(x1 - ddx + 128 * prx, y1 + 32 * pry);
                Gl.glTexCoord2d(1, 1); Gl.glVertex2d(x1 - ddx + 128 * prx, y1);
                Gl.glTexCoord2d(0, 1); Gl.glVertex2d(x1 - ddx, y1);
                Gl.glTexCoord2d(0, 0); Gl.glVertex2d(x1 - ddx, y1 + 32 * pry);
                Gl.glEnd();
                Gl.glDisable(Gl.GL_TEXTURE_2D);


                //ось ox
                Gl.glColor3f(0, 0, 0);
                y1 = min_y - hmark * pry;
                for (j = 0; j < nx + 1; j++)
                {
                    //значение
                    value = (Math.Round((min_x + j * hx), Convert.ToInt32(Math.Abs(pow_x) + 1))).ToString();
                    lmark = Glut.glutBitmapLength(Glut.GLUT_BITMAP_HELVETICA_18, value);
                    x1    = min_x + j * hx - 0.5 * lmark * prx;
                    Gl.glRasterPos2d(x1, y1);    // Set the position for the string (text)
                    Glut.glutBitmapString(Glut.GLUT_BITMAP_HELVETICA_18, value);
                }

                //подпись оси oх
                //creatLabelX();
                //value = name_x;
                //y1 = min_y - (hmark + Glut.glutBitmapHeight(Glut.GLUT_BITMAP_TIMES_ROMAN_24)) * pry;
                //x1 = (min_x+max_x)/2 - 7.5 * value.Count() * prx;
                //Gl.glRasterPos2d(x1, y1);    // Set the position for the string (text)
                //Glut.glutBitmapString(Glut.GLUT_BITMAP_TIMES_ROMAN_24, value);

                creatLabelX();
                LoadTexture(labelX);
                Gl.glEnable(Gl.GL_TEXTURE_2D);

                y1 = min_y - hmark * pry - 33 * pry;
                x1 = (min_x + max_x) / 2;

                Gl.glColor3f(255, 255, 255);
                Gl.glBegin(Gl.GL_QUADS);
                Gl.glTexCoord2d(1, 0); Gl.glVertex2d(x1 + 64 * prx, y1 + 31 * pry);
                Gl.glTexCoord2d(1, 1); Gl.glVertex2d(x1 + 64 * prx, y1);
                Gl.glTexCoord2d(0, 1); Gl.glVertex2d(x1 - 55 * prx, y1);
                Gl.glTexCoord2d(0, 0); Gl.glVertex2d(x1 - 55 * prx, y1 + 31 * pry);
                Gl.glEnd();
                Gl.glDisable(Gl.GL_TEXTURE_2D);
                //labelX.Save("lx.bmp");
            }
        }
Example #5
0
 static public int FontWidth(IntPtr font, string text)
 {
     return(Glut.glutBitmapLength(font, text));
 }