void ofxPanel::render(){ border.draw(); headerBg.draw(); ofBlendMode blendMode = ofGetStyle().blendingMode; if(blendMode!=OF_BLENDMODE_ALPHA){ ofEnableAlphaBlending(); } ofColor c = ofGetStyle().color; ofSetColor(thisTextColor); bindFontTexture(); textMesh.draw(); unbindFontTexture(); bool texHackEnabled = ofIsTextureEdgeHackEnabled(); ofDisableTextureEdgeHack(); loadIcon.draw(loadBox); saveIcon.draw(saveBox); if(texHackEnabled){ ofEnableTextureEdgeHack(); } for(int i = 0; i < (int)collection.size(); i++){ collection[i]->draw(); } ofSetColor(c); if(blendMode!=OF_BLENDMODE_ALPHA){ ofEnableBlendMode(blendMode); } }
//-------------------------------------------------------------- void testApp::setup() { #ifdef RELEASE ofSetFrameRate(30); #endif ofSetBackgroundAuto(false); // erase manually ofDisableTextureEdgeHack(); // roger: solves ofTexture minor scale/blur ofDisableArbTex(); ofFill(); glDisable(GL_DEPTH_TEST); counter = 0; }
void ofxPanel::render(){ border.draw(); headerBg.draw(); ofBlendMode blendMode = ofGetStyle().blendingMode; if(blendMode!=OF_BLENDMODE_ALPHA){ ofEnableAlphaBlending(); } ofColor c = ofGetStyle().color; ofSetColor(thisTextColor); bindFontTexture(); textMesh.draw(); unbindFontTexture(); bool texHackEnabled = ofIsTextureEdgeHackEnabled(); ofDisableTextureEdgeHack(); // loadIcon.draw(loadBox); // saveIcon.draw(saveBox); if(isDynamic){ ofSetColor(255,0,0); if(*isActive){ ofFill(); } else ofNoFill(); ofRect(activeBox); ofSetColor(0,255,0); if(*isPiping){ ofFill(); } else ofNoFill(); ofRect(pipeBox); } if(texHackEnabled){ ofEnableTextureEdgeHack(); } for(int i = 0; i < (int)collection.size(); i++){ collection[i]->draw(); } ofSetColor(c); if(blendMode!=OF_BLENDMODE_ALPHA){ ofEnableBlendMode(blendMode); } }
void ofxPanel::render(){ this->prerender(); ofColor c; ofBlendMode blendMode; bool performDraw = !useFbo || requiresRerender; if( performDraw ){ border.draw(); headerBg.draw(); blendMode = ofGetStyle().blendingMode; if(blendMode!=OF_BLENDMODE_ALPHA){ ofEnableAlphaBlending(); } c = ofGetStyle().color; ofSetColor(thisTextColor); bindFontTexture(); textMesh.draw(); unbindFontTexture(); bool texHackEnabled = ofIsTextureEdgeHackEnabled(); ofDisableTextureEdgeHack(); loadIcon.draw(loadBox); saveIcon.draw(saveBox); if(texHackEnabled){ ofEnableTextureEdgeHack(); } } int len = (int)collection.size(); for(int i = 0; i < len; i++){ collection[i]->draw(useFbo); } if( performDraw ){ ofSetColor(c); if(blendMode!=OF_BLENDMODE_ALPHA){ ofEnableBlendMode(blendMode); } requiresRerender = false; } this->postrender(); }
//-------------------------------------------------------------- void testApp::setup(){ ofDisableTextureEdgeHack(); ofDirectory dir; dir.allowExt("mp4"); dir.allowExt("avi"); dir.allowExt("mov"); dir.allowExt("m4v"); dir.listDir("/Volumes/data_RAID/Downloads/Videos/test"); video.load(dir.getPath(int(ofRandom(dir.getFiles().size()))),true); video.play(); ofBackground(0); ofSetVerticalSync(true); gui.setup(""); gui.add(x.set("x",0,-2000,2000)); gui.add(y.set("y",0,-2000,2000)); gui.add(z.set("z",0,-2000,2000)); //fbo.allocate(ofGetWidth(),ofGetHeight(),GL_RGB); }
//----------------------------------------------------------------------------------------- // void ofApp::setup() { fontSmall.loadFont("Fonts/DIN.otf", 8 ); // Give us a starting point for the camera camera.setNearClip(0.01f); camera.setPosition( 0, 4, 10 ); camera.setMovementMaxSpeed( 0.1f ); int textureSize = 128; int numParticles = textureSize * textureSize; // Allocate buffers ofFbo::Settings fboSettings; fboSettings.width = textureSize; fboSettings.height = textureSize; // We can create several color buffers for one FBO if we want to store velocity for instance, // then write to them simultaneously from a shader using gl_FragData[0], gl_FragData[1], etc. fboSettings.numColorbuffers = 1; fboSettings.useDepth = false; fboSettings.internalformat = GL_RGBA32F; // Gotta store the data as floats, they won't be clamped to 0..1 fboSettings.textureTarget = GL_TEXTURE_2D; fboSettings.wrapModeHorizontal = GL_CLAMP_TO_EDGE; fboSettings.wrapModeVertical = GL_CLAMP_TO_EDGE; fboSettings.minFilter = GL_NEAREST; // No interpolation, that would mess up data reads later! fboSettings.maxFilter = GL_NEAREST; ofDisableTextureEdgeHack(); particleData.allocate( fboSettings ); ofEnableTextureEdgeHack(); particleMaxAge = 4.0; }
//-------------------------------------------------------------- void ofApp::setup(){ ofBackground(34, 34, 34); ofSetVerticalSync(true); ofSetFrameRate(0); // ofDisableAntiAliasing(); ofDisableLighting(); // ofDisableAlphaBlending(); // ofEnableNormalizedTexCoords(); // ofDisableArbTex(); ofEnableArbTex(); // ofDisableNormalizedTexCoords(); ofDisableTextureEdgeHack(); // ofDisableSmoothing(); ofSetMinMagFilters(GL_NEAREST, GL_NEAREST); // ofEnableAlphaBlending(); img_size = 4096.; fbo_size = 8192.; w = img_size; h = img_size; scale_display = 5.7; scale_target = scale_display; // colorPixels = new unsigned char [w*h*3]; doShader = true; frame_num = 0; record_num = 0; time_step = 0; pick_step = 1; animate = false; camera_lock = false; camera_home = false; record = false; showFPS = false; font.loadFont("type/verdana.ttf", 10); quad.clear(); quad.setMode(OF_PRIMITIVE_TRIANGLE_STRIP); quad.addVertex(ofVec3f(0, 0, 0)); quad.addVertex(ofVec3f(w, 0, 0)); quad.addVertex(ofVec3f(0, h, 0)); quad.addVertex(ofVec3f(w, h, 0)); img_00.loadImage("images/d7f_4k_01.png"); img_01.loadImage("images/d7f_4k_02.png"); img_02.loadImage("images/d7f_4k_03.png"); img_03.loadImage("images/d7f_4k_04.png"); // img_00.loadImage("images/micro_01.jpg"); // img_01.loadImage("images/micro_02.jpg"); // img_02.loadImage("images/micro_03.jpg"); // img_03.loadImage("images/micro_04.jpg"); ///////////////////////////////////////////////////////////////////////////// // Framebuffers, allocation, etc ///////////////////////////////////////////////////////////////////////////// // height.allocate(w,h,GL_RGB); height0.allocate(w,h,GL_RGB); height1.allocate(w,h,GL_RGB); height2.allocate(w,h/2,GL_RGB); height3.allocate(w,h/2,GL_RGB); // height_old.allocate(w,h,GL_RGB); // height_backup.allocate(w,h,GL_RGB); display.allocate(ofGetWidth(),ofGetHeight(),GL_RGB); // height_FBO.allocate(w,h,GL_RGB); height_Fbo0.allocate(w,h,GL_RGB); height_Fbo1.allocate(w,h,GL_RGB); height_Fbo2.allocate(w,h/2,GL_RGB); height_Fbo3.allocate(w,h/2,GL_RGB); // height_old_FBO.allocate(w,h,GL_RGB); height_old_Fbo0.allocate(w,h,GL_RGB); height_old_Fbo1.allocate(w,h,GL_RGB); height_old_Fbo2.allocate(w,h/2,GL_RGB); height_old_Fbo3.allocate(w,h/2,GL_RGB); // height_backup_FBO.allocate(w,h,GL_RGB); height_backup_Fbo0.allocate(w,h,GL_RGB); height_backup_Fbo1.allocate(w,h,GL_RGB); height_backup_Fbo2.allocate(w,h/2,GL_RGB); height_backup_Fbo3.allocate(w,h/2,GL_RGB); ClearFramebuffers(); DisableInterpolation(); ///////////////////////////////////////////////////////////////////////////// // end framebuffers ///////////////////////////////////////////////////////////////////////////// // #ifdef TARGET_OPENGLES // shader.load("shaders_gles/noise.vert","shaders_gles/noise.frag"); // #else if(ofGetGLProgrammableRenderer()){ shader.load("shaders_gl3/noise.vert", "shaders_gl3/noise.frag"); waveShader.load("shaders_gl3/wave.vert", "shaders_gl3/wave.frag"); waveShaderTiled.load("shaders_gl3/wave_tiled.vert", "shaders_gl3/wave_tiled.frag"); waveShader_display.load("shaders_gl3/wave_DISPLAY.vert", "shaders_gl3/wave_DISPLAY.frag"); waveShader_displayTiled.load("shaders_gl3/wave_DISPLAY_tiled.vert", "shaders_gl3/wave_DISPLAY_tiled.frag"); waveShaderMod.load("shaders_gl3/wave_mod.vert", "shaders_gl3/wave_mod.frag"); } else{ shader.load("shaders/noise.vert", "shaders/noise.frag"); } // #endif }
//----------------------------------------------------------------------------------------- // void ParticleSystemInstancedGeometryGPU::init( int _texSize ) { string xmlSettingsPath = "Settings/Particles.xml"; gui.setup( "Particles", xmlSettingsPath ); gui.add( particleMaxAge.set("Particle Max Age", 10.0f, 0.0f, 20.0f) ); gui.add( noiseMagnitude.set("Noise Magnitude", 0.075, 0.01f, 1.0f) ); gui.add( noisePositionScale.set("Noise Position Scale", 1.5f, 0.01f, 5.0f) ); gui.add( noiseTimeScale.set("Noise Time Scale", 1.0 / 4000.0, 0.001f, 1.0f) ); gui.add( noisePersistence.set("Noise Persistence", 0.2, 0.001f, 1.0f) ); gui.add( baseSpeed.set("Wind", ofVec3f(0.5,0,0), ofVec3f(-2,-2,-2), ofVec3f(2,2,2)) ); gui.add( startColor.set("Start Color", ofColor::white, ofColor(0,0,0,0), ofColor(255,255,255,255)) ); gui.add( endColor.set("End Color", ofColor(0,0,0,0), ofColor(0,0,0,0), ofColor(255,255,255,255)) ); //gui.add( twistNoiseTimeScale.set("Twist Noise Time Scale", 0.01, 0.0f, 0.5f) ); //gui.add( twistNoisePosScale.set("Twist Noise Pos Scale", 0.25, 0.0f, 2.0f) ); //gui.add( twistMinAng.set("Twist Min Ang", -1, -5, 5) ); //gui.add( twistMaxAng.set("Twist Max Ang", 2.5, -5, 5) ); gui.add( materialShininess.set("Material Shininess", 20, 0, 127) ); gui.add( materialAmbient.set("Material Ambient", ofColor(50,50,50), ofColor(0,0,0,0), ofColor(255,255,255,255)) ); gui.add( materialSpecular.set("Material Specular", ofColor(255,255,255), ofColor(0,0,0,0), ofColor(255,255,255,255)) ); gui.add( materialEmissive.set("Material Emmissive", ofColor(0,0,0), ofColor(0,0,0,0), ofColor(255,255,255,255)) ); gui.loadFromFile( xmlSettingsPath ); gui.minimizeAll(); gui.setPosition( ofGetWidth() - gui.getWidth() - 10, 10 ); // Load shaders particleUpdate.load("Shaders/Particles/GL2/Update"); particleDraw.load("Shaders/Particles/GL2/DrawInstancedGeometry"); // Set how many particles we are going to have, this is based on data texture size textureSize = 128; numParticles = textureSize * textureSize; // Allocate buffers ofFbo::Settings fboSettings; fboSettings.width = textureSize; fboSettings.height = textureSize; // We can create several color buffers for one FBO if we want to store velocity for instance, // then draw to them simultaneously from a shader using gl_FragData[0], gl_FragData[1], etc. fboSettings.numColorbuffers = 2; fboSettings.useDepth = false; fboSettings.internalformat = GL_RGBA32F; // Gotta store the data as floats, they won't be clamped to 0..1 fboSettings.textureTarget = GL_TEXTURE_2D; fboSettings.wrapModeHorizontal = GL_CLAMP_TO_EDGE; fboSettings.wrapModeVertical = GL_CLAMP_TO_EDGE; fboSettings.minFilter = GL_NEAREST; // No interpolation, that would mess up data reads later! fboSettings.maxFilter = GL_NEAREST; ofDisableTextureEdgeHack(); particleDataFbo.allocate( fboSettings ); ofEnableTextureEdgeHack(); // We are going to encode our data into the FBOs like this // // Buffer 1: XYZ pos, W age // Buffer 2: XYZ vel, W not used // // Initialise the starting and static data ofVec4f* startPositionsAndAge = new ofVec4f[numParticles]; int tmpIndex = 0; for( int y = 0; y < textureSize; y++ ) { for( int x = 0; x < textureSize; x++ ) { ofVec3f pos(0,0,0); //ofVec3f pos (MathUtils::randomPointOnSphere() * 0.1); //pos.set( ofRandom(-1,1), ofRandom(0,2), ofRandom(-1,1) ); float startAge = ofRandom( particleMaxAge ); // position is not very important, but age is, by setting the lifetime randomly somewhere in the middle we can get a steady stream emitting startPositionsAndAge[tmpIndex] = ofVec4f( pos.x, pos.y, pos.z, startAge ); tmpIndex++; } } // Upload it to the source texture particleDataFbo.source()->getTextureReference(0).loadData( (float*)&startPositionsAndAge[0].x, textureSize, textureSize, GL_RGBA ); ofPrimitiveMode primitiveMode = OF_PRIMITIVE_TRIANGLES; // as we'll be drawing ths mesh instanced many times, we need to have many triangles as opposed to one long triangle strip ofMesh tmpMesh; ofConePrimitive cone( 0.1, 0.1, 5, 2, primitiveMode ); //tmpMesh = cone.getMesh(); ofBoxPrimitive box( 0.0015, 0.0015, 0.01 ); // we gotta face in the -Z direction tmpMesh = box.getMesh(); singleParticleMesh.append( tmpMesh ); singleParticleMesh.setMode( primitiveMode ); }