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/Window/GlResource.hpp> 00034 #include <SFML/Graphics/Color.hpp> 00035 #include <SFML/Graphics/Drawable.hpp> 00036 #include <SFML/Graphics/Matrix3.hpp> 00037 00038 00039 namespace sf 00040 { 00041 class Shader; 00042 class Texture; 00043 00048 class SFML_API Renderer : GlResource, NonCopyable 00049 { 00050 public : 00051 00056 enum PrimitiveType 00057 { 00058 TriangleList, 00059 TriangleStrip, 00060 TriangleFan, 00061 QuadList 00062 }; 00063 00064 public : 00065 00072 Renderer(RenderTarget& target); 00073 00078 void Initialize(); 00079 00086 void SaveGLStates(); 00087 00094 void RestoreGLStates(); 00095 00102 void Clear(const Color& color); 00103 00110 void PushStates(); 00111 00118 void PopStates(); 00119 00128 void SetModelView(const Matrix3& matrix); 00129 00138 void ApplyModelView(const Matrix3& matrix); 00139 00148 void SetProjection(const Matrix3& matrix); 00149 00160 void SetColor(const Color& color); 00161 00172 void ApplyColor(const Color& color); 00173 00180 void SetViewport(const IntRect& viewport); 00181 00188 void SetBlendMode(Blend::Mode mode); 00189 00196 void SetTexture(const Texture* texture); 00197 00204 void SetShader(const Shader* shader); 00205 00227 void Begin(PrimitiveType type); 00228 00235 void End(); 00236 00247 void AddVertex(float x, float y); 00248 00261 void AddVertex(float x, float y, float u, float v); 00262 00274 void AddVertex(float x, float y, const Color& color); 00275 00288 void AddVertex(float x, float y, float u, float v, const Color& color); 00289 00290 private : 00291 00308 void ProcessVertex(float x, float y, float u, float v, float r, float g, float b, float a); 00309 00311 // Structure holding the render states that can be stacked 00313 struct States 00314 { 00315 States() : r(1.f), g(1.f), b(1.f), a(1.f) {} 00316 00317 Matrix3 modelView; 00318 float r, g, b, a; 00319 }; 00320 00322 // Member data 00324 RenderTarget& myTarget; 00325 States myStatesStack[64]; 00326 States* myStates; 00327 const Texture* myTexture; 00328 unsigned int myTextureId; 00329 const Shader* myShader; 00330 Blend::Mode myBlendMode; 00331 IntRect myViewport; 00332 bool myTextureIsValid; 00333 bool myShaderIsValid; 00334 bool myBlendModeIsValid; 00335 bool myViewportIsValid; 00336 }; 00337 00338 } // namespace sf 00339 00340 00341 #endif // SFML_RENDERER_HPP 00342 00343
:: Copyright © 2007-2008 Laurent Gomila, all rights reserved :: Documentation generated by doxygen 1.5.2 ::