Created
October 25, 2011 09:03
-
-
Save natxopedreira/1311940 to your computer and use it in GitHub Desktop.
fvbo ejemplo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void testApp::setup(){ | |
ofBackground(0, 0, 0); | |
ofSetVerticalSync(true); | |
ofSetLogLevel(OF_LOG_VERBOSE); | |
ancho = 640; | |
alto = 480; | |
///// lo lleno al tuntun | |
for(int y = 0; y < alto ; y++){ | |
for (int x=0; x<ancho; x++) { | |
int indes = y*ancho+x; | |
vertices[indes].set(ofVec3f( ofRandom(0, 1024),ofRandom(0, 768),ofRandom(-200, 200) )); | |
colores[indes].set(ofRandom(0,1), ofRandom(0,1),ofRandom(0,1)); | |
} | |
} | |
vbo.setVertexData(&vertices[0],maxParticulas, GL_DYNAMIC_DRAW); | |
vbo.setColorData(&colores[0],maxParticulas,GL_DYNAMIC_DRAW); | |
ofDisableArbTex(); | |
bola.loadImage("particula.png"); | |
glPointSize(20); | |
} | |
//-------------------------------------------------------------- | |
void testApp::update(){ | |
for (int t=0;t<maxParticulas;t+=4 ){ | |
vertices[t].set(ofVec2f( ofRandom(0, 1024),ofRandom(0, 768) )); | |
colores[t].set(ofRandom(0,1), ofRandom(0,1),ofRandom(0,1)); | |
} | |
} | |
//-------------------------------------------------------------- | |
void testApp::draw(){ | |
ofBackground(0); | |
ofEnableAlphaBlending(); | |
ofSetHexColor(0xffffff); | |
ofEnablePointSprites(); | |
bola.getTextureReference().bind(); | |
vbo.updateVertexData(&vertices[0],maxParticulas); | |
vbo.updateColorData(&colores[0],maxParticulas); | |
vbo.draw(GL_POINTS, 0,maxParticulas); | |
bola.getTextureReference().unbind(); | |
ofDisablePointSprites(); | |
ofDisableAlphaBlending(); | |
ofSetColor(255, 255, 255); | |
string info = "FPS: "+ofToString(ofGetFrameRate()); | |
info += "\nTotal Particles: "+ofToString(maxParticulas); | |
ofDrawBitmapString(info, 20, 20); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment