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_SFMLPOINTRENDERER 00024 #define H_SPK_SFMLPOINTRENDERER 00025 00026 #include "RenderingAPIs/SFML/SPK_SFMLRenderer.h" 00027 #include "RenderingAPIs/OpenGL/SPK_GLExtHandler.h" 00028 #include "Extensions/Renderers/SPK_PointRendererInterface.h" 00029 00030 namespace SPK 00031 { 00032 namespace SFML 00033 { 00062 class SPK_SFML_PREFIX SFMLPointRenderer : public SFMLRenderer, 00063 public PointRendererInterface, 00064 public GL::GLExtHandler 00065 { 00066 SPK_IMPLEMENT_REGISTERABLE(SFMLPointRenderer) 00067 00068 public : 00069 00071 // Constructors // 00073 00079 SFMLPointRenderer(float size = 1.0f,ResizeMode mode = RESIZE_NONE); 00080 00088 static SFMLPointRenderer* create(float size = 1.0f,ResizeMode mode = RESIZE_NONE); 00089 00091 // Setters // 00093 00094 bool setType(PointType type); 00095 00103 void setImage(sf::Image* image); 00104 00109 void setResizeMode(ResizeMode mode); 00110 00112 // Getters // 00114 00119 sf::Image* getImage() const; 00120 00125 ResizeMode getResizeMode() const; 00126 00128 // Interface // 00130 00131 virtual void createBuffers(const Group& group); 00132 virtual void destroyBuffers(const Group& group); 00133 00134 protected : 00135 00136 virtual bool checkBuffers(const Group& group); 00137 00138 private : 00139 00140 sf::Image* image; 00141 ResizeMode resizeMode; 00142 00143 // vertex buffers and iterators 00144 static float* gpuBuffer; 00145 static float* gpuIterator; 00146 00147 // buffers names 00148 static const std::string GPU_BUFFER_NAME; 00149 00150 void innerRender(const Group& group); 00151 }; 00152 00153 00154 inline SFMLPointRenderer* SFMLPointRenderer::create(float size,ResizeMode mode) 00155 { 00156 SFMLPointRenderer* obj = new SFMLPointRenderer(size,mode); 00157 registerObject(obj); 00158 return obj; 00159 } 00160 00161 inline void SFMLPointRenderer::setImage(sf::Image* image) 00162 { 00163 this->image = image; 00164 } 00165 00166 inline void SFMLPointRenderer::setResizeMode(ResizeMode mode) 00167 { 00168 resizeMode = mode; 00169 } 00170 00171 inline sf::Image* SFMLPointRenderer::getImage() const 00172 { 00173 return image; 00174 } 00175 00176 inline ResizeMode SFMLPointRenderer::getResizeMode() const 00177 { 00178 return resizeMode; 00179 } 00180 }} 00181 00182 #endif