its very very basic and is aimed more at showing those who don’t know how to use the mentioned things. You can easily get hundreds of thousands of basic particles, if not millions at decent framerates (depending on hardware of course).
You will need to hack ofTexture.cpp to only use GL_TEXTURE_2D…
check testApp::keyPressed to see what keys do what…
yup, for 006 you just need to add texData like martignasse mentioned.
In addition, you don’t need to hack ofTexture to always use GL_TEXTURE_2D, but you can do it externally by just calling ofDisableArbTex() once (e.g. in your setup, this disables the use of GL_TEXTURE_RECTANGLE_ARB). After you’ve loaded the texture you want to use for the point sprite, you can re-enable GL_TEXTURE_RECTANGLE_ARB by calling ofEnableArbTex() if you want to create new textures (e.g. load images etc.) and use rectangular textures for them.
P.S. it will be more optimal to use square power of two textures (e.g. 128x128, 256x256, 512x512, 1024x1024 - if your card supports it).
Yup, when you’re cycling through the vector of particles updating them, also write their position and color to arrays to be sent to the card (I think thats what the example is already doing, though with arrays instead of vectors).
How would i get pos and col to be from the particles vector? Do i create a new pos and col array every frame? For numParticles i would just use particles.size(), but im stuck after that.
I’ve not encountered this problem cos I generally use a fixed size array of particles, capped to a predetermined maximum size, and whenever I need to add a new particle, I just reset the oldest particle (that way I have control over the maximum number of particles, so system can’t grind to a halt under heavy circumstances, and also no object creation or deletion happening every frame).
In your case, you could create a vector for pos and another vector for col as well. Everytime you add or remove a particle, you’d need to add or remove from the pos and col vectors as well. Then you can pass &pos[0] as your position buffer (pointer to the first element in the vector, which stores all data sequentially so you can use it as a normal array).
Maybe there is a better/more efficient way but isn’t popping into my head right now.
Adding and removing from a vectors for particles gets very slow when you get to large numbers of particles, so you should use a fixed size array for your particles.
i.e. have MAX_PARTICLES and NUM_PARTICLES
like memo said, knowing which index in the array to use is the trouble. I have a list of particles that are alive, and when adding new particles look up an index to use from the list of particles that are dead.
Also when you loop through to update the arrays for the vbo, you need to loop through the number of alive particles, and not the maximum number of particles, which is where my list of alive particles comes in.
i download your file but all its ok, i see your error and maybe you maybe not foloww the correct process…
Copy the alladdonfiles Projects to the folder apps/addonsExamples and change to name, and copy and paste the files Main.cpp, TespApp.cpp, TestApp.h, MSAImage.h, MSATexture.h, in src folder like your example, and add by hand to the project in visual Studio, and look if you can see the files in your branch folder… and run…
If not solution your problem adviceme and i install visual in my house because muy compnay only works in codebloks…
so each particle has a ribbon trail of MAX_TRAIL_LENGTH
with two vertex for each point on the ribbon.
currently im drawing using glBegin( GL_QUAD_STRIP ) although would like to optimise using VBOs.
with this point sprite example, im assuming its just grabbing every 2 vertex in the vertex array and using them as the location to draw the point sprite.
do i have to use a VBO for each trail?
or is there a way i can pass in my trail vertex and colour arrays into to VBO to render all at once?
Strange - I’ve compiled this under 0.06 with the changes to MSATexture.h and it runs fine with no errors, but the framerate are low and don’t seem to make sense to me. With the default settings, I’m getting ~12fps with the useVA:0 and useVBO:0. Turning the VBO and or Vertex Array on actually makes it slightly slower by about 1fps!
Hi.
I just compiled the latest files under OF06 and updated MSATexture.h with the one uploaded in this thread.
The compiler gave me two errors. Both are
'struct ofTextureData' has no member named 'textureName'
so I changed both the
texData.textureName[0]
into
texData.textureID
Now the application compiles and runs but I get just a screen with a changing background (and indications on the current FPR, particles count etc) BUT NO PARTICLES.
Hey all, sorry for not updating the example sooner, been a bit busy.
In 006+ actually it is much simpler, you don’t need MSAImage or MSATexture at all as the required functionality is now in the core. You can use a plain old ofImage. Updated example at http://www.memo.tv/vertex-arrays-vbos-a-…-eworks-006