@Gravit

Почему QGLWidget отказывается строить трехмерные объекты?

QGLWidget отказывается строить куб по такому коду:
void Widget::paintGL()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glMatrixMode(GL_MODELVIEW);
    //glLoadIdentity();
    glTranslatef(0.f,0.0f,2.0f);

    glRotatef(1.0f,1.0f,1.0f,1.0f);
    glBegin(GL_QUADS);
     glColor3f(0.0f,1.0f,0.0f);

    glVertex3f(-1.0f, 1.0f, 0.0f);
                    glVertex3f( 1.0f, 1.0f, 0.0f);
                    glVertex3f( 1.0f,-1.0f, 0.0f);
                    glVertex3f(-1.0f,-1.0f, 0.0f);

    glColor3f(0.0f,1.0f,0.0f);
          glVertex3f( 1.0f, 1.0f,-1.0f);
          glVertex3f(-1.0f, 1.0f,-1.0f);
          glVertex3f(-1.0f, 1.0f, 1.0f);
          glVertex3f( 1.0f, 1.0f, 1.0f);
          glColor3f(1.0f,0.5f,0.0f);
                  glVertex3f( 1.0f,-1.0f, 1.0f);
                  glVertex3f(-1.0f,-1.0f, 1.0f);
                  glVertex3f(-1.0f,-1.0f,-1.0f);
                  glVertex3f( 1.0f,-1.0f,-1.0f);
                  glColor3f(1.0f,0.0f,0.0f);
                         glVertex3f( 1.0f, 1.0f, 1.0f);
                         glVertex3f(-1.0f, 1.0f, 1.0f);
                         glVertex3f(-1.0f,-1.0f, 1.0f);
                         glVertex3f( 1.0f,-1.0f, 1.0f);
                         glColor3f(1.0f,1.0f,0.0f);
                                glVertex3f( 1.0f,-1.0f,-1.0f);
                                glVertex3f(-1.0f,-1.0f,-1.0f);
                                glVertex3f(-1.0f, 1.0f,-1.0f);
                                glVertex3f( 1.0f, 1.0f,-1.0f);
                                glColor3f(0.0f,0.0f,1.0f);
                                        glVertex3f(-1.0f, 1.0f, 1.0f);
                                        glVertex3f(-1.0f, 1.0f,-1.0f);
                                        glVertex3f(-1.0f,-1.0f,-1.0f);
                                        glVertex3f(-1.0f,-1.0f, 1.0f);
                                        glColor3f(1.0f,0.0f,1.0f);
                                        glVertex3f( 1.0f, 1.0f,-1.0f);
                                        glVertex3f( 1.0f, 1.0f, 1.0f);
                                        glVertex3f( 1.0f,-1.0f, 1.0f);
                                        glVertex3f( 1.0f,-1.0f,-1.0f);
                                        glEnd();
                                        glTranslatef(3.0f,0.0f,0.0f);

}

Но этот код рабочий:
void Widget::paintGL()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glMatrixMode(GL_MODELVIEW);
    //glLoadIdentity();
    glTranslatef(0.f,0.0f,2.0f);

    glRotatef(1.0f,1.0f,1.0f,1.0f);
    glBegin(GL_QUADS);
    glVertex3f(0.5, 0.5, 0.5);
    glVertex3f(-0.5, 0.5, 0.5);
    glVertex3f(-0.5, -0.5, 0.5);
    glVertex3f(0.5, -0.5, 0.5);
    glEnd();

}
  • Вопрос задан
  • 205 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы