Equalizer 1.0
|
00001 /* 00002 * Copyright 1993-2006 NVIDIA Corporation. All rights reserved. 00003 * 00004 * NOTICE TO USER: 00005 * 00006 * This source code is subject to NVIDIA ownership rights under U.S. and 00007 * international Copyright laws. 00008 * 00009 * NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE 00010 * CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR 00011 * IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH 00012 * REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF 00013 * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. 00014 * IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, 00015 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00016 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 00017 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE 00018 * OR PERFORMANCE OF THIS SOURCE CODE. 00019 * 00020 * U.S. Government End Users. This source code is a "commercial item" as 00021 * that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of 00022 * "commercial computer software" and "commercial computer software 00023 * documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) 00024 * and is provided to the U.S. Government only as a commercial end item. 00025 * Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 00026 * 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the 00027 * source code with only those rights set forth herein. 00028 */ 00029 00030 /* 00031 * Slightly adapted 2009 by Ph. Robert wrt the Equalizer port 00032 */ 00033 00034 #ifndef EQNBODY_RENDER_PARTICLES_H 00035 #define EQNBODY_RENDER_PARTICLES_H 00036 00037 struct GLEWContextStruct; 00038 typedef struct GLEWContextStruct GLEWContext; 00039 00040 namespace eqNbody 00041 { 00042 enum DisplayMode 00043 { 00044 PARTICLE_POINTS, 00045 PARTICLE_SPRITES, 00046 PARTICLE_SPRITES_COLOR, 00047 PARTICLE_NUM_MODES 00048 }; 00049 00050 class ParticleRenderer 00051 { 00052 public: 00053 ParticleRenderer( const GLEWContext* const glewContext ) 00054 : _glewContext( glewContext ) 00055 , m_pos(0) 00056 , m_numParticles(0) 00057 , m_pointSize(1.0f) 00058 , m_spriteSize(1.0f) 00059 , m_vertexShader(0) 00060 , m_pixelShader(0) 00061 , m_program(0) 00062 , m_texture(0) 00063 , m_pbo(0) 00064 , m_vboColor(0) { } 00065 00066 ~ParticleRenderer(); 00067 00068 void init(); 00069 00070 void setPositions(float *pos, int numParticles); 00071 void setColors(float *color, int numParticles); 00072 void setPBO(unsigned int pbo, int numParticles); 00073 00074 void draw(DisplayMode mode = PARTICLE_POINTS); 00075 00076 void setPointSize(float size) { m_pointSize = size; } 00077 void setSpriteSize(float size) { m_spriteSize = size; } 00078 const GLEWContext* glewGetContext() const { return _glewContext; } 00079 00080 protected: // methods 00081 void _createTexture(int resolution); 00082 void _drawPoints(bool color = false); 00083 private: 00084 const GLEWContext* _glewContext; 00085 protected: // data 00086 float *m_pos; 00087 int m_numParticles; 00088 00089 float m_pointSize; 00090 float m_spriteSize; 00091 00092 unsigned int m_vertexShader; 00093 unsigned int m_pixelShader; 00094 unsigned int m_program; 00095 unsigned int m_texture; 00096 unsigned int m_pbo; 00097 unsigned int m_vboColor; 00098 }; 00099 } 00100 #endif // EQNBODY_RENDER_PARTICLES_H