# Better error tolerance

Fail more nicely (no repeated error dialogs, no crashes) when unable to
create VBOs.

This was SVN commit r4931.
This commit is contained in:
Ykkrosh
2007-02-28 20:09:19 +00:00
parent a4c0ea9d07
commit f4d1ad77c2
3 changed files with 15 additions and 13 deletions
+6
View File
@@ -190,6 +190,9 @@ void VertexArray::Upload()
if (!m_VB)
m_VB = g_VBMan.Allocate(m_Stride, m_NumVertices, m_Dynamic);
if (!m_VB) // failed to allocate VBO
return;
m_VB->m_Owner->UpdateChunkVertices(m_VB, m_BackingStore);
}
@@ -197,6 +200,9 @@ void VertexArray::Upload()
// Bind this array, returns the base address for calls to glVertexPointer etc.
u8* VertexArray::Bind()
{
if (!m_VB)
return NULL;
u8* base = m_VB->m_Owner->Bind();
base += m_VB->m_Index*m_Stride;
return base;
-2
View File
@@ -113,9 +113,7 @@ CVertexBuffer::VBChunk* CVertexBuffer::Allocate(size_t vertexSize,size_t numVert
if (numVertices<=(*iter)->m_Count) {
chunk=*iter;
// remove this chunk from the free list
// size_t size1=m_FreeList.size();
m_FreeList.erase(iter);
// size_t size2=m_FreeList.size();
// no need to search further ..
break;
}
+9 -11
View File
@@ -37,7 +37,7 @@ void CVertexBufferManager::Shutdown()
// Allocate: try to allocate a buffer of given number of vertices (each of
// given size), with the given type, and using the given texture - return null
// if no free chunks available
CVertexBuffer::VBChunk* CVertexBufferManager::Allocate(size_t vertexSize,size_t numVertices,bool dynamic)
CVertexBuffer::VBChunk* CVertexBufferManager::Allocate(size_t vertexSize, size_t numVertices, bool dynamic)
{
CVertexBuffer::VBChunk* result=0;
@@ -46,23 +46,21 @@ CVertexBuffer::VBChunk* CVertexBufferManager::Allocate(size_t vertexSize,size_t
// iterate through all existing buffers testing for one that'll
// satisfy the allocation
typedef std::list<CVertexBuffer*>::iterator Iter;
for (Iter iter=m_Buffers.begin();iter!=m_Buffers.end();++iter) {
CVertexBuffer* buffer=*iter;
result=buffer->Allocate(vertexSize,numVertices,dynamic);
if (result) return result;
for (Iter iter = m_Buffers.begin(); iter != m_Buffers.end(); ++iter) {
CVertexBuffer* buffer = *iter;
result = buffer->Allocate(vertexSize, numVertices, dynamic);
if (result)
return result;
}
// got this far; need to allocate a new buffer
CVertexBuffer* buffer=new CVertexBuffer(vertexSize,dynamic);
CVertexBuffer* buffer = new CVertexBuffer(vertexSize, dynamic);
m_Buffers.push_front(buffer);
result=buffer->Allocate(vertexSize,numVertices,dynamic);
result = buffer->Allocate(vertexSize, numVertices, dynamic);
// TODO, RC - debug_assert not really suitable? probably need to handle "failed to create
// VBO case" better
if (!result)
{
LOG(ERROR, LOG_CATEGORY, "Failed to create VBOs");
debug_warn("Failed to create VBOs");
LOG(ERROR, LOG_CATEGORY, "Failed to create VBOs (%d*%d)", vertexSize, numVertices);
}
return result;