|
From: <axl...@us...> - 2009-12-24 18:12:07
|
Revision: 639
http://hgengine.svn.sourceforge.net/hgengine/?rev=639&view=rev
Author: axlecrusher
Date: 2009-12-24 18:11:56 +0000 (Thu, 24 Dec 2009)
Log Message:
-----------
update for faster particle rendering, use gl_Color instead of uniforms to set values
Modified Paths:
--------------
Mercury2/modules/ParticleEmitter.cpp
Mercury2/modules/ParticleEmitter.h
Modified: Mercury2/modules/ParticleEmitter.cpp
===================================================================
--- Mercury2/modules/ParticleEmitter.cpp 2009-12-24 18:11:04 UTC (rev 638)
+++ Mercury2/modules/ParticleEmitter.cpp 2009-12-24 18:11:56 UTC (rev 639)
@@ -255,8 +255,7 @@
void ParticleEmitter::Render(const MercuryMatrix& matrix)
{
-// printf("render particles\n");
- GLCALL( glPushAttrib(GL_ENABLE_BIT|GL_DEPTH_BUFFER_BIT) );
+ GLCALL( glPushAttrib(GL_ENABLE_BIT|GL_DEPTH_BUFFER_BIT|GL_CURRENT_BIT) );
GLCALL( glDepthMask( false ) );
GLCALL( glDisable(GL_CULL_FACE) );
@@ -266,38 +265,47 @@
}
GLCALL( glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_bufferID) );
+// GLCALL( glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, 0) );
+
MercuryVBO::m_lastVBOrendered = this;
if (m_dirtyVBO)
{
m_dirtyVBO = false;
- GLCALL( glBufferDataARB(GL_ARRAY_BUFFER_ARB, m_vertexData.LengthInBytes(), m_vertexData.Buffer(), GL_STATIC_DRAW_ARB) );
+ GLCALL( glBufferDataARB(GL_ARRAY_BUFFER_ARB, m_vertexData.LengthInBytes(), m_vertexData.Buffer(), GL_STREAM_DRAW_ARB) );
}
GLCALL( glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT) );
//do render stuff here
-// GLCALL( glDisableClientState(GL_TEXTURE_COORD_ARRAY) );
- Texture::ApplyActiveTextures(ParticleBase::STRIDE*sizeof(float));
+ Texture::ApplyActiveTextures(ParticleBase::STRIDE*sizeof(float), 7*sizeof(float));
GLCALL( glEnableClientState(GL_VERTEX_ARRAY) );
GLCALL( glEnableClientState( GL_COLOR_ARRAY ) ); //used for attributes
+// GLCALL( glDisableClientState( GL_NORMAL_ARRAY ) );
+
GLCALL( glVertexPointer(3, GL_FLOAT, ParticleBase::STRIDE*sizeof(float), BUFFER_OFFSET( 0*sizeof(float) ) ) );
GLCALL( glColorPointer(4, GL_FLOAT, ParticleBase::STRIDE*sizeof(float), BUFFER_OFFSET( 3*sizeof(float) ) ) );
- GLCALL( glTexCoordPointer(3, GL_FLOAT, ParticleBase::STRIDE*sizeof(float), BUFFER_OFFSET( 7*sizeof(float) ) ) );
-// GLCALL( glDrawRangeElements(GL_QUADS, 0, m_indexData.Length()-1, m_indexData.Length(), GL_UNSIGNED_SHORT, NULL) );
-// GLCALL( glDrawElements(GL_QUADS, m_maxParticles*4, GL_UNSIGNED_BYTE, 0) );
GLCALL( glDrawArrays(GL_QUADS, 0, m_maxParticles*4) );
-//printf("darw\n");
+
GLCALL( glPopClientAttrib() );
GLCALL( glPopAttrib() );
+ m_particlesDrawn+=m_maxParticles;
+
base::Render(matrix);
+}
-
+uint32_t ParticleEmitter::ResetDrawnCount()
+{
+ uint32_t t = m_particlesDrawn;
+ m_particlesDrawn = 0;
+ return t;
}
+uint32_t ParticleEmitter::m_particlesDrawn = 0;
+
/****************************************************************************
* Copyright (C) 2009 by Joshua Allen *
* *
Modified: Mercury2/modules/ParticleEmitter.h
===================================================================
--- Mercury2/modules/ParticleEmitter.h 2009-12-24 18:11:04 UTC (rev 638)
+++ Mercury2/modules/ParticleEmitter.h 2009-12-24 18:11:56 UTC (rev 639)
@@ -64,6 +64,8 @@
void SetMaxParticleCount(uint16_t count);
inline void SetDirtyVBO() { m_dirtyVBO=true; }
+ static uint32_t ResetDrawnCount();
+
GENRTTI( ParticleEmitter );
private:
// void DestroyParticles();
@@ -91,6 +93,7 @@
std::list< ParticleBase* > m_active, m_inactive;
// MercuryNode* m_masterParticle;
+ static uint32_t m_particlesDrawn;
};
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|