Loading...
Searching...
No Matches

Class holding a valid drawing context. More...

#include <SFML/Window/Context.hpp>

Inheritance diagram for sf::Context:
sf::GlResource sf::NonCopyable

Public Member Functions

 Context ()
 Default constructor.
 ~Context ()
 Destructor.
bool setActive (bool active)
 Activate or deactivate explicitely the context.
 Context (const ContextSettings &settings, unsigned int width, unsigned int height)
 Construct a in-memory context.

Detailed Description

Class holding a valid drawing context.

If you need to make OpenGL calls without having an active window (like in a thread), you can use an instance of this class to get a valid context.

Having a valid context is necessary for every OpenGL call.

Note that a context is only active in its current thread, if you create a new thread it will have no valid context by default.

To use a sf::Context instance, just construct it and let it live as long as you need a valid context. No explicit activation is needed, all it has to do is to exist. Its destructor will take care of deactivating and freeing all the attached resources.

Usage example:

void threadFunction(void*)
{
sf::Context context;
// from now on, you have a valid context
// you can make OpenGL calls
glClear(GL_DEPTH_BUFFER_BIT);
}
// the context is automatically deactivated and destroyed
// by the sf::Context destructor
Class holding a valid drawing context.
Definition Context.hpp:49

Definition at line 48 of file Context.hpp.

Constructor & Destructor Documentation

◆ Context() [1/2]

sf::Context::Context ( )

Default constructor.

The constructor creates and activates the context

◆ ~Context()

sf::Context::~Context ( )

Destructor.

The desctructor deactivates and destroys the context

◆ Context() [2/2]

sf::Context::Context ( const ContextSettings & settings,
unsigned int width,
unsigned int height )

Construct a in-memory context.

This constructor is for internal use, you don't need to bother with it.

Parameters
settingsCreation parameters
widthBack buffer width
heightBack buffer height

Member Function Documentation

◆ setActive()

bool sf::Context::setActive ( bool active)

Activate or deactivate explicitely the context.

Parameters
activeTrue to activate, false to deactivate
Returns
True on success, false on failure

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