00001 00002 // SPARK particle engine // 00003 // Copyright (C) 2008-2009 - Julien Fryer - julienfryer@gmail.com // 00004 // // 00005 // This software is provided 'as-is', without any express or implied // 00006 // warranty. In no event will the authors be held liable for any damages // 00007 // 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 // 00011 // freely, subject to the following restrictions: // 00012 // // 00013 // 1. The origin of this software must not be misrepresented; you must not // 00014 // claim that you wrote the original software. If you use this software // 00015 // in a product, an acknowledgment in the product documentation would be // 00016 // appreciated but is not required. // 00017 // 2. Altered source versions must be plainly marked as such, and must not be // 00018 // misrepresented as being the original software. // 00019 // 3. This notice may not be removed or altered from any source distribution. // 00021 00022 00023 #ifndef H_SPK_SFMLLINERENDERER 00024 #define H_SPK_SFMLLINERENDERER 00025 00026 #include "RenderingAPIs/SFML/SPK_SFMLRenderer.h" 00027 #include "Extensions/Renderers/SPK_LineRendererInterface.h" 00028 00029 namespace SPK 00030 { 00031 namespace SFML 00032 { 00052 class SPK_SFML_PREFIX SFMLLineRenderer : public SFMLRenderer,public LineRendererInterface 00053 { 00054 SPK_IMPLEMENT_REGISTERABLE(SFMLLineRenderer) 00055 00056 public : 00057 00059 // Constructors // 00061 00068 SFMLLineRenderer(float length = 1.0f,float width = 1.0f,ResizeMode mode = RESIZE_NONE); 00069 00078 static SFMLLineRenderer* create(float length = 1.0f,float width = 1.0f,ResizeMode mode = RESIZE_NONE); 00079 00081 // Setters // 00083 00088 void setResizeMode(ResizeMode mode); 00089 00091 // Getters // 00093 00098 ResizeMode getResizeMode() const; 00099 00101 // Interface // 00103 00104 virtual void createBuffers(const Group& group); 00105 virtual void destroyBuffers(const Group& group); 00106 00107 protected : 00108 00109 virtual bool checkBuffers(const Group& group); 00110 00111 private : 00112 00113 ResizeMode resizeMode; 00114 00115 // vertex buffers and iterators 00116 static float* gpuBuffer; 00117 static float* gpuIterator; 00118 00119 // buffers names 00120 static const std::string GPU_BUFFER_NAME; 00121 00122 virtual void innerRender(const Group& group); 00123 }; 00124 00125 00126 inline SFMLLineRenderer* SFMLLineRenderer::create(float length,float width,ResizeMode mode) 00127 { 00128 SFMLLineRenderer* obj = new SFMLLineRenderer(length,width,mode = RESIZE_NONE); 00129 registerObject(obj); 00130 return obj; 00131 } 00132 00133 inline void SFMLLineRenderer::setResizeMode(ResizeMode mode) 00134 { 00135 resizeMode = mode; 00136 } 00137 00138 inline ResizeMode SFMLLineRenderer::getResizeMode() const 00139 { 00140 return resizeMode; 00141 } 00142 }} 00143 00144 #endif