Exemplo n.º 1
0
def writeShader(shader, cppFileName, variableName):

    
    fout = osgDB.ofstream(cppFileName.c_str())
    if  not fout :
        print "Error: could not open file `", cppFileName, "` for writing."

    shaderSource = shader.getShaderSource()
    searchAndReplace(shaderSource, "\r\n", "\n")
    searchAndReplace(shaderSource, "\r", "\n")
    searchAndReplace(shaderSource, "\"", "\\\"")
 
    variableString = str("char ")+variableName+str("[] = ")
    
    startOfLine = 0
    endOfLine = shaderSource.find_first_of('\n', startOfLine)
    
    if endOfLine==str.npos : 
        fout, variableString, shaderSource, "\\n\""
    else:
        padding = str(variableString.size(),ord(" "))

        fout, variableString, "\"", shaderSource.substr(startOfLine,endOfLine-startOfLine), "\\n\""
        startOfLine = endOfLine+1
        endOfLine = shaderSource.find_first_of('\n', startOfLine)

        while endOfLine  not = str.npos :
            fout, padding, "\"", shaderSource.substr(startOfLine,endOfLine-startOfLine), "\\n\""
            startOfLine = endOfLine + 1
            endOfLine = shaderSource.find_first_of('\n', startOfLine)
        fout, padding, "\"", shaderSource.substr(startOfLine,endOfLine-startOfLine), "\\n\""
Exemplo n.º 2
0
def writeShader(shader, cppFileName, variableName):

    
    fout = osgDB.ofstream(cppFileName.c_str())
    if  not fout :
        print "Error: could not open file `", cppFileName, "` for writing."

    shaderSource = shader.getShaderSource()
    searchAndReplace(shaderSource, "\r\n", "\n")
    searchAndReplace(shaderSource, "\r", "\n")
    searchAndReplace(shaderSource, "\"", "\\\"")
 
    variableString = str("char ")+variableName+str("[] = ")
    
    startOfLine = 0
    endOfLine = shaderSource.find_first_of('\n', startOfLine)
    
    if endOfLine==str.npos : 
        fout, variableString, shaderSource, "\\n\""
    else:
        padding = str(variableString.size(),ord(" "))

        fout, variableString, "\"", shaderSource.substr(startOfLine,endOfLine-startOfLine), "\\n\""
        startOfLine = endOfLine+1
        endOfLine = shaderSource.find_first_of('\n', startOfLine)

        while endOfLine  not = str.npos :
            fout, padding, "\"", shaderSource.substr(startOfLine,endOfLine-startOfLine), "\\n\""
            startOfLine = endOfLine + 1
            endOfLine = shaderSource.find_first_of('\n', startOfLine)
        fout, padding, "\"", shaderSource.substr(startOfLine,endOfLine-startOfLine), "\\n\""
    print "Written shader to `", cppFileName, "`"
Exemplo n.º 3
0
        
        header.thumbnail_s = thumbnailSize
        header.thumbnail_t = thumbnailSize
        header.thumbnail_position = 0
        
        header.fullsize_s = thumbnailSize
        header.fullsize_t = thumbnailSize
        header.fullsize_position = 0

        photoIndex.push_back(header)
        

    print "Building photo archive containing ", photoIndex.size(), " pictures"

    # open up the archive for writing to
    out = osgDB.ofstream(filename.c_str(), std.ios.out | std.ios.binary)

    # write out file indentifier.
    out.write(FILE_IDENTIFER.c_str(),FILE_IDENTIFER.size())

    numPhotos = photoIndex.size()
    out.write((char*)numPhotos,sizeof(unsigned int))

    # write the photo index to ensure we can the correct amount of space
    # available.
    startOfPhotoIndex = out.tellp()
    out.write((char*)photoIndex.front(),sizeof(PhotoHeader)*photoIndex.size())

    photoCount = 1    
    for(PhotoIndexList.iterator pitr=photoIndex.begin()
        not = photoIndex.end()