Ejemplo n.º 1
0
        static void desenhar()
        {
            Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);
            cenaCampo();

            Gl.glColor3f(1f, 1f, 1f);
            float j1 = (0.5f - (float)(jogador1.Length + pontoJogador1.ToString().Length + 5) / 100);

            Gl.glRasterPos2f(j1, 0.9f);
            Glut.glutBitmapString(Glut.GLUT_BITMAP_HELVETICA_18, jogador1 + " " + pontoJogador1);

            Gl.glRasterPos2f(0.53f, 0.9f);
            Glut.glutBitmapString(Glut.GLUT_BITMAP_HELVETICA_18, jogador2 + " " + pontoJogador2);

            // Glut.glutBitmapString(Glut.GLUT_BITMAP_HELVETICA_18, "Jogador 1");
            Novacor = new float[3] {
                0.87f, 0f, 0f
            };
            goleiroAlemanha(Novacor);
            Novacor = new float[3] {
                1f, 0.87f, 0f
            };
            goleiroBrasil(Novacor);
            bola();
            Glut.glutSwapBuffers();
        }
Ejemplo n.º 2
0
            public override void draw()
            {
                IntPtr font = Glut.GLUT_BITMAP_9_BY_15;

                Gl.glLoadIdentity();
                Gl.glPushMatrix();
                Gl.glTranslated(0, 0, 1);
                switch (color)
                {
                case (int)colors.RED:
                    Gl.glColor3f(1.0f, 0.0f, 0.0f);
                    font = Glut.GLUT_BITMAP_HELVETICA_18;
                    break;

                case (int)colors.GREEN:
                    Gl.glColor3f(0.0f, 1.0f, 0.0f);
                    break;

                case (int)colors.BLUE:
                    Gl.glColor3f(0.0f, 0.0f, 1.0f);
                    break;
                }
                Gl.glRasterPos2d(x - 8, y + 5);
                Glut.glutBitmapString(font, text);
                Gl.glPopMatrix();
            }
Ejemplo n.º 3
0
 public void DesenhaTexto(string texto)
 {
     //cria uma interferencia (tira um screeenshot faz a interferencia e volta ele )
     Gl.glPushMatrix();
     Gl.glColor3f(1, 1, 1);
     Gl.glRasterPos2f(150, 220);
     Glut.glutBitmapString(Glut.GLUT_BITMAP_TIMES_ROMAN_24, texto);
     Gl.glPopMatrix();
 }
Ejemplo n.º 4
0
        private void paintNumbers(int i)
        {
            Vector v1 = new Vector(-radius / 2, -radius / 2, radius + 0.05f);
            Vector v2 = v1 * !q;

            Gl.glDisable(Gl.GL_LIGHT0);
            Gl.glDisable(Gl.GL_LIGHTING);
            Gl.glColor3f(0.0f, 0.0f, 1.0f);
            Gl.glRasterPos3d(v2.X, v2.Y, v2.Z);
            Glut.glutBitmapString(Glut.GLUT_BITMAP_TIMES_ROMAN_24, Convert.ToString(i));
            Gl.glEnable(Gl.GL_LIGHTING);
            Gl.glEnable(Gl.GL_LIGHT0);
        }
Ejemplo n.º 5
0
        /**
         * @brief  Bu fonksiyon OpenGL ekranina cizilen noktalari Pn seklinde isimlendirerek,
         *         ilgili text karakterlerinin OpenGL ekranina ciziminde kullanilir.
         * @param  glutPoints
         * @param  numberofPoints
         * @retval yok
         */
        public void drawFreeGlut(double[] glutPoints, int numberofPoints)
        {
            int i = 0;
            int j = 0;

            for (i = 0; i < numberofPoints; i++)
            {
                Gl.glColor3d(0, 0, 10);
                Gl.glRasterPos3d(glutPoints[j], glutPoints[j + 1], glutPoints[j + 2]);
                j += 3;
                Glut.glutBitmapString(Glut.GLUT_BITMAP_TIMES_ROMAN_24, "P" + i.ToString());
            }
        }
Ejemplo n.º 6
0
        protected void DrawMenuInfo(Scene.Scene scene)
        {
            IntPtr font = Glut.GLUT_BITMAP_HELVETICA_12;

            Gl.glColor3d(0, 0, 0);
            Gl.glRasterPos2d(OffsetX + 20, OffsetY + HEIGHT / 2 + 4);
            string text = "";

            if (scene.sceneState == SceneState.Edit)
            {
                text = "Edit " + scene.SelectedButton.CurrentProperty + ": " + scene.InputString;
            }
            if (scene.sceneState == SceneState.LoadObj)
            {
                text = "Write filename (without extension)" + ": " + scene.InputString;
            }
            else if (scene.sceneState == SceneState.Error)
            {
                text = "Error.";
            }
            else if (scene.sceneState == SceneState.Create)
            {
                text = "Create ";
                if (scene.FigureToCreate == Figures.FigureEnum.Triangle)
                {
                    text += " triangle";
                }
                else if (scene.FigureToCreate == Figures.FigureEnum.Sphere)
                {
                    text += " sphere";
                }
            }
            else if (scene.sceneState == SceneState.Save)
            {
                text = "Scene was successfully saved";
            }
            else if (scene.sceneState == SceneState.Free)
            {
                text = "Commands: 'L' load model, 'C + T + ENTER' create triangle, 'C + S + ENTER' create sphere, 'DEL' delete selected object, 'SPACE' save";
            }

            Glut.glutBitmapString(font, text);
        }
Ejemplo n.º 7
0
 public static void WriteText(IntPtr font, string text, int x, int y, int r = 0, int g = 0, int b = 0)
 {
     Gl.glRasterPos2d(x, y);
     Gl.glColor3d(r, g, b);
     Glut.glutBitmapString(font, text);
 }
Ejemplo n.º 8
0
 private void PrintText(double x, double y, double z, string text)
 {
     Gl.glRasterPos3d(x, y, z);
     Glut.glutBitmapString(Glut.GLUT_BITMAP_9_BY_15, text);
 }
Ejemplo n.º 9
0
 /**
  * @brief  Bu fonksiyon OpenGL ekranindaki herhangi bir noktaya istenilen bir text'i
  *         Times New Roman fontunda 10 punto ile basmak icin kullanilir.
  * @param  x
  * @param  y
  * @param  z
  * @param  text
  * @retval yok
  */
 public void drawTextSmall(double x, double y, double z, string text)
 {
     Gl.glColor3d(0.698f, 0.133f, 0.133f);
     Gl.glRasterPos3d(x, y, z);
     Glut.glutBitmapString(Glut.GLUT_BITMAP_TIMES_ROMAN_10, text);
 }
        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");
            }
        }