コード例 #1
0
 SafeShader::SafeShader( ci::DataSourceRef vertexShader, ci::DataSourceRef fragmentShader, ci::DataSourceRef geometryShader,
        GLint geometryInputType, GLint geometryOutputType, GLint geometryOutputVertices)
 {
     
     try {
         mObj = shared_ptr<Obj>( new Obj );
         
         mObj->mHandle = glCreateProgram();
         
         if ( vertexShader )
             loadShader( vertexShader->getBuffer(), GL_VERTEX_SHADER_ARB );
         
         if( fragmentShader )
             loadShader( fragmentShader->getBuffer(), GL_FRAGMENT_SHADER_ARB );
         
         if( geometryShader ) {
             loadShader( geometryShader->getBuffer(), GL_GEOMETRY_SHADER_EXT );
             
             glProgramParameteriEXT(mObj->mHandle, GL_GEOMETRY_INPUT_TYPE_EXT, geometryInputType);
             glProgramParameteriEXT(mObj->mHandle, GL_GEOMETRY_OUTPUT_TYPE_EXT, geometryOutputType);
             glProgramParameteriEXT(mObj->mHandle, GL_GEOMETRY_VERTICES_OUT_EXT, geometryOutputVertices);
         }
         
         link();
     }
     catch( gl::GlslProgCompileExc exc ){
         cout << exc.what() << endl;
     }
 }
コード例 #2
0
string AudioDevice::registerSound(ci::DataSourceRef dataSource, bool looping, bool is3d, bool asStream)
{
    ci::fs::path relativePath = dataSource->getFilePath();
    if( relativePath.empty() )
        relativePath = ci::fs::path( dataSource->getFilePathHint() );
    return registerSound(relativePath, is3d, looping, asStream);
}
コード例 #3
0
ファイル: Shader.cpp プロジェクト: simongeilfus/Cinder-Shader
void Shader::loadShader( ci::DataSourceRef shaderSourceRef, GLint shaderType, GLint geometryInputType, GLint geometryOutputType, GLint geometryOutputVertices )
{
    if( shaderSourceRef ){
        mSource[shaderType] = shaderSourceRef;
        mLastTime[shaderType] = ci::fs::last_write_time( shaderSourceRef->getFilePath() );
        GlslProg::loadShader( shaderSourceRef->getBuffer(), shaderType );
    
        if( shaderType == GL_GEOMETRY_SHADER_EXT ){
            glProgramParameteriEXT(mObj->mHandle, GL_GEOMETRY_INPUT_TYPE_EXT, geometryInputType);
            glProgramParameteriEXT(mObj->mHandle, GL_GEOMETRY_OUTPUT_TYPE_EXT, geometryOutputType);
            glProgramParameteriEXT(mObj->mHandle, GL_GEOMETRY_VERTICES_OUT_EXT, geometryOutputVertices);
            
            mGeometryData = GeomData( geometryInputType, geometryOutputType, geometryOutputVertices );
        }
    }
}
コード例 #4
0
ファイル: ShaderSet.cpp プロジェクト: field/Sketchbook
    std::map<std::string, std::string> splitShaderSource(ci::DataSourceRef source)
    {
        using namespace std;
        
        ci::Buffer buffer = source->getBuffer();
        string str(static_cast<char*>(buffer.getData()), buffer.getDataSize());
        
        string del("---");
        vector<string> splitted;
        
        split(str, del, insert_iterator<vector<string> >(splitted, splitted.begin()));
        \
        vector<string>::iterator it = splitted.begin();
        ++it; // skip header
        
        map<string, string> sources;
        for(; it != splitted.end(); ++it) {    
            string key(*it);
            ++it;
            string value(*it);
            sources.insert( pair<string, string>(key, value) );
//            printf("key '%s' '%s'", key.c_str(), value.c_str());
        }
        return sources;
    }
コード例 #5
0
ファイル: License.cpp プロジェクト: bgbotond/License
void License::setKey( ci::DataSourceRef dataSource )
{
	Buffer buf = dataSource->getBuffer();
	size_t dataSize = buf.getDataSize();
	shared_ptr<char> bufString( new char[dataSize+1], checked_array_deleter<char>() );
	memcpy( bufString.get(), buf.getData(), buf.getDataSize() );
	bufString.get()[dataSize] = 0;
	string publicKey( bufString.get() );

	mPublicKey = publicKey;
}