How can I accelerate 2D graphics painting using OpenGL?

I created an Animated Application in Introjucer, and add some codes which consume some time in the fuction paint(). It slows down my program.
Now I just need to do some 2D paintings, so I still want to use Graphics class and don't want to learn too complex OpenGL programming. How can I accelerate this paint() function using juce's class about OpenGL?
Is there any existing JUCE class can help me?
            
Thanks.
 

Well yes - have a look in the demo app, which shows how to use GL-accelerated rendering.

So this kind of code (or create an OpenGLContext and attach it to the current component) can get accelerated effects, right? I still want to use the functions in the graphics... Then thanks again, for wasting your many time.


class MainContentComponent   : public OpenGLAppComponent
{
public:
    MainContentComponent(): src(0)
    {
        centreWithSize(1280, 720);
        setVisible(1);
        src=new Image(ImageFileFormat::loadFrom(File("test.png")));
        return;
    }
    ~MainContentComponent()
    {
        delete src; src=0;
        return;
    }
    void initialise() override {}
    void shutdown() override { shutdownOpenGL(); }
    void render() override {}
    void resized() override { return; }
    void paint (Graphics& g) override
    {
        //some codes using Graphics function that consuming many time
        //here is only a example
        g.drawImage(*src, 0, 0, 1280, 720, 0, 0, 1280, 720);
        return;
    }
private:
    
    Image *src;
    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainContentComponent)
};

Yes. Like in the demo app.

BTW, as I seem to have said many times on many different threads recently: the Image class is a copy-by-value type - you never create it on the heap. Not sure why everyone seems to keep using it like that, as you won't see any code anywhere in our code base that works that way.

Thanks to get me awared. And I will look more threads in the fourm and more source codes. THE LAST, congretulate on grapefruit JUCE!

Thanks! But as a beginner, don't assume that all the code people post on the forum is good - a great deal of it has some quite bad C++ practices that you shouldn't copy!

The title of this post is my sincere gratitude.

 
gratitude
gratitude
 
gratitude