用OpenGL和uC ++翻译三角形

时间:2014-07-05 19:33:24

标签: c++ opengl

我在使用OpenGL和使用uC ++进行三角形翻译时遇到了困难。每只鸟(三角形)都是一个线程。事实上,当鸟儿翻译时,相机或一般图像会向上或向下移动。

抽奖代码就是这个:

   void Graphics::draw(){
       double AxisX;
       double AxisY;
       double Direction;

       for (int i = 0; i < numBirds; i++)
       {
           AxisX     = birds[i]->Px;
           AxisY      = birds[i]->Py;
           Direction = birds[i]->Dir - 90;

           glColor3d(1, 1, 1);

       //Operacion para el triangulo
           glTranslated(AxisX, AxisY, 0.0f);
           glRotated(Direction, 0, 0, 1);


           /*
               Se mantienen estas proporciones:
                Base: 1
                Altura: 1.9364916731
                Lado (isosceles): 2
          */
           glBegin(GL_TRIANGLES); // Inicio del dibujo
           glVertex3d(-5, 0, 0); // Primer vertice
           glVertex3d( 5, 0, 0); // Segundo vertice
           glVertex3d( 0, 15, 0); // Tercer vertice
           glEnd(); // Fin del dibujo

          // Deshago las operaciones de rotacion y translacion
           glRotated(-Direction, 0, 0, 1);
           glTranslated(-AxisX, -AxisY, 0.0f);
       }
   }

问题是,我该如何解决这个问题?我一直在苦苦挣扎几个小时。

0 个答案:

没有答案