Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8911607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:59:24+00:00 2026-06-15T03:59:24+00:00

I am working on a Qt/GPU/OpenCL code with OpenGL rendering. It performs an animation

  • 0

I am working on a Qt/GPU/OpenCL code with OpenGL rendering. It performs an animation of a 3D scene and I succeed in rotating this 3D scene with mouse while the animation. But the rotation doesn’t work when I do a pause of the animation, i.e when the 3D scene is “fixed”.

here’s the two functions for the rotation with mouse :

void GLWidget::mousePressEvent(QMouseEvent *event)
 {
     lastPos = event->pos();
 }

 void GLWidget::mouseMoveEvent(QMouseEvent *event)
 {
     float dx = (event->y() - lastPos.y()) / 10.0f;
     float dy = (event->x() - lastPos.x()) / 10.0f;
     float dz = 0.0f;
     float angle = sqrtf((event->x() - lastPos.x()) + (event->y() - lastPos.y()));

     if (event->buttons() & Qt::LeftButton) {
        angle = sqrtf(dx*dx + dy*dy);
        glRotatef(0.1*angle, dx, dy, dz);
       }
 }

When the animation is on “pause”, I would like to be able to rotate the fixed scene and when I push the “restart” button, I would like the animation restarts with the last modified image done by the rotation of the scene.

So, this should be, before to do “pause”, like a snapshot of the last animation, then the possiblity to rotate, and finally, restart the animation from the last 3D rotated scene.

Here’s my main display function “processCurrent()” called by a QTimer and where "draw()" contains OpenGL functions and animation is set to false when I do a pause :

 void GLWidget::processCurrent()
{

 if (Galaxy->isFirstLaunch)
    {
    draw();
    printStats();
    //Calling kernel for calculatig subsequent positions
    Galaxy->runCLKernels();
    Galaxy->isFirstLaunch = false;
    glFlush();
    swapBuffers();
    }

 if (animation)
    {
    clWaitForEvents(1, &Galaxy->glEvent);
    draw();
    printStats();
    //Calling kernel for calculatig subsequent positions
    Galaxy->runCLKernels();
    glFlush();
    swapBuffers();
   }

}

Could you explain me why this rotation doesn’t work with a fixed scene ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:59:25+00:00Added an answer on June 15, 2026 at 3:59 am

    you still need to draw the scene, if draw() only does draw operations and no animation operations and runCLKernels does animation this should work:

    if(animation)
    {
        //same as before...
    }
    else
    {
        // I don't know whether or not you would still call WaitForEvents...
        draw();
        printStats();
        // Do NOT calculate subsequent positions, just use what was calculated last time.
        glFlush();
        swapBuffers();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently I started using OpenGL in C++ for some 3D rendering, but oddly enough
I am working in parallelise [this file][1] on GPU using [PTX file with matlab
I find that when I enable this developer option, my OpenGL project stops working.
I am working on GPU device which has very high division integer latency, several
Working with H2 I get this error when I try to write a row
I am new to OpenCL. I have written a vector addition code in OpenCL
I'm currently trying to set up a GPU skinning (with glsl) but it's not
I'm working on some image manipulation code in c# and need to do some
I have the following code written to make my lazy second CPU core working.
I'm working on a hybrid OpenCL application that has to decide at run time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.