Documentation de SFML 2.0

Attention: cette page se réfère à une ancienne version de SFML. Cliquez ici pour passer à la dernière version.
RenderTarget.hpp
1 
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24 
25 #ifndef SFML_RENDERTARGET_HPP
26 #define SFML_RENDERTARGET_HPP
27 
29 // Headers
31 #include <SFML/Graphics/Export.hpp>
32 #include <SFML/Graphics/Color.hpp>
33 #include <SFML/Graphics/Rect.hpp>
34 #include <SFML/Graphics/View.hpp>
35 #include <SFML/Graphics/Transform.hpp>
36 #include <SFML/Graphics/BlendMode.hpp>
37 #include <SFML/Graphics/RenderStates.hpp>
38 #include <SFML/Graphics/PrimitiveType.hpp>
39 #include <SFML/Graphics/Vertex.hpp>
40 #include <SFML/System/NonCopyable.hpp>
41 
42 
43 namespace sf
44 {
45 class Drawable;
46 
51 class SFML_GRAPHICS_API RenderTarget : NonCopyable
52 {
53 public :
54 
59  virtual ~RenderTarget();
60 
70  void clear(const Color& color = Color(0, 0, 0, 255));
71 
91  void setView(const View& view);
92 
101  const View& getView() const;
102 
114  const View& getDefaultView() const;
115 
129  IntRect getViewport(const View& view) const;
130 
149  Vector2f mapPixelToCoords(const Vector2i& point) const;
150 
180  Vector2f mapPixelToCoords(const Vector2i& point, const View& view) const;
181 
200  Vector2i mapCoordsToPixel(const Vector2f& point) const;
201 
227  Vector2i mapCoordsToPixel(const Vector2f& point, const View& view) const;
228 
236  void draw(const Drawable& drawable, const RenderStates& states = RenderStates::Default);
237 
247  void draw(const Vertex* vertices, unsigned int vertexCount,
248  PrimitiveType type, const RenderStates& states = RenderStates::Default);
249 
256  virtual Vector2u getSize() const = 0;
257 
290  void pushGLStates();
291 
301  void popGLStates();
302 
324  void resetGLStates();
325 
326 protected :
327 
332  RenderTarget();
333 
341  void initialize();
342 
343 private:
344 
349  void applyCurrentView();
350 
357  void applyBlendMode(BlendMode mode);
358 
365  void applyTransform(const Transform& transform);
366 
373  void applyTexture(const Texture* texture);
374 
381  void applyShader(const Shader* shader);
382 
395  virtual bool activate(bool active) = 0;
396 
401  struct StatesCache
402  {
403  enum {VertexCacheSize = 4};
404 
405  bool glStatesSet;
406  bool viewChanged;
407  BlendMode lastBlendMode;
408  Uint64 lastTextureId;
409  bool useVertexCache;
410  Vertex vertexCache[VertexCacheSize];
411  };
412 
414  // Member data
416  View m_defaultView;
417  View m_view;
418  StatesCache m_cache;
419 };
420 
421 } // namespace sf
422 
423 
424 #endif // SFML_RENDERTARGET_HPP
425 
426