Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Rotating 2 objects Qt and openGL.
Forum Updated to NodeBB v4.3 + New Features

Rotating 2 objects Qt and openGL.

Scheduled Pinned Locked Moved Game Development
1 Posts 1 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Roma1988
    wrote on last edited by
    #1

    Hi, There is a program:
    @
    Widget::Widget(QWidget *parent) :
    QGLWidget(parent),
    ui(new Ui::Widget)
    {

    ui->setupUi(this);
    tm = new QTimer(this);
    

    }

    Widget::~Widget()
    {
    delete ui;
    delete tm;
    }

    void Widget::initializeGL()
    {
    connect(tm, SIGNAL(timeout()),this, SLOT(update()));
    tm->start(10);
    }

    void Widget::resizeGL(int n_width, int n_height)
    {

    glViewport(0, 0, (GLint)n_width, (GLint)n_height);
    }

    void Widget::paintGL()
    {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    draw();
    draw2();
    }
    void Widget::update()
    {
    updateGL();
    }

    void Widget::draw()
    {
    glLoadIdentity();
    glTranslatef(-0.35f, 0.0f, -0.20f);
    glRotatef(65.0f/4.0f, 1.0f, 0.0f, 1.0f);
    glBegin(GL_QUADS);
    glColor3f(1.0f,0.0f,0.0f);
    glVertex3f(-0.5f, 0.5f, 0.0f);
    glColor3f(0.0f,1.0f,0.0f);
    glVertex3f(-0.5f, -0.5f, 0.0f);
    glColor3f(1.0f,0.0f,1.0f);
    glVertex3f(0.5f,-0.5f,0.0);
    glColor3f(1.0f,1.0f,1.0f);
    glVertex3f(0.5f,0.5f,0.0);
    glEnd();
    }
    void Widget::draw2()
    {
    glLoadIdentity();
    glTranslatef(0.45f, 0.0f, 0.50f);
    glRotatef(65.0f/4.0f, 0.0f, 1.0f, 1.0f);
    glBegin(GL_QUADS);
    glColor3f(1.0f,0.0f,0.0f);
    glVertex3f(-0.5f, 0.5f, 0.0f);
    glColor3f(0.0f,1.0f,0.0f);
    glVertex3f(-0.5f, -0.5f, 0.0f);
    glColor3f(1.0f,0.0f,1.0f);
    glVertex3f(0.5f,-0.5f,0.0);
    glColor3f(1.0f,1.0f,1.0f);
    glVertex3f(0.5f,0.5f,0.0);
    glEnd();
    }
    @

    After starting the program, a square defined functions Drava () drev2 () remain nepodvizhny.Pri window is resized so the rotation does not occur.
    Prompt in what could be the problem? Version Qt 4.8. OpenGL 3.3

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved