Added missing setActive virtual method to sf::RenderTarget, added setActive calls to OpenGL example to demonstrate proper explicit context management.

This commit is contained in:
binary1248 2016-10-06 23:44:56 +02:00 committed by Lukas Dürrenberger
parent 39208efb55
commit 2df9abf341
7 changed files with 69 additions and 55 deletions

View file

@ -255,6 +255,28 @@ public:
////////////////////////////////////////////////////////////
virtual Vector2u getSize() const = 0;
////////////////////////////////////////////////////////////
/// \brief Activate or deactivate the render target for rendering
///
/// This function makes the render target's context current for
/// future OpenGL rendering operations (so you shouldn't care
/// about it if you're not doing direct OpenGL stuff).
/// A render target's context is active only on the current thread,
/// if you want to make it active on another thread you have
/// to deactivate it on the previous thread first if it was active.
/// Only one context can be current in a thread, so if you
/// want to draw OpenGL geometry to another render target
/// don't forget to activate it again. Activating a render
/// target will automatically deactivate the previously active
/// context (if any).
///
/// \param active True to activate, false to deactivate
///
/// \return True if operation was successful, false otherwise
///
////////////////////////////////////////////////////////////
virtual bool setActive(bool active = true) = 0;
////////////////////////////////////////////////////////////
/// \brief Save the current OpenGL render states and matrices
///
@ -380,20 +402,6 @@ private:
////////////////////////////////////////////////////////////
void applyShader(const Shader* shader);
////////////////////////////////////////////////////////////
/// \brief Activate the target for rendering
///
/// This function must be implemented by derived classes to make
/// their OpenGL context current; it is called by the base class
/// everytime it's going to use OpenGL calls.
///
/// \param active True to make the target active, false to deactivate it
///
/// \return True if the function succeeded
///
////////////////////////////////////////////////////////////
virtual bool activate(bool active) = 0;
////////////////////////////////////////////////////////////
/// \brief Render states cache
///

View file

@ -204,19 +204,6 @@ public:
private:
////////////////////////////////////////////////////////////
/// \brief Activate the target for rendering
///
/// This function is called by the base class
/// everytime it's going to use OpenGL calls.
///
/// \param active True to make the target active, false to deactivate it
///
/// \return True if the function succeeded
///
////////////////////////////////////////////////////////////
virtual bool activate(bool active);
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////

View file

@ -112,6 +112,24 @@ public:
////////////////////////////////////////////////////////////
virtual Vector2u getSize() const;
////////////////////////////////////////////////////////////
/// \brief Activate or deactivate the window as the current target
/// for OpenGL rendering
///
/// A window is active only on the current thread, if you want to
/// make it active on another thread you have to deactivate it
/// on the previous thread first if it was active.
/// Only one window can be active on a thread at a time, thus
/// the window previously active (if any) automatically gets deactivated.
/// This is not to be confused with requestFocus().
///
/// \param active True to activate, false to deactivate
///
/// \return True if operation was successful, false otherwise
///
////////////////////////////////////////////////////////////
bool setActive(bool active = true);
////////////////////////////////////////////////////////////
/// \brief Copy the current contents of the window to an image
///
@ -159,18 +177,6 @@ protected:
///
////////////////////////////////////////////////////////////
virtual void onResize();
private:
////////////////////////////////////////////////////////////
/// \brief Activate the target for rendering
///
/// \param active True to make the target active, false to deactivate it
///
/// \return True if the function succeeded
///
////////////////////////////////////////////////////////////
virtual bool activate(bool active);
};
} // namespace sf