예제 #1
0
    void StaticGeometryBuffer::build( DrawHint drawHint )
	{
		if(getVertexProperties() & TANGENTS)
			_generateTangents();

		_generateIndices();
		
		
        if( _vertexBufferHandle == 0 )
            glGenBuffers( 1, &_vertexBufferHandle );

        if( _indexBufferHandle == 0 )
            glGenBuffers( 1, &_indexBufferHandle );
		
        int vCount = getVertexCount();
        int iCount = getIndexCount();

        glBindBuffer( GL_ARRAY_BUFFER,          _vertexBufferHandle );
        glBufferData( GL_ARRAY_BUFFER,          sizeof( Vertex ) * _vertexList.size(), &_vertexList[ 0 ], drawHint );
        //glBufferSubData( GL_ARRAY_BUFFER, 0,    sizeof( Vertex ) * _vertexList.size(), &_vertexList[ 0 ] );


        glBindBuffer( GL_ELEMENT_ARRAY_BUFFER,          _indexBufferHandle );
        glBufferData( GL_ELEMENT_ARRAY_BUFFER,          sizeof( GLuint ) * _indexList.size(), &_indexList[ 0 ] , drawHint );
       // glBufferSubData( GL_ELEMENT_ARRAY_BUFFER, 0,    sizeof( GLuint ) * _indexList.size(), &_indexList[ 0 ] );
	}
예제 #2
0
    void StaticGeometryBuffer::build( 
		Vertex *	vertexList,   
		uint		vertCount,
        uint *		indexList,   
		uint		indexCount,
        DrawHint	drawHint )
	{

		_vertexList.clear();

		for( uint i = 0; i < vertCount; ++i )
			_vertexList.push_back( vertexList[ i ] );


        if( indexList == NULL || indexCount == 0 )
        {
            _generateIndices();
        }
		else
		{
			_indexList.clear();

			for( uint i = 0; i < indexCount; ++i )
				_indexList.push_back( indexList[ i ] );
		}

		
		if( getVertexProperties() & TANGENTS )
			_generateTangents();

        if( _vertexBufferHandle == 0 )
            glGenBuffers( 1, &_vertexBufferHandle );

        if( _indexBufferHandle == 0 )
            glGenBuffers( 1, &_indexBufferHandle );
		

        glBindBuffer( GL_ARRAY_BUFFER,          _vertexBufferHandle );
        glBufferData( GL_ARRAY_BUFFER,          sizeof( Vertex ) * _vertexList.size(), NULL, drawHint   );
		glBufferSubData( GL_ARRAY_BUFFER, 0,    sizeof( Vertex ) * _vertexList.size(), &_vertexList[0]  );


        glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, _indexBufferHandle );
		glBufferData( GL_ELEMENT_ARRAY_BUFFER,          sizeof( GLuint ) * _indexList.size(), NULL, drawHint    );
        glBufferSubData( GL_ELEMENT_ARRAY_BUFFER, 0,    sizeof( GLuint ) * _indexList.size(), &_indexList[ 0 ]  );
	}
예제 #3
0
	bool ObjFile::load(const std::string& fname)
	{
		bool status = false;

		// Open the file
		std::ifstream file(fname);
		if (!file.is_open())
		{
			mIsLoaded = false;
			return false;
		}

		// Parse the file
		status = _parse(file);
		if (!status)
		{
			mIsLoaded = false;
			return false;
		}

		// Done with file
		file.close();

		// Organize the parsed data
		status = _organise();
		if (!status)
		{
			mIsLoaded = false;
			return false;
		}

		_finalize();


		_generateTangents(0);

		// Success!
		mIsLoaded = true;
		return true;
	}