28 #include <SFML/Graphics/RenderTarget.hpp>
29 #include <SFML/Graphics/Drawable.hpp>
30 #include <SFML/Graphics/GraphicsContext.hpp>
40 myCurrentView (&myDefaultView),
41 myPreserveStates(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;
184 void RenderTarget::SetRenderStates()
186 GLCheck(glDisable(GL_ALPHA_TEST));
187 GLCheck(glDisable(GL_DEPTH_TEST));
188 GLCheck(glDisable(GL_LIGHTING));
Uint8 a
Alpha (transparency) component.
RenderTarget()
Default constructor.
This class defines a view (position, size, etc.) ; you can consider it as a 2D camera.
virtual unsigned int GetWidth() const =0
Get the width of the rendering region of the target.
View & GetDefaultView()
Get the default view of the window for read / write.
void SetView(const View &NewView)
Change the current active view.
Abstract base class for every object that can be drawn into a render window.
const View & GetView() const
Get the current view.
void SetFromRect(const FloatRect &ViewRect)
Rebuild the view from a rectangle.
void PreserveOpenGLStates(bool Preserve)
Tell SFML to preserve external OpenGL states, at the expense of more CPU charge.
virtual ~RenderTarget()
Destructor.
virtual unsigned int GetHeight() const =0
Get the height of the rendering region of the target.
const float * Get4x4Elements() const
Return the elements of the matrix as a 4x4, in an array of 16 floats.
Color is an utility class for manipulating 32-bits RGBA colors.
void Initialize()
Called by the derived class when it's ready to be initialized.
void Clear(const Color &FillColor=Color(0, 0, 0))
Clear the entire target with a single color.
virtual void Draw(const Drawable &Object)
Draw something into the target.