DISTRHO Plugin Framework
Public Member Functions | List of all members
Window::ScopedGraphicsContext Struct Reference

#include <Window.hpp>

Public Member Functions

 ScopedGraphicsContext (Window &window)
 
 ScopedGraphicsContext (Window &window, Window &transientParentWindow)
 
 ~ScopedGraphicsContext ()
 
void done ()
 
void reinit ()
 

Detailed Description

Window graphics context as a scoped struct. This class gives graphics context drawing time to a window's widgets. Typically used for allowing OpenGL drawing operations during a window + widget constructor.

Unless you are subclassing the Window or StandaloneWindow classes, you do not need to care. In such cases you will need to use this struct as a way to get a valid OpenGL context. For example in a standalone application:

int main()
{
Window win(app);
{
widget = new MyCustomTopLevelWidget(win);
}
app.exec();
return 0;
}
Definition: Application.hpp:43
void exec(uint idleTimeInMs=30)
Definition: ScopedPointer.hpp:83
Definition: Window.hpp:63
Definition: Window.hpp:95

This struct is necessary because we cannot automatically make the window leave the OpenGL context in custom code. And we must always cleanly enter and leave the OpenGL context. So in order to avoid messing up the global host context, this class is used around widget creation.

Constructor & Destructor Documentation

◆ ScopedGraphicsContext() [1/2]

Window::ScopedGraphicsContext::ScopedGraphicsContext ( Window window)
explicit

Constructor that will make the window graphics context the current one

◆ ScopedGraphicsContext() [2/2]

Window::ScopedGraphicsContext::ScopedGraphicsContext ( Window window,
Window transientParentWindow 
)
explicit

Overloaded constructor, gives back context to its transient parent when done

◆ ~ScopedGraphicsContext()

Window::ScopedGraphicsContext::~ScopedGraphicsContext ( )

Desstructor for clearing current context, if not done yet

Member Function Documentation

◆ done()

void Window::ScopedGraphicsContext::done ( )

Early context clearing, useful for standalone windows not created by you.

◆ reinit()

void Window::ScopedGraphicsContext::reinit ( )

Get a valid context back again.


The documentation for this struct was generated from the following file: