00001 00002 // 00003 // SFML - Simple and Fast Multimedia Library 00004 // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) 00005 // 00006 // This software is provided 'as-is', without any express or implied warranty. 00007 // In no event will the authors be held liable for any damages arising from the use of this software. 00008 // 00009 // Permission is granted to anyone to use this software for any purpose, 00010 // including commercial applications, and to alter it and redistribute it freely, 00011 // subject to the following restrictions: 00012 // 00013 // 1. The origin of this software must not be misrepresented; 00014 // you must not claim that you wrote the original software. 00015 // If you use this software in a product, an acknowledgment 00016 // in the product documentation would be appreciated but is not required. 00017 // 00018 // 2. Altered source versions must be plainly marked as such, 00019 // and must not be misrepresented as being the original software. 00020 // 00021 // 3. This notice may not be removed or altered from any source distribution. 00022 // 00024 00025 #ifndef SFML_RENDERER_HPP 00026 #define SFML_RENDERER_HPP 00027 00029 // Headers 00031 #include <SFML/Config.hpp> 00032 #include <SFML/System/NonCopyable.hpp> 00033 #include <SFML/Graphics/Color.hpp> 00034 #include <SFML/Graphics/Drawable.hpp> 00035 #include <SFML/Graphics/Matrix3.hpp> 00036 00037 00038 namespace sf 00039 { 00040 class Image; 00041 class Shader; 00042 00047 class SFML_API Renderer : NonCopyable 00048 { 00049 public : 00050 00055 enum PrimitiveType 00056 { 00057 TriangleList, 00058 TriangleStrip, 00059 TriangleFan, 00060 QuadList 00061 }; 00062 00063 public : 00064 00071 Renderer(RenderTarget& target); 00072 00077 ~Renderer(); 00078 00083 void Initialize(); 00084 00091 void SaveGLStates(); 00092 00099 void RestoreGLStates(); 00100 00107 void Clear(const Color& color); 00108 00115 void PushStates(); 00116 00123 void PopStates(); 00124 00136 void SetModelView(const Matrix3& matrix); 00137 00149 void ApplyModelView(const Matrix3& matrix); 00150 00162 void SetProjection(const Matrix3& matrix); 00163 00176 void SetColor(const Color& color); 00177 00190 void ApplyColor(const Color& color); 00191 00201 void SetViewport(const IntRect& viewport); 00202 00212 void SetBlendMode(Blend::Mode mode); 00213 00223 void SetTexture(const Image* texture); 00224 00234 void SetShader(const Shader* shader); 00235 00255 void Begin(PrimitiveType type); 00256 00263 void End(); 00264 00275 void AddVertex(float x, float y); 00276 00289 void AddVertex(float x, float y, float u, float v); 00290 00302 void AddVertex(float x, float y, const Color& color); 00303 00316 void AddVertex(float x, float y, float u, float v, const Color& color); 00317 00318 private : 00319 00336 void ProcessVertex(float x, float y, float u, float v, float r, float g, float b, float a); 00337 00339 // Structure holding the render states that can be stacked 00341 struct States 00342 { 00343 States() : r(1.f), g(1.f), b(1.f), a(1.f) {} 00344 00345 Matrix3 modelView; 00346 float r, g, b, a; 00347 }; 00348 00350 // Member data 00352 RenderTarget& myTarget; 00353 States myStatesStack[64]; 00354 States* myStates; 00355 const Image* myTexture; 00356 const Shader* myShader; 00357 Blend::Mode myBlendMode; 00358 IntRect myViewport; 00359 bool myTextureIsValid; 00360 bool myShaderIsValid; 00361 bool myBlendModeIsValid; 00362 bool myViewportIsValid; 00363 }; 00364 00365 } // namespace sf 00366 00367 00368 #endif // SFML_RENDERER_HPP 00369 00370
:: Copyright © 2007-2008 Laurent Gomila, all rights reserved :: Documentation generated by doxygen 1.5.2 ::