Hi All
I have a little confusion with ofFbo. currently i understand it as using the frame rate almost as a for loop to draw objects (please correct me if im wrong).
My problem lies with trying to speed up my code, a particle system, after ive written a ton of for loops.
another thing im struggling to grasp is how do i use it in the classes i create?
for example, I’ve created a particle class with a Particle.draw() function , where do i put all this stuff : Fbo.allocate(ofGetWidth(), ofGetHeight());
Fbo.begin();
Fbo.clear();
Fbo.end();
and where do i initilise the fbo class? in the main or the class?
heres my particle class header file
#pragma once
#include "ofMain.h"
class Particle
{
ofVec2f position;
ofVec2f velocity;
ofVec2f acceleration;
ofVec2f gravity = ofVec2f(0.0,0.1);
int p_radius = 2;
float fluid_density = 0.3;
float p_bounciness = 0.9;
int bounces_y;
int bounces_x;
ofVec2f reacting_force;
ofVec2f drag(ofVec2f vector);
void next_frame();
void sum_vectors(ofVec2f ex_force, bool collision = false);
public:
Particle();
Particle(int pos_x, int pos_y, int p_rad);
void setup(int pos_x, int pos_y, int p_rad);
void update();
void draw();
void set_bounciness(float i);
void set_fluid_density(float i);
void set_p_radius(int i);
void reset_bounces();
ofVec2f get_pos();
int get_p_rad();
void add_force(ofVec2f force);
ofVec2f null_vector;
void debug();
};
here’s some of the important methods
#include "Particle.h"
Particle::Particle() {
}
Particle::Particle(int pos_x, int pos_y, int p_rad) {
position.set(pos_x, pos_y);
p_radius = p_rad;
null_vector.set(0, 0);
}
void Particle::setup(int pos_x, int pos_y, int p_rad) {
position.set(pos_x, pos_y);
p_radius = p_rad;
null_vector.set(0, 0);
}
void Particle::update() {
//debug();
next_frame();
//acceleration.set(0, 0);
}
void Particle::draw() {
ofDrawCircle(position.x, position.y, p_radius);
Help will be much appreciated, i’m still very much a beginner so any nudges in the right direction will help loads
Thanks!!