// --------------------------------------------------------------------------------------------------------------------------------------------------- // bool ofxAutoReloadedShader::load(string vertName, string fragName, string geomName) { unload(); ofShader::setGeometryOutputCount(geometryOutputCount); ofShader::setGeometryInputType(geometryInputType); ofShader::setGeometryOutputType(geometryOutputType); // hackety hack, clear errors or shader will fail to compile GLuint err = glGetError(); lastTimeCheckMillis = ofGetElapsedTimeMillis(); setMillisBetweenFileCheck( 2 * 1000 ); enableWatchFiles(); loadShaderNextFrame = false; vertexShaderFilename = vertName; fragmentShaderFilename = fragName; geometryShaderFilename = geomName; vertexShaderFile.clear(); fragmentShaderFile.clear(); geometryShaderFile.clear(); vertexShaderFile = ofFile( ofToDataPath( vertexShaderFilename ) ); fragmentShaderFile = ofFile( ofToDataPath( fragmentShaderFilename ) ); geometryShaderFile = ofFile( ofToDataPath( geometryShaderFilename ) ); ofBuffer vertexShaderBuffer = ofBufferFromFile( ofToDataPath( vertexShaderFilename ) ); ofBuffer fragmentShaderBuffer = ofBufferFromFile( ofToDataPath( fragmentShaderFilename ) ); ofBuffer geometryShaderBuffer = ofBufferFromFile( ofToDataPath( geometryShaderFilename ) ); fileChangedTimes.clear(); fileChangedTimes.push_back( getLastModified( vertexShaderFile ) ); fileChangedTimes.push_back( getLastModified( fragmentShaderFile ) ); fileChangedTimes.push_back( getLastModified( geometryShaderFile ) ); if( vertexShaderBuffer.size() > 0 ) { setupShaderFromSource(GL_VERTEX_SHADER, vertexShaderBuffer.getText() ); } if( fragmentShaderBuffer.size() > 0 ) { setupShaderFromSource(GL_FRAGMENT_SHADER, fragmentShaderBuffer.getText()); } #ifndef TARGET_OPENGLES if( geometryShaderBuffer.size() > 0 ) { setupShaderFromSource(GL_GEOMETRY_SHADER_EXT, geometryShaderBuffer.getText()); } #endif bindDefaults(); return linkProgram(); }
//-------------------------------------------------------------- bool ofShader::load(string vertName, string fragName, string geomName) { if(vertName.empty() == false) setupShaderFromFile(GL_VERTEX_SHADER, vertName); if(fragName.empty() == false) setupShaderFromFile(GL_FRAGMENT_SHADER, fragName); #ifndef TARGET_OPENGLES if(geomName.empty() == false) setupShaderFromFile(GL_GEOMETRY_SHADER_EXT, geomName); #endif if(ofIsGLProgrammableRenderer()){ bindDefaults(); } return linkProgram(); }