コード例 #1
0
ファイル: terrain.cpp プロジェクト: crvv/simple
void Terrain::loadModel() {
    std::ifstream patchFile("model/patch", std::ios::binary);
    std::ifstream terrainFile("model/terrain", std::ios::binary);
    if (!patchFile.good() || !terrainFile.good()) {
        throw std::runtime_error("unable to read file");
    }
    std::vector<GLfloat> vertices;
    std::vector<GLuint> indices;
    std::vector<GLfloat> terrain;
    GLuint terrainSidePointCount;

    ModelUtils::readFileToValue(patchFile, vertices, indices);
    ModelUtils::readFileToValue(terrainFile, terrainSideLength, terrainSidePointCount, terrain);

    vertexCount = static_cast<GLsizei>(indices.size());
    vao->addElementBuffer(indices, GL_STATIC_DRAW);
    vao->addVertexAttribBuffer(0, 2, GL_FLOAT, vertices, GL_STATIC_DRAW);

    texture = std::make_shared<Texture>(GL_TEXTURE_2D, terrainSidePointCount, terrain);

}
コード例 #2
0
ファイル: readTRN.cpp プロジェクト: Mesagoppinmypants/Tools
int main( int argc, char **argv )
{

    if( 2 != argc )
    {
	std::cout << "readTRN <file>" << std::endl;
	return 0;
    }

    std::ifstream terrainFile( argv[1], std::ios_base::binary );

    if( !terrainFile.is_open() )
    {
	std::cout << "Unable to open file: " << argv[1] << std::endl;
	throw std::exception();
    }

    ml::trn terrain;
    terrain.readTRN( terrainFile );

    terrainFile.close();

    return 0;
}