Mouse events + repaint has too much latency

Well, I had already finished this post, but what I have discovered is incredible

I have thought that maybe I could combine OpenGL to clean the window and other heavy tasks.

What has been my surprise, that by the mere fact of adding the opengl render to the component, the drawing of the Gui has become super fast. I’ve actually tried to clean the component in a loop 500 times maintaining a smooth animation, or 30 times with g.drawImage

I have not used any OpenGL, only what is necessary to activate it. It also works on the main component, that is, it is not necessary to do it on the drawing component. In case it helps someone, it is very simple, just Add OpenGLRenderer to the component, and overriding newOpenGLContextCreated, openGLContextClosing, and renderOpenGL, necessary because they are pure. and initialize the OpenGLContext like this:

    openGLContext.setOpenGLVersionRequired(juce::OpenGLContext::OpenGLVersion::openGL3_2);
    openGLContext.setRenderer(this);
    openGLContext.attachTo(*this);

and the magic appears.

I have no idea what’s going on, but I think this should be able to be activated in some transparent way for the programmer.

2 Likes