Mzq
Mzq

Reputation: 1854

glDrawArrays,dynamically change the number of points being drawn?

I have a key function/event allows user to decrease “numParticles”

   glDrawArrays( GL_POINTS, 0, numParticles );

But changing this variable only does not change the number of points being draw

So I have to modify the original “vertices” array?

Now, I have added

glClear(GL_COLOR_BUFFER_BIT);

I can see the number of points are changing now.

But after decreasing “numParticles” to zero, there are still points left on the screen?

Also it doesn't seem to effect the points updated by a shader?

Code

Upvotes: 1

Views: 494

Answers (1)

kravemir
kravemir

Reputation: 10986

You have bug in your header:

static int numParticles = 50000;

This will create the local variable for each object( file ), then object draw.o will be having its own variable, which ogl2particle.o don't change. Instead you should use:

extern int numParticles = 50000;

And in any, but only one file:

int numParticles = 50000;

You can read something abou global variables in c at http://en.wikipedia.org/wiki/External_variable

Upvotes: 0

Related Questions