Added Vertex Buffer support ( cVertexBuffer base class (interface), cVertexBufferOGL fallback if gpu doesn't support VBO's, cVertexBufferVBO uses ARB Vertex Buffer Object ).

Added a Memory Manager to trace memory leaks.
Fixed some memory leaks detected with the new memory manager.
Added an allocator for STL ( to use it with the custom allocation seted in the memory manager ).
Fixed Makefiles ( i wroke them ).
This commit is contained in:
spartanj
2010-09-03 02:53:14 -03:00
parent d9bd5d763f
commit f8703cd568
60 changed files with 1279 additions and 254 deletions

View File

@@ -0,0 +1,66 @@
#include "cvertexbufferogl.hpp"
namespace EE { namespace Graphics {
cVertexBufferOGL::cVertexBufferOGL( const Uint32& VertexFlags, EE_DRAW_TYPE DrawType, const Int32& ReserveVertexSize, const Int32& ReserveIndexSize, EE_VBO_USAGE_TYPE UsageType ) :
cVertexBuffer( VertexFlags, DrawType, ReserveVertexSize, ReserveIndexSize, UsageType )
{
}
cVertexBufferOGL::~cVertexBufferOGL() {
}
void cVertexBufferOGL::Bind() {
SetVertexStates();
}
bool cVertexBufferOGL::Compile() {
return true;
}
void cVertexBufferOGL::Draw() {
if( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_USE_INDICES ) ) {
Int32 lSize = mElemDraw;
if( mElemDraw < 0 )
lSize = GetIndexCount();
glDrawElements( mDrawType, lSize, GL_UNSIGNED_INT, &mIndexArray[0] );
} else {
glDrawArrays( mDrawType, 0, GetVertexCount() );
}
}
void cVertexBufferOGL::SetVertexStates() {
/// POSITION
if( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_POSITION ) ) {
glEnableClientState( GL_VERTEX_ARRAY );
glVertexPointer( eeVertexElements[ VERTEX_FLAG_POSITION ], GL_FLOAT, sizeof(float) * eeVertexElements[ VERTEX_FLAG_POSITION ], &mVertexArray[ VERTEX_FLAG_POSITION ][0] );
} else {
glDisableClientState( GL_VERTEX_ARRAY );
}
/// COLOR
if( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_COLOR ) ) {
glEnableClientState( GL_COLOR_ARRAY );
glColorPointer( eeVertexElements[ VERTEX_FLAG_COLOR ], GL_UNSIGNED_BYTE, sizeof(Uint8) * eeVertexElements[ VERTEX_FLAG_COLOR ], &mColorArray[0] );
} else {
glDisableClientState( GL_COLOR_ARRAY );
}
/// TEXTURES
for ( Int32 i = 0; i < 5; i++ ) {
if( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_TEXTURE0 + i ) ) {
glClientActiveTextureARB( GL_TEXTURE0_ARB );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glTexCoordPointer( eeVertexElements[ VERTEX_FLAG_TEXTURE0 + i ], GL_FLOAT, sizeof(float) * eeVertexElements[ VERTEX_FLAG_TEXTURE0 + i ], &mVertexArray[ VERTEX_FLAG_TEXTURE0 + i ][0] );
} else {
//glClientActiveTextureARB( GL_TEXTURE0_ARB );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glDisable( GL_TEXTURE_2D );
}
}
}
}}