Vertex Shader:
uniform float Time;
uniform float scr_h;
void main()
{
vec4 newpos = gl_Vertex;
newpos.xyz += gl_Color.xyz*(Time - gl_Color.w); // move the sprite based on velocity
vec3 particle = vec3(gl_ModelViewMatrix * newpos); // scale point sprite for perspective
gl_PointSize = scr_h / sqrt(dot(particle, particle));
gl_Position = gl_ModelViewProjectionMatrix * newpos;
}
C++ part:
glUniform1f(ptime, float(SDL_GetTicks()/1000.0)); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glUniform1f(pr_scrh, float(screen->h)); glBindBuffer(GL_ARRAY_BUFFER, Vbuffer); glBufferData(GL_ARRAY_BUFFER, particle::getNumParticles() * 3 * sizeof(float), particle::get(), GL_STATIC_DRAW); glVertexPointer(3, GL_FLOAT, 0, 0); glBindBuffer(GL_ARRAY_BUFFER, Tbuffer); glBufferData(GL_ARRAY_BUFFER, particle::getNumParticles() * 4 * sizeof(float), particle::getVelocityTime(), GL_STATIC_DRAW); glColorPointer(3, GL_FLOAT, 0, 0); glDrawArrays(GL_POINTS, 0, particle::getNumParticles() * 3); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_COLOR_ARRAY);
Anything obvious wrong with my code or even my approach?
P.S. don't bother telling me if anything I'm using is deprecated because this is targeted for OpenGL 2.1
Edited by ic0de, 22 October 2012 - 09:57 PM.






