@ -1174,6 +1174,9 @@ bool CVertexArrayRangeARB::allocate(uint32 size, CVertexBuffer::TPreferredMemory
switch ( vbType )
switch ( vbType )
{
{
case CVertexBuffer : : AGPVolatile :
glBufferDataARB ( GL_ARRAY_BUFFER_ARB , size , NULL , GL_STREAM_DRAW_ARB ) ;
break ;
case CVertexBuffer : : AGPPreferred :
case CVertexBuffer : : AGPPreferred :
glBufferDataARB ( GL_ARRAY_BUFFER_ARB , size , NULL , GL_DYNAMIC_DRAW_ARB ) ;
glBufferDataARB ( GL_ARRAY_BUFFER_ARB , size , NULL , GL_DYNAMIC_DRAW_ARB ) ;
break ;
break ;
@ -1221,13 +1224,14 @@ IVertexBufferHardGL *CVertexArrayRangeARB::createVBHardGL(uint size, CVertexBuff
if ( glGetError ( ) ! = GL_NO_ERROR ) return NULL ;
if ( glGetError ( ) ! = GL_NO_ERROR ) return NULL ;
_Driver - > _DriverGLStates . forceBindARBVertexBuffer ( vertexBufferID ) ;
_Driver - > _DriverGLStates . forceBindARBVertexBuffer ( vertexBufferID ) ;
switch ( _VBType )
CVertexBuffer : : TPreferredMemory preferred = vb - > getPreferredMemory ( ) ;
switch ( preferred )
{
{
case CVertexBuffer : : AGP Preferred :
case CVertexBuffer : : AGP Volatile :
# ifdef USE_OPENGLES
# ifdef USE_OPENGLES
glBufferData ( GL_ARRAY_BUFFER , size , NULL , GL_ DYNAMIC _DRAW) ;
glBufferData ( GL_ARRAY_BUFFER , size , NULL , GL_ STREAM _DRAW) ;
# else
# else
nglBufferDataARB ( GL_ARRAY_BUFFER_ARB , size , NULL , GL_ DYNAMIC _DRAW_ARB) ;
nglBufferDataARB ( GL_ARRAY_BUFFER_ARB , size , NULL , GL_ STREAM _DRAW_ARB) ;
# endif
# endif
break ;
break ;
case CVertexBuffer : : StaticPreferred :
case CVertexBuffer : : StaticPreferred :
@ -1244,8 +1248,13 @@ IVertexBufferHardGL *CVertexArrayRangeARB::createVBHardGL(uint size, CVertexBuff
nglBufferDataARB ( GL_ARRAY_BUFFER_ARB , size , NULL , GL_DYNAMIC_DRAW_ARB ) ;
nglBufferDataARB ( GL_ARRAY_BUFFER_ARB , size , NULL , GL_DYNAMIC_DRAW_ARB ) ;
# endif
# endif
break ;
break ;
// case CVertexBuffer::AGPPreferred:
default :
default :
nlassert ( 0 ) ;
# ifdef USE_OPENGLES
glBufferData ( GL_ARRAY_BUFFER , size , NULL , GL_DYNAMIC_DRAW ) ;
# else
nglBufferDataARB ( GL_ARRAY_BUFFER_ARB , size , NULL , GL_DYNAMIC_DRAW_ARB ) ;
# endif
break ;
break ;
}
}
if ( glGetError ( ) ! = GL_NO_ERROR )
if ( glGetError ( ) ! = GL_NO_ERROR )
@ -1259,7 +1268,7 @@ IVertexBufferHardGL *CVertexArrayRangeARB::createVBHardGL(uint size, CVertexBuff
return NULL ;
return NULL ;
}
}
CVertexBufferHardARB * newVbHard = new CVertexBufferHardARB ( _Driver , vb ) ;
CVertexBufferHardARB * newVbHard = new CVertexBufferHardARB ( _Driver , vb ) ;
newVbHard - > initGL ( vertexBufferID , this , _VBTy pe) ;
newVbHard - > initGL ( vertexBufferID , this , pr eferred ) ;
_Driver - > _DriverGLStates . forceBindARBVertexBuffer ( 0 ) ;
_Driver - > _DriverGLStates . forceBindARBVertexBuffer ( 0 ) ;
return newVbHard ;
return newVbHard ;
}
}
@ -1393,6 +1402,7 @@ void *CVertexBufferHardARB::lock()
H_AUTO_OGL ( CVertexBufferHardARB_lock ) ;
H_AUTO_OGL ( CVertexBufferHardARB_lock ) ;
if ( _VertexPtr ) return _VertexPtr ; // already locked
if ( _VertexPtr ) return _VertexPtr ; // already locked
const uint size = VB - > getNumVertices ( ) * VB - > getVertexSize ( ) ;
if ( _Invalid )
if ( _Invalid )
{
{
if ( VB - > getLocation ( ) ! = CVertexBuffer : : NotResident )
if ( VB - > getLocation ( ) ! = CVertexBuffer : : NotResident )
@ -1414,15 +1424,14 @@ void *CVertexBufferHardARB::lock()
_Driver - > incrementResetCounter ( ) ;
_Driver - > incrementResetCounter ( ) ;
return & _DummyVB [ 0 ] ;
return & _DummyVB [ 0 ] ;
}
}
const uint size = VB - > getNumVertices ( ) * VB - > getVertexSize ( ) ;
_Driver - > _DriverGLStates . forceBindARBVertexBuffer ( vertexBufferID ) ;
_Driver - > _DriverGLStates . forceBindARBVertexBuffer ( vertexBufferID ) ;
switch ( _MemType )
switch ( _MemType )
{
{
case CVertexBuffer : : AGP Preferred :
case CVertexBuffer : : AGP Volatile :
# ifdef USE_OPENGLES
# ifdef USE_OPENGLES
glBufferData ( GL_ARRAY_BUFFER , size , NULL , GL_ DYNAMIC _DRAW) ;
glBufferData ( GL_ARRAY_BUFFER , size , NULL , GL_ STREAM _DRAW) ;
# else
# else
nglBufferDataARB ( GL_ARRAY_BUFFER_ARB , size , NULL , GL_ DYNAMIC _DRAW_ARB) ;
nglBufferDataARB ( GL_ARRAY_BUFFER_ARB , size , NULL , GL_ STREAM _DRAW_ARB) ;
# endif
# endif
break ;
break ;
case CVertexBuffer : : StaticPreferred :
case CVertexBuffer : : StaticPreferred :
@ -1439,8 +1448,13 @@ void *CVertexBufferHardARB::lock()
nglBufferDataARB ( GL_ARRAY_BUFFER_ARB , size , NULL , GL_DYNAMIC_DRAW_ARB ) ;
nglBufferDataARB ( GL_ARRAY_BUFFER_ARB , size , NULL , GL_DYNAMIC_DRAW_ARB ) ;
# endif
# endif
break ;
break ;
// case CVertexBuffer::AGPPreferred:
default :
default :
nlassert ( 0 ) ;
# ifdef USE_OPENGLES
glBufferData ( GL_ARRAY_BUFFER , size , NULL , GL_DYNAMIC_DRAW ) ;
# else
nglBufferDataARB ( GL_ARRAY_BUFFER_ARB , size , NULL , GL_DYNAMIC_DRAW_ARB ) ;
# endif
break ;
break ;
}
}
if ( glGetError ( ) ! = GL_NO_ERROR )
if ( glGetError ( ) ! = GL_NO_ERROR )
@ -1499,7 +1513,14 @@ void *CVertexBufferHardARB::lock()
_LastBufferSize = size ;
_LastBufferSize = size ;
}
}
# else
# else
_VertexPtr = nglMapBufferARB ( GL_ARRAY_BUFFER_ARB , GL_WRITE_ONLY_ARB ) ;
if ( _MemType = = CVertexBuffer : : AGPVolatile )
{
_VertexPtr = nglMapBufferRange ( GL_ARRAY_BUFFER , 0 , size , GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT ) ;
}
else
{
_VertexPtr = nglMapBufferARB ( GL_ARRAY_BUFFER_ARB , GL_WRITE_ONLY_ARB ) ;
}
if ( ! _VertexPtr )
if ( ! _VertexPtr )
{
{
nglUnmapBufferARB ( GL_ARRAY_BUFFER_ARB ) ;
nglUnmapBufferARB ( GL_ARRAY_BUFFER_ARB ) ;