28#include <SFML/Graphics/RenderTarget.hpp>
29#include <SFML/Graphics/Drawable.hpp>
30#include <SFML/Graphics/GraphicsContext.hpp>
40myCurrentView (&myDefaultView),
41myPreserveStates(false),
65 GLCheck(glClearColor(FillColor.
r / 255.f, FillColor.
g / 255.f, FillColor.
b / 255.f, FillColor.
a / 255.f));
66 GLCheck(glClear(GL_COLOR_BUFFER_BIT));
89 GLCheck(glPushAttrib(GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT | GL_ENABLE_BIT |
90 GL_TEXTURE_BIT | GL_TRANSFORM_BIT | GL_VIEWPORT_BIT));
91 GLCheck(glMatrixMode(GL_MODELVIEW)); GLCheck(glPushMatrix());
92 GLCheck(glMatrixMode(GL_PROJECTION)); GLCheck(glPushMatrix());
98 GLCheck(glMatrixMode(GL_PROJECTION)); GLCheck(glLoadMatrixf(myCurrentView->GetMatrix().Get4x4Elements()));
99 GLCheck(glMatrixMode(GL_MODELVIEW)); GLCheck(glLoadIdentity());
105 if (myPreserveStates)
107 GLCheck(glMatrixMode(GL_PROJECTION)); GLCheck(glPopMatrix());
108 GLCheck(glMatrixMode(GL_MODELVIEW)); GLCheck(glPopMatrix());
109 GLCheck(glPopAttrib());
131 myCurrentView = &NewView;
140 return *myCurrentView;
149 return myDefaultView;
163 myPreserveStates = Preserve;
176 myDefaultView.SetFromRect(FloatRect(0, 0,
static_cast<float>(
GetWidth()),
static_cast<float>(
GetHeight())));
184void RenderTarget::SetRenderStates()
186 GLCheck(glDisable(GL_ALPHA_TEST));
187 GLCheck(glDisable(GL_DEPTH_TEST));
188 GLCheck(glDisable(GL_LIGHTING));
Color is an utility class for manipulating 32-bits RGBA colors.
Uint8 a
Alpha (transparency) component.
Abstract base class for every object that can be drawn into a render window.
void Clear(const Color &FillColor=Color(0, 0, 0))
Clear the entire target with a single color.
View & GetDefaultView()
Get the default view of the window for read / write.
virtual void Draw(const Drawable &Object)
Draw something into the target.
const View & GetView() const
Get the current view.
RenderTarget()
Default constructor.
void Initialize()
Called by the derived class when it's ready to be initialized.
virtual ~RenderTarget()
Destructor.
virtual unsigned int GetWidth() const =0
Get the width of the rendering region of the target.
void SetView(const View &NewView)
Change the current active view.
virtual unsigned int GetHeight() const =0
Get the height of the rendering region of the target.
void PreserveOpenGLStates(bool Preserve)
Tell SFML to preserve external OpenGL states, at the expense of more CPU charge.
This class defines a view (position, size, etc.) ; you can consider it as a 2D camera.