VERTEX_MANAGER functions return false in case of failure.

This commit is contained in:
Maciej Suminski 2016-05-02 15:56:11 +02:00
parent 4262915b38
commit 113e75c5c5
2 changed files with 21 additions and 11 deletions

View File

@ -49,7 +49,7 @@ VERTEX_MANAGER::VERTEX_MANAGER( bool aCached ) :
} }
void VERTEX_MANAGER::Reserve( unsigned int aSize ) bool VERTEX_MANAGER::Reserve( unsigned int aSize )
{ {
assert( m_reservedSpace == 0 && m_reserved == NULL ); assert( m_reservedSpace == 0 && m_reserved == NULL );
@ -66,14 +66,16 @@ void VERTEX_MANAGER::Reserve( unsigned int aSize )
show_err = false; show_err = false;
} }
return; return false;
} }
m_reservedSpace = aSize; m_reservedSpace = aSize;
return true;
} }
void VERTEX_MANAGER::Vertex( GLfloat aX, GLfloat aY, GLfloat aZ ) bool VERTEX_MANAGER::Vertex( GLfloat aX, GLfloat aY, GLfloat aZ )
{ {
// flag to avoid hanging by calling DisplayError too many times: // flag to avoid hanging by calling DisplayError too many times:
static bool show_err = true; static bool show_err = true;
@ -102,14 +104,16 @@ void VERTEX_MANAGER::Vertex( GLfloat aX, GLfloat aY, GLfloat aZ )
show_err = false; show_err = false;
} }
return; return false;
} }
putVertex( *newVertex, aX, aY, aZ ); putVertex( *newVertex, aX, aY, aZ );
return true;
} }
void VERTEX_MANAGER::Vertices( const VERTEX aVertices[], unsigned int aSize ) bool VERTEX_MANAGER::Vertices( const VERTEX aVertices[], unsigned int aSize )
{ {
// flag to avoid hanging by calling DisplayError too many times: // flag to avoid hanging by calling DisplayError too many times:
static bool show_err = true; static bool show_err = true;
@ -125,7 +129,7 @@ void VERTEX_MANAGER::Vertices( const VERTEX aVertices[], unsigned int aSize )
show_err = false; show_err = false;
} }
return; return false;
} }
// Put vertices in already allocated memory chunk // Put vertices in already allocated memory chunk
@ -133,6 +137,8 @@ void VERTEX_MANAGER::Vertices( const VERTEX aVertices[], unsigned int aSize )
{ {
putVertex( newVertex[i], aVertices[i].x, aVertices[i].y, aVertices[i].z ); putVertex( newVertex[i], aVertices[i].x, aVertices[i].y, aVertices[i].z );
} }
return true;
} }

View File

@ -63,8 +63,9 @@ public:
* allocates space for vertices, so it will be used with subsequent Vertex() calls. * allocates space for vertices, so it will be used with subsequent Vertex() calls.
* *
* @param aSize is the number of vertices that should be available in the reserved space. * @param aSize is the number of vertices that should be available in the reserved space.
* @return True if successful, false otherwise.
*/ */
void Reserve( unsigned int aSize ); bool Reserve( unsigned int aSize );
/** /**
* Function Vertex() * Function Vertex()
@ -74,10 +75,11 @@ public:
* matrix applied. * matrix applied.
* *
* @param aVertex contains vertex coordinates. * @param aVertex contains vertex coordinates.
* @return True if successful, false otherwise.
*/ */
inline void Vertex( const VERTEX& aVertex ) inline bool Vertex( const VERTEX& aVertex )
{ {
Vertex( aVertex.x, aVertex.y, aVertex.z ); return Vertex( aVertex.x, aVertex.y, aVertex.z );
} }
/** /**
@ -88,8 +90,9 @@ public:
* @param aX is the X coordinate of the new vertex. * @param aX is the X coordinate of the new vertex.
* @param aY is the Y coordinate of the new vertex. * @param aY is the Y coordinate of the new vertex.
* @param aZ is the Z coordinate of the new vertex. * @param aZ is the Z coordinate of the new vertex.
* @return True if successful, false otherwise.
*/ */
void Vertex( GLfloat aX, GLfloat aY, GLfloat aZ ); bool Vertex( GLfloat aX, GLfloat aY, GLfloat aZ );
/** /**
* Function Vertices() * Function Vertices()
@ -101,8 +104,9 @@ public:
* *
* @param aVertices contains vertices to be added * @param aVertices contains vertices to be added
* @param aSize is the number of vertices to be added. * @param aSize is the number of vertices to be added.
* @return True if successful, false otherwise.
*/ */
void Vertices( const VERTEX aVertices[], unsigned int aSize ); bool Vertices( const VERTEX aVertices[], unsigned int aSize );
/** /**
* Function Color() * Function Color()