mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-28 17:16:29 +03:00
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:
24
Makefile
24
Makefile
@@ -1,15 +1,15 @@
|
||||
ifeq ($(DEBUGBUILD), yes)
|
||||
DEBUGFLAGS = -g -DDEBUG -DEE_DEBUG
|
||||
DEBUGFLAGS = -g -DDEBUG -DEE_DEBUG -DEE_MEMORY_MANAGER
|
||||
else
|
||||
DEBUGFLAGS = -O2 -s -DNDEBUG
|
||||
endif
|
||||
|
||||
ifeq ($(STATIC), yes)
|
||||
BUILDFLAGS =
|
||||
LINKFLAGS =
|
||||
else
|
||||
ifeq ($(DYNAMIC), yes)
|
||||
BUILDFLAGS = -fPIC
|
||||
LINKFLAGS = -shared
|
||||
else
|
||||
BUILDFLAGS =
|
||||
LINKFLAGS =
|
||||
endif
|
||||
|
||||
export CC = gcc
|
||||
@@ -44,6 +44,7 @@ SRCZLIB = $(wildcard ./src/helper/zlib/*.c)
|
||||
SRCLIBZIP = $(wildcard ./src/helper/libzip/*.c)
|
||||
|
||||
SRCHAIKUTTF = $(wildcard ./src/helper/haikuttf/*.cpp)
|
||||
SRCBASE = $(wildcard ./src/base/*.cpp)
|
||||
SRCAUDIO = $(wildcard ./src/audio/*.cpp)
|
||||
SRCGAMING = $(wildcard ./src/gaming/*.cpp)
|
||||
SRCGRAPHICS = $(wildcard ./src/graphics/*.cpp)
|
||||
@@ -63,6 +64,7 @@ OBJZLIB = $(SRCZLIB:.c=.o)
|
||||
OBJLIBZIP = $(SRCLIBZIP:.c=.o)
|
||||
|
||||
OBJHAIKUTTF = $(SRCHAIKUTTF:.cpp=.o)
|
||||
OBJBASE = $(SRCBASE:.cpp=.o)
|
||||
OBJAUDIO = $(SRCAUDIO:.cpp=.o)
|
||||
OBJGAMING = $(SRCGAMING:.cpp=.o)
|
||||
OBJGRAPHICS = $(SRCGRAPHICS:.cpp=.o)
|
||||
@@ -73,19 +75,19 @@ OBJUTILS = $(SRCUTILS:.cpp=.o)
|
||||
OBJWINDOW = $(SRCWINDOW:.cpp=.o)
|
||||
|
||||
OBJHELPERS = $(OBJGLEW) $(OBJSOIL) $(OBJSTBVORBIS) $(OBJZLIB) $(OBJLIBZIP)
|
||||
OBJMODULES = $(OBJHAIKUTTF) $(OBJUTILS) $(OBJMATH) $(OBJSYSTEM) $(OBJAUDIO) $(OBJWINDOW) $(OBJGRAPHICS) $(OBJGAMING) $(OBJUI)
|
||||
OBJMODULES = $(OBJHAIKUTTF) $(OBJBASE) $(OBJUTILS) $(OBJMATH) $(OBJSYSTEM) $(OBJAUDIO) $(OBJWINDOW) $(OBJGRAPHICS) $(OBJGAMING) $(OBJUI)
|
||||
|
||||
OBJTEST = $(SRCTEST:.cpp=.o)
|
||||
OBJEEIV = $(SRCEEIV:.cpp=.o)
|
||||
|
||||
ifeq ($(STATIC), yes)
|
||||
LIB = libeepp-s.a
|
||||
LIBNAME = $(LIBPATH)/$(LIB)
|
||||
INSTALL =
|
||||
else
|
||||
ifeq ($(DYNAMIC), yes)
|
||||
LIB = libeepp.so
|
||||
LIBNAME = $(LIBPATH)/$(LIB).$(VERSION)
|
||||
INSTALL = && $(LN) $(LNFLAGS) $(DESTLIBDIR)/$(LIB).$(VERSION) $(DESTLIBDIR)/$(LIB)
|
||||
else
|
||||
LIB = libeepp-s.a
|
||||
LIBNAME = $(LIBPATH)/$(LIB)
|
||||
INSTALL =
|
||||
endif
|
||||
|
||||
all: $(LIB)
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
ifeq ($(DEBUGBUILD), yes)
|
||||
DEBUGFLAGS = -g -DDEBUG -DEE_DEBUG
|
||||
DEBUGFLAGS = -g -DDEBUG -DEE_DEBUG -DEE_MEMORY_MANAGER
|
||||
else
|
||||
DEBUGFLAGS = -O2 -s -DNDEBUG
|
||||
endif
|
||||
|
||||
ifeq ($(STATIC), yes)
|
||||
BUILDFLAGS =
|
||||
LINKFLAGS =
|
||||
else
|
||||
ifeq ($(DYNAMIC), yes)
|
||||
BUILDFLAGS = -fPIC
|
||||
LINKFLAGS = -shared
|
||||
else
|
||||
BUILDFLAGS =
|
||||
LINKFLAGS =
|
||||
endif
|
||||
|
||||
export CC = gcc
|
||||
@@ -44,6 +44,7 @@ SRCZLIB = $(wildcard ./src/helper/zlib/*.c)
|
||||
SRCLIBZIP = $(wildcard ./src/helper/libzip/*.c)
|
||||
|
||||
SRCHAIKUTTF = $(wildcard ./src/helper/haikuttf/*.cpp)
|
||||
SRCBASE = $(wildcard ./src/base/*.cpp)
|
||||
SRCAUDIO = $(wildcard ./src/audio/*.cpp)
|
||||
SRCGAMING = $(wildcard ./src/gaming/*.cpp)
|
||||
SRCGRAPHICS = $(wildcard ./src/graphics/*.cpp)
|
||||
@@ -63,6 +64,7 @@ OBJZLIB = $(SRCZLIB:.c=.o)
|
||||
OBJLIBZIP = $(SRCLIBZIP:.c=.o)
|
||||
|
||||
OBJHAIKUTTF = $(SRCHAIKUTTF:.cpp=.o)
|
||||
OBJBASE = $(SRCBASE:.cpp=.o)
|
||||
OBJAUDIO = $(SRCAUDIO:.cpp=.o)
|
||||
OBJGAMING = $(SRCGAMING:.cpp=.o)
|
||||
OBJGRAPHICS = $(SRCGRAPHICS:.cpp=.o)
|
||||
@@ -73,19 +75,19 @@ OBJUTILS = $(SRCUTILS:.cpp=.o)
|
||||
OBJWINDOW = $(SRCWINDOW:.cpp=.o)
|
||||
|
||||
OBJHELPERS = $(OBJGLEW) $(OBJSOIL) $(OBJSTBVORBIS) $(OBJZLIB) $(OBJLIBZIP)
|
||||
OBJMODULES = $(OBJHAIKUTTF) $(OBJUTILS) $(OBJMATH) $(OBJSYSTEM) $(OBJAUDIO) $(OBJWINDOW) $(OBJGRAPHICS) $(OBJGAMING) $(OBJUI)
|
||||
OBJMODULES = $(OBJHAIKUTTF) $(OBJBASE) $(OBJUTILS) $(OBJMATH) $(OBJSYSTEM) $(OBJAUDIO) $(OBJWINDOW) $(OBJGRAPHICS) $(OBJGAMING) $(OBJUI)
|
||||
|
||||
OBJTEST = $(SRCTEST:.cpp=.o)
|
||||
OBJEEIV = $(SRCEEIV:.cpp=.o)
|
||||
|
||||
ifeq ($(STATIC), yes)
|
||||
LIB = libeepp-s.a
|
||||
LIBNAME = $(LIBPATH)/$(LIB)
|
||||
INSTALL =
|
||||
else
|
||||
ifeq ($(DYNAMIC), yes)
|
||||
LIB = libeepp.so
|
||||
LIBNAME = $(LIBPATH)/$(LIB).$(VERSION)
|
||||
INSTALL = && $(LN) $(LNFLAGS) $(DESTLIBDIR)/$(LIB).$(VERSION) $(DESTLIBDIR)/$(LIB)
|
||||
else
|
||||
LIB = libeepp-s.a
|
||||
LIBNAME = $(LIBPATH)/$(LIB)
|
||||
INSTALL =
|
||||
endif
|
||||
|
||||
all: $(LIB)
|
||||
|
||||
18
ee.linux.cbp
18
ee.linux.cbp
@@ -8,7 +8,7 @@
|
||||
<Build>
|
||||
<Target title="Debug">
|
||||
<Option output="eetest" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="." />
|
||||
<Option object_output="./obj/linux/debug" />
|
||||
<Option type="1" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
@@ -18,11 +18,10 @@
|
||||
</Target>
|
||||
<Target title="Release">
|
||||
<Option output="eetest" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="." />
|
||||
<Option object_output="./obj/linux/release" />
|
||||
<Option type="1" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-march=core2" />
|
||||
<Add option="-O2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
@@ -32,6 +31,7 @@
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-Wall" />
|
||||
<Add option="-DEE_MEMORY_MANAGER" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add library="GL" />
|
||||
@@ -67,6 +67,11 @@
|
||||
<Unit filename="src/audio/tsoundloader.hpp" />
|
||||
<Unit filename="src/audio/tsoundmanager.hpp" />
|
||||
<Unit filename="src/base.hpp" />
|
||||
<Unit filename="src/base/allocator.hpp" />
|
||||
<Unit filename="src/base/base.hpp" />
|
||||
<Unit filename="src/base/memorymanager.cpp" />
|
||||
<Unit filename="src/base/memorymanager.hpp" />
|
||||
<Unit filename="src/base/stlcontainers.hpp" />
|
||||
<Unit filename="src/ee.h" />
|
||||
<Unit filename="src/gaming/base.hpp" />
|
||||
<Unit filename="src/gaming/cisomap.cpp" />
|
||||
@@ -140,11 +145,18 @@
|
||||
<Unit filename="src/graphics/cttffont.hpp" />
|
||||
<Unit filename="src/graphics/cttffontloader.cpp" />
|
||||
<Unit filename="src/graphics/cttffontloader.hpp" />
|
||||
<Unit filename="src/graphics/cvertexbuffer.cpp" />
|
||||
<Unit filename="src/graphics/cvertexbuffer.hpp" />
|
||||
<Unit filename="src/graphics/cvertexbufferogl.cpp" />
|
||||
<Unit filename="src/graphics/cvertexbufferogl.hpp" />
|
||||
<Unit filename="src/graphics/cvertexbuffervbo.cpp" />
|
||||
<Unit filename="src/graphics/cvertexbuffervbo.hpp" />
|
||||
<Unit filename="src/graphics/fonthelper.hpp" />
|
||||
<Unit filename="src/graphics/packerhelper.hpp" />
|
||||
<Unit filename="src/graphics/pixelperfect.cpp" />
|
||||
<Unit filename="src/graphics/pixelperfect.hpp" />
|
||||
<Unit filename="src/graphics/renders.hpp" />
|
||||
<Unit filename="src/graphics/vbohelper.hpp" />
|
||||
<Unit filename="src/helper/SOIL/SOIL.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
|
||||
@@ -48,7 +48,7 @@ bool cAudioDevice::isCreated() {
|
||||
cAudioDevice * cAudioDevice::instance() {
|
||||
// Create the audio device if it doesn't exist
|
||||
if ( NULL == mInstance )
|
||||
mInstance = new cAudioDevice;
|
||||
mInstance = eeNew( cAudioDevice, () );
|
||||
|
||||
return mInstance;
|
||||
}
|
||||
@@ -66,7 +66,7 @@ void cAudioDevice::RemoveReference() {
|
||||
|
||||
// Destroy the audio device if the references count reaches 0
|
||||
if (mInstance->mRefCount == 0) {
|
||||
delete mInstance;
|
||||
eeDelete( mInstance );
|
||||
mInstance = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,10 @@ class EE_API cAudioDevice {
|
||||
bool IsExtensionSupported( const std::string& extension );
|
||||
|
||||
bool isCreated();
|
||||
private :
|
||||
cAudioDevice();
|
||||
|
||||
~cAudioDevice();
|
||||
private :
|
||||
cAudioDevice();
|
||||
|
||||
static cAudioDevice * mInstance;
|
||||
|
||||
|
||||
@@ -64,10 +64,10 @@ bool cSoundBuffer::LoadFromPack( cPack* Pack, const std::string& FilePackPath )
|
||||
|
||||
bool cSoundBuffer::LoadFromMemory( const char* Data, std::size_t SizeInBytes ) {
|
||||
// Create the sound file
|
||||
std::auto_ptr<cSoundFile> File( cSoundFile::CreateRead( Data, SizeInBytes ) );
|
||||
cSoundFile * File = cSoundFile::CreateRead( Data, SizeInBytes );
|
||||
|
||||
// Open the sound file
|
||||
if ( File.get() ) {
|
||||
if ( NULL != File ) {
|
||||
// Get the sound parameters
|
||||
std::size_t NbSamples = File->GetSamplesCount();
|
||||
unsigned int ChannelsCount = File->GetChannelsCount();
|
||||
@@ -80,9 +80,14 @@ bool cSoundBuffer::LoadFromMemory( const char* Data, std::size_t SizeInBytes ) {
|
||||
cLog::instance()->Write( "Sound file loaded from memory." );
|
||||
|
||||
// Update the internal buffer with the new samples
|
||||
eeDelete( File );
|
||||
|
||||
return Update( ChannelsCount, SampleRate );
|
||||
} else {
|
||||
cLog::instance()->Write( "Failed to read audio data from file in memory" );
|
||||
|
||||
eeDelete( File );
|
||||
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -21,9 +21,9 @@ cSoundFile * cSoundFile::CreateRead( const std::string& Filename ) {
|
||||
// Create the file according to its type
|
||||
cSoundFile * File = NULL;
|
||||
|
||||
if ( cSoundFileOgg::IsFileSupported(Filename, true) ) File = new cSoundFileOgg;
|
||||
if ( cSoundFileOgg::IsFileSupported(Filename, true) ) File = eeNew( cSoundFileOgg, () );
|
||||
#ifndef EE_NO_SNDFILE
|
||||
else if ( cSoundFileDefault::IsFileSupported(Filename, true) ) File = new cSoundFileDefault;
|
||||
else if ( cSoundFileDefault::IsFileSupported(Filename, true) ) File = eeNew( cSoundFileDefault, () );
|
||||
#endif
|
||||
|
||||
// Open it for reading
|
||||
@@ -40,7 +40,7 @@ cSoundFile * cSoundFile::CreateRead( const std::string& Filename ) {
|
||||
File->mChannelsCount = ChannelsCount;
|
||||
File->mSampleRate = SampleRate;
|
||||
} else {
|
||||
delete File;
|
||||
eeDelete( File );
|
||||
File = NULL;
|
||||
}
|
||||
}
|
||||
@@ -52,9 +52,9 @@ cSoundFile * cSoundFile::CreateRead( const char* Data, std::size_t SizeInMemory
|
||||
// Create the file according to its type
|
||||
cSoundFile * File = NULL;
|
||||
|
||||
if ( cSoundFileOgg::IsFileSupported(Data, SizeInMemory)) File = new cSoundFileOgg;
|
||||
if ( cSoundFileOgg::IsFileSupported(Data, SizeInMemory)) File = eeNew( cSoundFileOgg, () );
|
||||
#ifndef EE_NO_SNDFILE
|
||||
else if ( cSoundFileDefault::IsFileSupported(Data, SizeInMemory) ) File = new cSoundFileDefault;
|
||||
else if ( cSoundFileDefault::IsFileSupported(Data, SizeInMemory) ) File = eeNew( cSoundFileDefault, () );
|
||||
#endif
|
||||
|
||||
// Open it for reading
|
||||
@@ -71,7 +71,7 @@ cSoundFile * cSoundFile::CreateRead( const char* Data, std::size_t SizeInMemory
|
||||
File->mChannelsCount = ChannelsCount;
|
||||
File->mSampleRate = SampleRate;
|
||||
} else {
|
||||
delete File;
|
||||
eeDelete( File );
|
||||
File = NULL;
|
||||
}
|
||||
}
|
||||
@@ -83,9 +83,9 @@ cSoundFile * cSoundFile::CreateWrite( const std::string& Filename, unsigned int
|
||||
// Create the file according to its type
|
||||
cSoundFile * File = NULL;
|
||||
|
||||
if ( cSoundFileOgg::IsFileSupported(Filename, false) ) File = new cSoundFileOgg;
|
||||
if ( cSoundFileOgg::IsFileSupported(Filename, false) ) File = eeNew( cSoundFileOgg, () );
|
||||
#ifndef EE_NO_SNDFILE
|
||||
else if ( cSoundFileDefault::IsFileSupported(Filename, false) ) File = new cSoundFileDefault;
|
||||
else if ( cSoundFileDefault::IsFileSupported(Filename, false) ) File = eeNew( cSoundFileDefault, () );
|
||||
#endif
|
||||
|
||||
// Open it for writing
|
||||
@@ -98,7 +98,7 @@ cSoundFile * cSoundFile::CreateWrite( const std::string& Filename, unsigned int
|
||||
File->mChannelsCount = ChannelsCount;
|
||||
File->mSampleRate = SampleRate;
|
||||
} else {
|
||||
delete File;
|
||||
eeDelete( File );
|
||||
File = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
37
src/base.hpp
37
src/base.hpp
@@ -7,6 +7,14 @@
|
||||
#include <cwchar>
|
||||
#include <cstdarg>
|
||||
#include <ctime>
|
||||
#include <cctype>
|
||||
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -14,21 +22,14 @@
|
||||
#include <deque>
|
||||
#include <queue>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <set>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include <SDL/SDL.h>
|
||||
|
||||
// Templates needed by the library
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <SDL/SDL.h>
|
||||
|
||||
#define Int8 Sint8
|
||||
#define Int16 Sint16
|
||||
#define Int32 Sint32
|
||||
@@ -84,6 +85,12 @@
|
||||
#define EE_CALL
|
||||
#endif
|
||||
|
||||
#if ( __GNUC__ >= 4 ) && defined( EE_DYNAMIC ) && defined( EE_EXPORTS )
|
||||
#define EE_API __attribute__ ((visibility("default")))
|
||||
#else
|
||||
#define EE_API
|
||||
#endif
|
||||
|
||||
#include "helper/glew/glew.h"
|
||||
#if EE_PLATFORM == EE_PLATFORM_MACOSX
|
||||
#include <OpenGL/gl.h>
|
||||
@@ -91,14 +98,16 @@
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#include "base/base.hpp"
|
||||
|
||||
namespace EE {
|
||||
#define eeARRAY_SIZE(__array) ( sizeof(__array) / sizeof(__array[0]) )
|
||||
#define eeSAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
|
||||
#define eeSAFE_FREE(p) { if(p) { free ( (void*)p );(p)=NULL; } }
|
||||
#define eeSAFE_DELETE_ARRAY(p) { if(p) { delete[](p); (p)=NULL; } }
|
||||
#define eeSAFE_DELETE(p) { if(p) { eeDelete (p); (p)=NULL; } }
|
||||
#define eeSAFE_FREE(p) { if(p) { eeFree ( (void*)p ); (p)=NULL; } }
|
||||
#define eeSAFE_DELETE_ARRAY(p) { if(p) { eeDeleteArray(p); (p)=NULL; } }
|
||||
|
||||
typedef float eeFloat; //! The internal floating point used on EE++. \n This can help to improve compatibility with some platforms. \n And helps for an easy change from single precision to double precision.
|
||||
typedef double eeDouble; //! The internal double floating point. It's only used when the engine needs some very high precision floating point ( for example the timer )
|
||||
typedef double eeDouble; //! The internal double floating point. It's only used when the engine needs some very high precision floating point ( for example the timer )
|
||||
typedef unsigned int eeUint;
|
||||
typedef signed int eeInt;
|
||||
|
||||
|
||||
75
src/base/allocator.hpp
Normal file
75
src/base/allocator.hpp
Normal file
@@ -0,0 +1,75 @@
|
||||
#ifndef EE_ALLOCATOR_HPP
|
||||
#define EE_ALLOCATOR_HPP
|
||||
|
||||
#include "memorymanager.hpp"
|
||||
|
||||
namespace EE {
|
||||
|
||||
template<typename T>
|
||||
class eeAllocator {
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef T * pointer;
|
||||
typedef const T * const_pointer;
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef size_t size_type;
|
||||
|
||||
eeAllocator() {
|
||||
}
|
||||
|
||||
eeAllocator( const eeAllocator& ) {
|
||||
}
|
||||
|
||||
virtual ~eeAllocator() {
|
||||
}
|
||||
|
||||
T * allocate( size_t cnt, typename std::allocator<void>::const_pointer ptr = 0 ) {
|
||||
(void)ptr;
|
||||
return ( T * ) eeMalloc( cnt * sizeof( T ) );
|
||||
}
|
||||
|
||||
void deallocate( T * ptr, size_type ) {
|
||||
eeFree( ptr );
|
||||
}
|
||||
|
||||
void construct( T * ptr, const T&e ) {
|
||||
new ( (void*)ptr ) T( e );
|
||||
}
|
||||
|
||||
void destroy( T * ptr ) {
|
||||
ptr->~T();
|
||||
}
|
||||
|
||||
size_t max_size() const {
|
||||
return size_t( 0xFFFFFFFF );
|
||||
}
|
||||
|
||||
pointer address( reference x ) const {
|
||||
return &x;
|
||||
}
|
||||
|
||||
const_pointer address( const_reference x ) const {
|
||||
return &x;
|
||||
}
|
||||
|
||||
eeAllocator<T>& operator=(const eeAllocator&) { return *this; }
|
||||
|
||||
template <class U>
|
||||
struct rebind {
|
||||
typedef eeAllocator<U> other;
|
||||
};
|
||||
|
||||
template <class U>
|
||||
eeAllocator( const eeAllocator<U>& ) {}
|
||||
|
||||
template <class U>
|
||||
eeAllocator& operator=(const eeAllocator<U>&) { return *this; }
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
9
src/base/base.hpp
Normal file
9
src/base/base.hpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef EE_BASE_BASE_HPP
|
||||
#define EE_BASE_BASE_HPP
|
||||
|
||||
#include "memorymanager.hpp"
|
||||
#include "allocator.hpp"
|
||||
#include "stlcontainers.hpp"
|
||||
|
||||
#endif
|
||||
|
||||
138
src/base/memorymanager.cpp
Normal file
138
src/base/memorymanager.cpp
Normal file
@@ -0,0 +1,138 @@
|
||||
#include "memorymanager.hpp"
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
namespace EE {
|
||||
|
||||
static std::string SizeToString( const unsigned int& MemSize ) {
|
||||
std::string size = " bytes";
|
||||
double mem = static_cast<double>( MemSize );
|
||||
unsigned int c = 0;
|
||||
|
||||
while ( mem > 1024 ) {
|
||||
c++;
|
||||
mem = mem / 1024;
|
||||
}
|
||||
|
||||
switch (c) {
|
||||
case 0: size = " bytes"; break;
|
||||
case 1: size = " KB"; break;
|
||||
case 2: size = " MB"; break;
|
||||
case 3: size = " GB"; break;
|
||||
case 4: size = " TB"; break;
|
||||
default: size = " WTF";
|
||||
}
|
||||
|
||||
std::ostringstream ss;
|
||||
ss << mem;
|
||||
|
||||
return std::string( ss.str() + size );
|
||||
}
|
||||
|
||||
tAllocatedPointerMap MemoryManager::mMapPointers;
|
||||
size_t MemoryManager::mTotalMemoryUsage = 0;
|
||||
size_t MemoryManager::mPeakMemoryUsage = 0;
|
||||
|
||||
cAllocatedPointer::cAllocatedPointer( void * Data,const std::string& File, int Line, size_t Memory ) {
|
||||
mData = Data;
|
||||
mFile = File;
|
||||
mLine = Line;
|
||||
mMemory = Memory;
|
||||
}
|
||||
|
||||
void * MemoryManager::AddPointer( const cAllocatedPointer& aAllocatedPointer ) {
|
||||
mMapPointers.insert( tAllocatedPointerMap::value_type( aAllocatedPointer.mData, aAllocatedPointer ) );
|
||||
|
||||
mTotalMemoryUsage += aAllocatedPointer.mMemory;
|
||||
|
||||
if ( mPeakMemoryUsage < mTotalMemoryUsage )
|
||||
mPeakMemoryUsage = mTotalMemoryUsage;
|
||||
|
||||
return aAllocatedPointer.mData;
|
||||
}
|
||||
|
||||
bool MemoryManager::RemovePointer( void * Data ) {
|
||||
bool Found = false;
|
||||
|
||||
tAllocatedPointerMapIt it = mMapPointers.upper_bound( Data );
|
||||
|
||||
it--;
|
||||
|
||||
if( it != mMapPointers.end() ) {
|
||||
char * Test = (char*)it->second.mData;
|
||||
|
||||
size_t testSize = it->second.mMemory;
|
||||
|
||||
if( Data >= Test && Data < Test + testSize )
|
||||
Found = true;
|
||||
}
|
||||
|
||||
|
||||
if ( !Found ) {
|
||||
printf( "Trying to delete pointer %p created that does not exist!\n", Data );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
mTotalMemoryUsage -= it->second.mMemory;
|
||||
|
||||
mMapPointers.erase( it );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MemoryManager::LogResults() {
|
||||
#ifdef EE_MEMORY_MANAGER
|
||||
printf("\n|--Memory Manager Report-------------------------------|\n");
|
||||
printf("|\n");
|
||||
|
||||
if( mMapPointers.empty() ) {
|
||||
printf( "| No memory leaks detected.\n" );
|
||||
} else {
|
||||
printf( "| Memory leaks detected: \n" );
|
||||
printf( "|\n");
|
||||
|
||||
printf( "| address\t file" );
|
||||
|
||||
//Get max length of file name
|
||||
int lMax =0;
|
||||
tAllocatedPointerMapIt it = mMapPointers.begin();
|
||||
|
||||
for( ; it != mMapPointers.end(); ++it ){
|
||||
cAllocatedPointer &ap = it->second;
|
||||
|
||||
if( (int)ap.mFile.length() > lMax )
|
||||
lMax = (int)ap.mFile.length();
|
||||
}
|
||||
|
||||
lMax += 5;
|
||||
|
||||
for( int i = 0; i < lMax - 4; ++i )
|
||||
printf(" ");
|
||||
|
||||
printf( "line\t\t memory usage\t \n" );
|
||||
|
||||
printf( "|------------------------------------------------------------\n" );
|
||||
|
||||
it = mMapPointers.begin();
|
||||
|
||||
for( ; it != mMapPointers.end(); ++it ) {
|
||||
cAllocatedPointer &ap = it->second;
|
||||
|
||||
printf( "| %p\t %s", ap.mData, ap.mFile.c_str() );
|
||||
|
||||
for ( int i=0; i < lMax - (int)ap.mFile.length(); ++i )
|
||||
printf(" ");
|
||||
|
||||
printf( "%d\t\t %d\t\n", ap.mLine, ap.mMemory );
|
||||
}
|
||||
}
|
||||
|
||||
printf( "|\n" );
|
||||
printf( "| Memory left: %s\n", SizeToString( mTotalMemoryUsage ).c_str() );
|
||||
printf( "| Peak Memory Usage: %s\n", SizeToString( mPeakMemoryUsage ).c_str() );
|
||||
printf( "|------------------------------------------------------|\n\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
101
src/base/memorymanager.hpp
Normal file
101
src/base/memorymanager.hpp
Normal file
@@ -0,0 +1,101 @@
|
||||
#ifndef EE_MEMORY_MANAGER_HPP
|
||||
#define EE_MEMORY_MANAGER_HPP
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
|
||||
namespace EE {
|
||||
|
||||
class cAllocatedPointer {
|
||||
public:
|
||||
cAllocatedPointer( void * Data, const std::string& File, int Line, size_t Memory );
|
||||
|
||||
std::string mFile;
|
||||
int mLine;
|
||||
size_t mMemory;
|
||||
void * mData;
|
||||
};
|
||||
|
||||
typedef std::map<void*, cAllocatedPointer> tAllocatedPointerMap;
|
||||
typedef tAllocatedPointerMap::iterator tAllocatedPointerMapIt;
|
||||
|
||||
class MemoryManager {
|
||||
public:
|
||||
|
||||
static void * AddPointer( const cAllocatedPointer& aAllocatedPointer );
|
||||
|
||||
static bool RemovePointer( void * Data );
|
||||
|
||||
static void LogResults();
|
||||
|
||||
static void SetLogCreation( bool abX );
|
||||
|
||||
template<class T>
|
||||
static T* DeleteAndReturn( T * Data ) {
|
||||
delete Data;
|
||||
return Data;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static T* DeleteArrayAndReturn( T * Data ) {
|
||||
delete [] Data;
|
||||
return Data;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static T* FreeAndReturn( T * Data ) {
|
||||
free( Data );
|
||||
return Data;
|
||||
}
|
||||
|
||||
static tAllocatedPointerMap mMapPointers;
|
||||
static size_t mTotalMemoryUsage;
|
||||
static size_t mPeakMemoryUsage;
|
||||
};
|
||||
|
||||
#ifdef EE_MEMORY_MANAGER
|
||||
#define eeNew(classType, constructor) \
|
||||
( classType *)EE::MemoryManager::AddPointer( EE::cAllocatedPointer(new classType constructor ,__FILE__,__LINE__,sizeof(classType) ) )
|
||||
|
||||
#define eeNewArray(classType, amount) \
|
||||
( classType *) EE::MemoryManager::AddPointer( EE::cAllocatedPointer( new classType [ amount ], __FILE__, __LINE__, amount * sizeof( classType ) ) )
|
||||
|
||||
#define eeMalloc(amount) \
|
||||
EE::MemoryManager::AddPointer( EE::cAllocatedPointer( malloc( amount ) , __FILE__, __LINE__, amount ) )
|
||||
|
||||
#define eeDelete(data){ \
|
||||
if( EE::MemoryManager::RemovePointer( EE::MemoryManager::DeleteAndReturn( data ) ) == false ) printf( "Deleting at '%s' %d\n", __FILE__, __LINE__ ); \
|
||||
}
|
||||
|
||||
#define eeDeleteArray(data){ \
|
||||
if(EE::MemoryManager::RemovePointer( EE::MemoryManager::DeleteArrayAndReturn( data ) ) == false ) printf( "Deleting at '%s' %d\n", __FILE__, __LINE__ ); \
|
||||
}
|
||||
|
||||
#define eeFree( data ){ \
|
||||
if( EE::MemoryManager::RemovePointer( EE::MemoryManager::FreeAndReturn( data ) ) == false ) printf( "Deleting at '%s' %d\n", __FILE__, __LINE__ ); \
|
||||
}
|
||||
#else
|
||||
#define eeNew(classType, constructor) \
|
||||
new classType constructor
|
||||
|
||||
#define eeNewArray(classType, amount) \
|
||||
new classType [ amount ]
|
||||
|
||||
#define eeMalloc(amount) \
|
||||
malloc( amount )
|
||||
|
||||
#define eeDelete(data) \
|
||||
delete data;
|
||||
|
||||
#define eeDeleteArray(data) \
|
||||
delete [] data;
|
||||
|
||||
#define eeFree(data) \
|
||||
free(data);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
68
src/base/stlcontainers.hpp
Normal file
68
src/base/stlcontainers.hpp
Normal file
@@ -0,0 +1,68 @@
|
||||
#ifndef EE_STLCONTAINERS_HPP
|
||||
#define EE_STLCONTAINERS_HPP
|
||||
|
||||
namespace EE {
|
||||
|
||||
template <typename T, typename A = eeAllocator<T> >
|
||||
struct eeDeque {
|
||||
#ifdef EE_MEMORY_MANAGER
|
||||
typedef typename std::deque<T, A> type;
|
||||
#else
|
||||
typedef typename std::deque<T> type;
|
||||
#endif
|
||||
};
|
||||
|
||||
template <typename T, typename A = eeAllocator<T> >
|
||||
struct eeVector {
|
||||
#ifdef EE_MEMORY_MANAGER
|
||||
typedef typename std::vector<T, A> type;
|
||||
#else
|
||||
typedef typename std::vector<T> type;
|
||||
#endif
|
||||
};
|
||||
|
||||
template <typename T, typename A = eeAllocator<T> >
|
||||
struct eeList {
|
||||
#ifdef EE_MEMORY_MANAGER
|
||||
typedef typename std::list<T, A> type;
|
||||
#else
|
||||
typedef typename std::list<T> type;
|
||||
#endif
|
||||
};
|
||||
|
||||
template <typename T, typename P = std::less<T>, typename A = eeAllocator<T> >
|
||||
struct eeSet {
|
||||
#ifdef EE_MEMORY_MANAGER
|
||||
typedef typename std::set<T, P, A> type;
|
||||
#else
|
||||
typedef typename std::set<T, P> type;
|
||||
#endif
|
||||
};
|
||||
|
||||
template <typename K, typename V, typename P = std::less<K>, typename A = eeAllocator< std::pair<const K, V> > >
|
||||
struct eeMap {
|
||||
#ifdef EE_MEMORY_MANAGER
|
||||
typedef typename std::map<K, V, P, A> type;
|
||||
#else
|
||||
typedef typename std::map<K, V, P> type;
|
||||
#endif
|
||||
};
|
||||
|
||||
template <typename K, typename V, typename P = std::less<K>, typename A = eeAllocator< std::pair<const K, V> > >
|
||||
struct eeMultimap {
|
||||
#ifdef EE_MEMORY_MANAGER
|
||||
typedef typename std::multimap<K, V, P, A> type;
|
||||
#else
|
||||
typedef typename std::multimap<K, V, P> type;
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef eeVector<Uint8>::type eeVectorUint8;
|
||||
typedef eeVector<Uint16>::type eeVectorUint16;
|
||||
typedef eeVector<Uint32>::type eeVectorUint32;
|
||||
typedef eeVector<Int8>::type eeVectorInt8;
|
||||
typedef eeVector<Int16>::type eeVectorInt16;
|
||||
typedef eeVector<Int32>::type eeVectorInt32;
|
||||
}
|
||||
|
||||
#endif
|
||||
3
src/ee.h
3
src/ee.h
@@ -123,6 +123,9 @@
|
||||
#include "graphics/cframebuffer.hpp"
|
||||
#include "graphics/cframebufferfbo.hpp"
|
||||
#include "graphics/cframebufferpbuffer.hpp"
|
||||
#include "graphics/cvertexbuffer.hpp"
|
||||
#include "graphics/cvertexbufferogl.hpp"
|
||||
#include "graphics/cvertexbuffervbo.hpp"
|
||||
using namespace EE::Graphics;
|
||||
|
||||
// Gaming
|
||||
|
||||
@@ -7,7 +7,7 @@ cBatchRenderer::cBatchRenderer() :
|
||||
mNumVertex(0),
|
||||
mTexture(NULL),
|
||||
mBlend(ALPHA_NORMAL),
|
||||
mCurrentMode(EE_GL_QUADS),
|
||||
mCurrentMode(EE_DT_QUADS),
|
||||
mRotation(0.0f),
|
||||
mScale(1.0f),
|
||||
mPosition(0.0f, 0.0f),
|
||||
@@ -23,7 +23,7 @@ cBatchRenderer::cBatchRenderer( const eeUint& Prealloc ) :
|
||||
mNumVertex(0),
|
||||
mTexture(NULL),
|
||||
mBlend(ALPHA_NORMAL),
|
||||
mCurrentMode(EE_GL_QUADS),
|
||||
mCurrentMode(EE_DT_QUADS),
|
||||
mRotation(0.0f),
|
||||
mScale(1.0f),
|
||||
mPosition(0.0f, 0.0f),
|
||||
@@ -73,7 +73,7 @@ void cBatchRenderer::AddVertexs( const eeUint& num ) {
|
||||
Flush();
|
||||
}
|
||||
|
||||
void cBatchRenderer::SetBlendMode( EE_BATCH_RENDER_METHOD Mode, const bool& Force ) {
|
||||
void cBatchRenderer::SetBlendMode( EE_DRAW_TYPE Mode, const bool& Force ) {
|
||||
if ( Force && mCurrentMode != Mode ) {
|
||||
Flush();
|
||||
mCurrentMode = Mode;
|
||||
@@ -93,7 +93,7 @@ void cBatchRenderer::Flush() {
|
||||
|
||||
cTextureFactory::instance()->SetBlendFunc( mBlend );
|
||||
|
||||
if ( mCurrentMode == EE_GL_POINTS && NULL != mTexture ) {
|
||||
if ( mCurrentMode == EE_DT_POINTS && NULL != mTexture ) {
|
||||
glEnable( GL_POINT_SPRITE_ARB );
|
||||
glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE );
|
||||
glPointSize( (GLfloat)mTexture->Width() );
|
||||
@@ -120,7 +120,7 @@ void cBatchRenderer::Flush() {
|
||||
if ( CreateMatrix )
|
||||
glPopMatrix();
|
||||
|
||||
if ( mCurrentMode == EE_GL_POINTS && mTexture > 0 ) {
|
||||
if ( mCurrentMode == EE_DT_POINTS && mTexture > 0 ) {
|
||||
glDisable( GL_POINT_SPRITE_ARB );
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ void cBatchRenderer::BatchQuad( const eeFloat& x, const eeFloat& y, const eeFloa
|
||||
}
|
||||
|
||||
#ifndef EE_GLES
|
||||
SetBlendMode( EE_GL_QUADS, mForceBlendMode );
|
||||
SetBlendMode( EE_DT_QUADS, mForceBlendMode );
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex ];
|
||||
mTVertex->pos.x = x;
|
||||
@@ -172,7 +172,7 @@ void cBatchRenderer::BatchQuad( const eeFloat& x, const eeFloat& y, const eeFloa
|
||||
mTVertex->color = mVerColor[3];
|
||||
Rotate(center, &mTVertex->pos, angle);
|
||||
#else
|
||||
SetBlendMode( EE_GL_TRIANGLE_STRIP, mForceBlendMode );
|
||||
SetBlendMode( EE_DT_TRIANGLE_STRIP, mForceBlendMode );
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex ];
|
||||
mTVertex->pos.x = x;
|
||||
@@ -232,7 +232,7 @@ void cBatchRenderer::BatchQuadEx( const eeFloat& x, const eeFloat& y, const eeFl
|
||||
center.y += y;
|
||||
|
||||
#ifndef EE_GLES
|
||||
SetBlendMode( EE_GL_QUADS, mForceBlendMode );
|
||||
SetBlendMode( EE_DT_QUADS, mForceBlendMode );
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex ];
|
||||
mTVertex->pos.x = mx;
|
||||
@@ -262,7 +262,7 @@ void cBatchRenderer::BatchQuadEx( const eeFloat& x, const eeFloat& y, const eeFl
|
||||
mTVertex->color = mVerColor[3];
|
||||
Rotate(center, &mTVertex->pos, angle);
|
||||
#else
|
||||
SetBlendMode( EE_GL_TRIANGLE_STRIP, mForceBlendMode );
|
||||
SetBlendMode( EE_DT_TRIANGLE_STRIP, mForceBlendMode );
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex ];
|
||||
mTVertex->pos.x = mx;
|
||||
@@ -301,7 +301,7 @@ void cBatchRenderer::BatchQuadFree( const eeFloat& x0, const eeFloat& y0, const
|
||||
return;
|
||||
|
||||
#ifndef EE_GLES
|
||||
SetBlendMode( EE_GL_QUADS, mForceBlendMode );
|
||||
SetBlendMode( EE_DT_QUADS, mForceBlendMode );
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex ];
|
||||
mTVertex->pos.x = x0;
|
||||
@@ -327,7 +327,7 @@ void cBatchRenderer::BatchQuadFree( const eeFloat& x0, const eeFloat& y0, const
|
||||
mTVertex->tex = mTexCoord[3];
|
||||
mTVertex->color = mVerColor[3];
|
||||
#else
|
||||
SetBlendMode( EE_GL_TRIANGLE_STRIP, mForceBlendMode );
|
||||
SetBlendMode( EE_DT_TRIANGLE_STRIP, mForceBlendMode );
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex ];
|
||||
mTVertex->pos.x = x0;
|
||||
@@ -397,7 +397,7 @@ void cBatchRenderer::BatchQuadFreeEx( const eeFloat& x0, const eeFloat& y0, cons
|
||||
mQ = RotateQuadCentered( mQ, Angle, QCenter );
|
||||
|
||||
#ifndef EE_GLES
|
||||
SetBlendMode( EE_GL_QUADS, mForceBlendMode );
|
||||
SetBlendMode( EE_DT_QUADS, mForceBlendMode );
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex ];
|
||||
mTVertex->pos.x = mQ[0].x;
|
||||
@@ -423,7 +423,7 @@ void cBatchRenderer::BatchQuadFreeEx( const eeFloat& x0, const eeFloat& y0, cons
|
||||
mTVertex->tex = mTexCoord[3];
|
||||
mTVertex->color = mVerColor[3];
|
||||
#else
|
||||
SetBlendMode( EE_GL_TRIANGLE_STRIP, mForceBlendMode );
|
||||
SetBlendMode( EE_DT_TRIANGLE_STRIP, mForceBlendMode );
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex ];
|
||||
mTVertex->pos.x = mQ[0].x;
|
||||
@@ -454,7 +454,7 @@ void cBatchRenderer::BatchQuadFreeEx( const eeFloat& x0, const eeFloat& y0, cons
|
||||
}
|
||||
|
||||
void cBatchRenderer::QuadsBegin() {
|
||||
SetBlendMode( EE_GL_QUADS, true );
|
||||
SetBlendMode( EE_DT_QUADS, true );
|
||||
QuadsSetSubset( 0, 0, 1, 1 );
|
||||
QuadsSetColor( eeColorA() );
|
||||
}
|
||||
@@ -495,7 +495,7 @@ void cBatchRenderer::Rotate( const eeVector2f& center, eeVector2f* point, const
|
||||
}
|
||||
|
||||
void cBatchRenderer::PointsBegin() {
|
||||
SetBlendMode( EE_GL_POINTS, true );
|
||||
SetBlendMode( EE_DT_POINTS, true );
|
||||
QuadsSetSubset( 0, 0, 1, 1 );
|
||||
PointSetColor( eeColorA() );
|
||||
}
|
||||
@@ -508,7 +508,7 @@ void cBatchRenderer::BatchPoint( const eeFloat& x, const eeFloat& y ) {
|
||||
if ( mNumVertex + 1 >= mVertex.size() )
|
||||
return;
|
||||
|
||||
SetBlendMode( EE_GL_POINTS, mForceBlendMode );
|
||||
SetBlendMode( EE_DT_POINTS, mForceBlendMode );
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex ];
|
||||
mTVertex->pos.x = x;
|
||||
@@ -520,7 +520,7 @@ void cBatchRenderer::BatchPoint( const eeFloat& x, const eeFloat& y ) {
|
||||
}
|
||||
|
||||
void cBatchRenderer::LinesBegin() {
|
||||
SetBlendMode( EE_GL_LINES, true );
|
||||
SetBlendMode( EE_DT_LINES, true );
|
||||
QuadsSetSubset( 0, 0, 1, 1 );
|
||||
PointSetColor( eeColorA() );
|
||||
}
|
||||
@@ -537,7 +537,7 @@ void cBatchRenderer::BatchLine( const eeFloat& x0, const eeFloat& y0, const eeFl
|
||||
if ( mNumVertex + 1 >= mVertex.size() )
|
||||
return;
|
||||
|
||||
SetBlendMode( EE_GL_LINES, mForceBlendMode );
|
||||
SetBlendMode( EE_DT_LINES, mForceBlendMode );
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex ];
|
||||
mTVertex->pos.x = x0;
|
||||
@@ -555,7 +555,7 @@ void cBatchRenderer::BatchLine( const eeFloat& x0, const eeFloat& y0, const eeFl
|
||||
}
|
||||
|
||||
void cBatchRenderer::LineLoopBegin() {
|
||||
SetBlendMode( EE_GL_LINE_LOOP, true );
|
||||
SetBlendMode( EE_DT_LINE_LOOP, true );
|
||||
QuadsSetSubset( 0, 0, 1, 1 );
|
||||
PointSetColor( eeColorA() );
|
||||
}
|
||||
@@ -572,7 +572,7 @@ void cBatchRenderer::BatchLineLoop( const eeFloat& x0, const eeFloat& y0, const
|
||||
if ( mNumVertex + 1 >= mVertex.size() )
|
||||
return;
|
||||
|
||||
SetBlendMode( EE_GL_LINE_LOOP, mForceBlendMode );
|
||||
SetBlendMode( EE_DT_LINE_LOOP, mForceBlendMode );
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex ];
|
||||
mTVertex->pos.x = x0;
|
||||
@@ -597,7 +597,7 @@ void cBatchRenderer::BatchLineLoop( const eeFloat& x0, const eeFloat& y0 ) {
|
||||
if ( mNumVertex + 1 >= mVertex.size() )
|
||||
return;
|
||||
|
||||
SetBlendMode( EE_GL_LINE_LOOP, mForceBlendMode );
|
||||
SetBlendMode( EE_DT_LINE_LOOP, mForceBlendMode );
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex ];
|
||||
mTVertex->pos.x = x0;
|
||||
@@ -613,7 +613,7 @@ void cBatchRenderer::BatchLineLoop( const eeVector2f& vector1 ) {
|
||||
}
|
||||
|
||||
void cBatchRenderer::TriangleFanBegin() {
|
||||
SetBlendMode( EE_GL_TRIANGLE_FAN, true );
|
||||
SetBlendMode( EE_DT_TRIANGLE_FAN, true );
|
||||
TriangleFanSetSubset( 0, 0, 0, 1, 1, 1 );
|
||||
TriangleFanSetColor( eeColorA() );
|
||||
}
|
||||
@@ -637,7 +637,7 @@ void cBatchRenderer::BatchTriangleFan( const eeFloat& x0, const eeFloat& y0, con
|
||||
if ( mNumVertex + 2 >= mVertex.size() )
|
||||
return;
|
||||
|
||||
SetBlendMode( EE_GL_TRIANGLE_FAN, mForceBlendMode );
|
||||
SetBlendMode( EE_DT_TRIANGLE_FAN, mForceBlendMode );
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex ];
|
||||
mTVertex->pos.x = x0;
|
||||
@@ -661,7 +661,7 @@ void cBatchRenderer::BatchTriangleFan( const eeFloat& x0, const eeFloat& y0, con
|
||||
}
|
||||
|
||||
void cBatchRenderer::TrianglesBegin() {
|
||||
SetBlendMode( EE_GL_TRIANGLES, true );
|
||||
SetBlendMode( EE_DT_TRIANGLES, true );
|
||||
TrianglesSetSubset( 0, 0, 0, 1, 1, 1 );
|
||||
TrianglesSetColor( eeColorA() );
|
||||
}
|
||||
@@ -685,7 +685,7 @@ void cBatchRenderer::BatchTriangle( const eeFloat& x0, const eeFloat& y0, const
|
||||
if ( mNumVertex + 2 >= mVertex.size() )
|
||||
return;
|
||||
|
||||
SetBlendMode( EE_GL_TRIANGLES, mForceBlendMode );
|
||||
SetBlendMode( EE_DT_TRIANGLES, mForceBlendMode );
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex ];
|
||||
mTVertex->pos.x = x0;
|
||||
@@ -716,7 +716,7 @@ void cBatchRenderer::BatchPolygon( const eePolygon2f& Polygon ) {
|
||||
if ( Polygon.Size() > mVertex.size() )
|
||||
return;
|
||||
|
||||
SetBlendMode( EE_GL_POLYGON, mForceBlendMode );
|
||||
SetBlendMode( EE_DT_POLYGON, mForceBlendMode );
|
||||
|
||||
for ( Uint32 i = 0; i < Polygon.Size(); i++ ) {
|
||||
mTVertex = &mVertex[ mNumVertex ];
|
||||
@@ -734,7 +734,7 @@ void cBatchRenderer::BatchPolygonByPoint( const eeFloat& x, const eeFloat& y ) {
|
||||
if ( mNumVertex + 1 >= mVertex.size() )
|
||||
return;
|
||||
|
||||
SetBlendMode( EE_GL_POLYGON, mForceBlendMode );
|
||||
SetBlendMode( EE_DT_POLYGON, mForceBlendMode );
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex ];
|
||||
mTVertex->pos.x = x;
|
||||
|
||||
@@ -71,16 +71,16 @@ class EE_API cBatchRenderer {
|
||||
/** @return The batch center position */
|
||||
eeVector2f BatchCenter() const { return mCenter; }
|
||||
|
||||
/** Add to the batch a quad ( this will change your batch rendering method to GL_QUADS, so if you were using another one will Draw all the batched vertexs first ) */
|
||||
/** Add to the batch a quad ( this will change your batch rendering method to EE_DT_QUADS, so if you were using another one will Draw all the batched vertexs first ) */
|
||||
void BatchQuadEx( const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeFloat& angle = 0.0f, const eeFloat& scale = 1.0f, const bool& scalefromcenter = true );
|
||||
|
||||
/** Add to the batch a quad ( this will change your batch rendering method to GL_QUADS, so if you were using another one will Draw all the batched vertexs first ) */
|
||||
/** Add to the batch a quad ( this will change your batch rendering method to EE_DT_QUADS, so if you were using another one will Draw all the batched vertexs first ) */
|
||||
void BatchQuad( const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeFloat& angle = 0.0f );
|
||||
|
||||
/** Add to the batch a quad with the vertex freely seted ( this will change your batch rendering method to GL_QUADS, so if you were using another one will Draw all the batched vertexs first ) */
|
||||
/** Add to the batch a quad with the vertex freely seted ( this will change your batch rendering method to EE_DT_QUADS, so if you were using another one will Draw all the batched vertexs first ) */
|
||||
void BatchQuadFree( const eeFloat& x0, const eeFloat& y0, const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3 );
|
||||
|
||||
/** Add to the batch a quad with the vertex freely seted ( this will change your batch rendering method to GL_QUADS, so if you were using another one will Draw all the batched vertexs first ) */
|
||||
/** Add to the batch a quad with the vertex freely seted ( this will change your batch rendering method to EE_DT_QUADS, so if you were using another one will Draw all the batched vertexs first ) */
|
||||
void BatchQuadFreeEx( const eeFloat& x0, const eeFloat& y0, const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const eeFloat& Angle = 0.0f, const eeFloat& Scale = 1.0f );
|
||||
|
||||
/** This will set as the default batch rendering to GL_QUADS. WIll reset the texture subset rendering to the whole texture. Will reset the default color rendering to eeColorA(255,255,255,255). */
|
||||
@@ -98,16 +98,16 @@ class EE_API cBatchRenderer {
|
||||
/** Set the quad color per vertex */
|
||||
void QuadsSetColorFree( const eeColorA Color0, const eeColorA Color1, const eeColorA Color2, const eeColorA Color3 );
|
||||
|
||||
/** This will set as the default batch rendering to GL_POINTS. And will reset the point color to eeColorA(255,255,255,255). */
|
||||
/** This will set as the default batch rendering to EE_DT_POINTS. And will reset the point color to eeColorA(255,255,255,255). */
|
||||
void PointsBegin();
|
||||
|
||||
/** Set the point color */
|
||||
void PointSetColor( const eeColorA Color );
|
||||
|
||||
/** Add to the batch a point ( this will change your batch rendering method to GL_POINTS, so if you were using another one will Draw all the batched vertexs first ) */
|
||||
/** Add to the batch a point ( this will change your batch rendering method to EE_DT_POINTS, so if you were using another one will Draw all the batched vertexs first ) */
|
||||
void BatchPoint( const eeFloat& x, const eeFloat& y );
|
||||
|
||||
/** This will set as the default batch rendering to GL_LINES. And will reset the line color to eeColorA(255,255,255,255). */
|
||||
/** This will set as the default batch rendering to EE_DT_LINES. And will reset the line color to eeColorA(255,255,255,255). */
|
||||
void LinesBegin();
|
||||
|
||||
/** Set the line color */
|
||||
@@ -116,7 +116,7 @@ class EE_API cBatchRenderer {
|
||||
/** Set the line color, per vertex */
|
||||
void LinesSetColorFree( const eeColorA Color0, const eeColorA Color1 );
|
||||
|
||||
/** Add to the batch a line ( this will change your batch rendering method to GL_LINES, so if you were using another one will Draw all the batched vertexs first ) */
|
||||
/** Add to the batch a line ( this will change your batch rendering method to EE_DT_LINES, so if you were using another one will Draw all the batched vertexs first ) */
|
||||
void BatchLine( const eeFloat& x0, const eeFloat& y0, const eeFloat& x1, const eeFloat& y1 );
|
||||
|
||||
/** This will set as the default batch rendering to GL_LINE_LOOP. And will reset the line color to eeColorA(255,255,255,255). */
|
||||
@@ -128,7 +128,7 @@ class EE_API cBatchRenderer {
|
||||
/** Set the line color, per vertex */
|
||||
void LineLoopSetColorFree( const eeColorA Color0, const eeColorA Color1 );
|
||||
|
||||
/** Add to the batch a line ( this will change your batch rendering method to GL_LINE_LOOP, so if you were using another one will Draw all the batched vertexs first ) */
|
||||
/** Add to the batch a line ( this will change your batch rendering method to EE_DT_LINE_LOOP, so if you were using another one will Draw all the batched vertexs first ) */
|
||||
void BatchLineLoop( const eeFloat& x0, const eeFloat& y0, const eeFloat& x1, const eeFloat& y1 );
|
||||
|
||||
void BatchLineLoop( const eeFloat& x0, const eeFloat& y0);
|
||||
@@ -137,7 +137,7 @@ class EE_API cBatchRenderer {
|
||||
|
||||
void BatchLineLoop( const eeVector2f& vector1 );
|
||||
|
||||
/** This will set as the default batch rendering to GL_TRIANGLE_FAN. And will reset the line color to eeColorA(255,255,255,255). */
|
||||
/** This will set as the default batch rendering to EE_DT_TRIANGLE_FAN. And will reset the line color to eeColorA(255,255,255,255). */
|
||||
void TriangleFanBegin();
|
||||
|
||||
/** Set the triangle fan color */
|
||||
@@ -149,10 +149,10 @@ class EE_API cBatchRenderer {
|
||||
/** Set the texture sector to be rendered but freely seted */
|
||||
void TriangleFanSetSubset( const eeFloat& x0, const eeFloat& y0, const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2 );
|
||||
|
||||
/** Add to the batch a triangle fan ( this will change your batch rendering method to GL_TRIANGLE_FAN, so if you were using another one will Draw all the batched vertexs first ) */
|
||||
/** Add to the batch a triangle fan ( this will change your batch rendering method to EE_DT_TRIANGLE_FAN, so if you were using another one will Draw all the batched vertexs first ) */
|
||||
void BatchTriangleFan( const eeFloat& x0, const eeFloat& y0, const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2 );
|
||||
|
||||
/** This will set as the default batch rendering to GL_TRIANGLES. And will reset the line color to eeColorA(255,255,255,255). */
|
||||
/** This will set as the default batch rendering to EE_DT_TRIANGLES. And will reset the line color to eeColorA(255,255,255,255). */
|
||||
void TrianglesBegin();
|
||||
|
||||
/** Set the triangles color */
|
||||
@@ -164,13 +164,13 @@ class EE_API cBatchRenderer {
|
||||
/** Set the texture sector to be rendered but freely seted */
|
||||
void TrianglesSetSubset( const eeFloat& x0, const eeFloat& y0, const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2 );
|
||||
|
||||
/** Add to the batch a triangle ( this will change your batch rendering method to GL_TRIANGLES, so if you were using another one will Draw all the batched vertexs first ) */
|
||||
/** Add to the batch a triangle ( this will change your batch rendering method to EE_DT_TRIANGLES, so if you were using another one will Draw all the batched vertexs first ) */
|
||||
void BatchTriangle( const eeFloat& x0, const eeFloat& y0, const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2 );
|
||||
|
||||
/** Set the polygon color */
|
||||
void PolygonSetColor( const eeColorA& Color );
|
||||
|
||||
/** Add to the batch a polygon ( this will change your batch rendering method to GL_POLYGON, so if you were using another one will Draw all the batched vertexs first ) */
|
||||
/** Add to the batch a polygon ( this will change your batch rendering method to EE_DT_POLYGON, so if you were using another one will Draw all the batched vertexs first ) */
|
||||
void BatchPolygon( const eePolygon2f& Polygon );
|
||||
|
||||
/** Set the line width */
|
||||
@@ -197,7 +197,7 @@ class EE_API cBatchRenderer {
|
||||
eeTexCoord mTexCoord[4];
|
||||
eeColorA mVerColor[4];
|
||||
|
||||
EE_BATCH_RENDER_METHOD mCurrentMode;
|
||||
EE_DRAW_TYPE mCurrentMode;
|
||||
|
||||
eeFloat mRotation, mScale;
|
||||
eeVector2f mPosition, mCenter;
|
||||
@@ -209,7 +209,7 @@ class EE_API cBatchRenderer {
|
||||
void Init();
|
||||
void AddVertexs( const eeUint& num );
|
||||
void Rotate( const eeVector2f& center, eeVector2f* point, const eeFloat& angle );
|
||||
void SetBlendMode( EE_BATCH_RENDER_METHOD Mode, const bool& Force );
|
||||
void SetBlendMode( EE_DRAW_TYPE Mode, const bool& Force );
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -8,10 +8,10 @@ namespace EE { namespace Graphics {
|
||||
|
||||
cFrameBuffer * cFrameBuffer::CreateNew( const Uint32& Width, const Uint32& Height, bool DepthBuffer ) {
|
||||
if ( cFrameBufferFBO::IsSupported() )
|
||||
return new cFrameBufferFBO( Width, Height, DepthBuffer );
|
||||
return eeNew( cFrameBufferFBO, ( Width, Height, DepthBuffer ) );
|
||||
|
||||
if ( cFrameBufferPBuffer::IsSupported() )
|
||||
return new cFrameBufferPBuffer( Width, Height, DepthBuffer );
|
||||
return eeNew( cFrameBufferPBuffer, ( Width, Height, DepthBuffer ) );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ Uint8* cImage::GetPixels() const {
|
||||
void cImage::Allocate( const Uint32& size ) {
|
||||
ClearCache();
|
||||
|
||||
mPixels = new unsigned char[ size ];
|
||||
mPixels = eeNewArray( unsigned char, size );
|
||||
mSize = size;
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ eeUint cImage::Channels() const {
|
||||
return mChannels;
|
||||
}
|
||||
|
||||
bool cImage::SaveToFile( const std::string& filepath, const EE_SAVETYPE& Format ) {
|
||||
bool cImage::SaveToFile( const std::string& filepath, const EE_SAVE_TYPE& Format ) {
|
||||
bool Res = false;
|
||||
|
||||
if ( NULL != mPixels && 0 != mWidth && 0 != mHeight && 0 != mChannels ) {
|
||||
@@ -233,7 +233,7 @@ void cImage::CopyImage( cImage * Img, const eeUint& x, const eeUint& y ) {
|
||||
|
||||
void cImage::Resize( const eeUint& new_width, const eeUint& new_height ) {
|
||||
if ( NULL != mPixels && mWidth != new_width && mHeight != new_height ) {
|
||||
unsigned char * resampled = new unsigned char[ mChannels * new_width * new_height ];
|
||||
unsigned char * resampled = eeNewArray( unsigned char, mChannels * new_width * new_height );
|
||||
|
||||
int res = up_scale_image( reinterpret_cast<const unsigned char*> ( mPixels ), mWidth, mHeight, mChannels, resampled, new_width, new_height );
|
||||
|
||||
@@ -266,12 +266,12 @@ cImage * cImage::Thumbnail( const eeUint& max_width, const eeUint& max_height )
|
||||
Int32 new_width = (Int32)( (eeFloat)mWidth * iScale );
|
||||
Int32 new_height = (Int32)( (eeFloat)mHeight * iScale );
|
||||
|
||||
unsigned char * resampled = new unsigned char[ mChannels * new_width * new_height ];
|
||||
unsigned char * resampled = eeNewArray( unsigned char, mChannels * new_width * new_height );
|
||||
|
||||
int res = up_scale_image( reinterpret_cast<const unsigned char*> ( mPixels ), mWidth, mHeight, mChannels, resampled, new_width, new_height );
|
||||
|
||||
if ( res ) {
|
||||
return new cImage( (Uint8*)resampled, new_width, new_height, mChannels );
|
||||
return eeNew( cImage, ( (Uint8*)resampled, new_width, new_height, mChannels ) );
|
||||
} else {
|
||||
eeSAFE_DELETE_ARRAY( resampled );
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ class EE_API cImage {
|
||||
eeUint Size() const;
|
||||
|
||||
/** Save the Image to a new File in a specific format */
|
||||
virtual bool SaveToFile( const std::string& filepath, const EE_SAVETYPE& Format );
|
||||
virtual bool SaveToFile( const std::string& filepath, const EE_SAVE_TYPE& Format );
|
||||
|
||||
/** Create an Alpha mask from a Color */
|
||||
virtual void CreateMaskFromColor( const eeColorA& ColorKey, Uint8 Alpha );
|
||||
|
||||
@@ -30,8 +30,8 @@ cShaderProgram::cShaderProgram( const std::string& VertexShaderFile, const std::
|
||||
AddToManager( name );
|
||||
Init();
|
||||
|
||||
cVertexShader * vs = new cVertexShader( VertexShaderFile );
|
||||
cFragmentShader * fs = new cFragmentShader( FragmentShaderFile );
|
||||
cVertexShader * vs = eeNew( cVertexShader, ( VertexShaderFile ) );
|
||||
cFragmentShader * fs = eeNew( cFragmentShader, ( FragmentShaderFile ) );
|
||||
|
||||
if ( !vs->IsValid() || !fs->IsValid() ) {
|
||||
eeSAFE_DELETE( vs );
|
||||
@@ -52,8 +52,8 @@ cShaderProgram::cShaderProgram( cPack * Pack, const std::string& VertexShaderPat
|
||||
Init();
|
||||
|
||||
if ( NULL != Pack && Pack->IsOpen() && -1 != Pack->Exists( VertexShaderPath ) && -1 != Pack->Exists( FragmentShaderPath ) ) {
|
||||
cVertexShader * vs = new cVertexShader( Pack, VertexShaderPath );
|
||||
cFragmentShader * fs = new cFragmentShader( Pack, FragmentShaderPath );
|
||||
cVertexShader * vs = eeNew( cVertexShader, ( Pack, VertexShaderPath ) );
|
||||
cFragmentShader * fs = eeNew( cFragmentShader, ( Pack, FragmentShaderPath ) );
|
||||
|
||||
if ( !vs->IsValid() || !fs->IsValid() ) {
|
||||
eeSAFE_DELETE( vs );
|
||||
@@ -74,8 +74,8 @@ cShaderProgram::cShaderProgram( const Uint8 * VertexShaderData, const Uint32& Ve
|
||||
AddToManager( name );
|
||||
Init();
|
||||
|
||||
cVertexShader * vs = new cVertexShader( VertexShaderData, VertexShaderDataSize );
|
||||
cFragmentShader * fs = new cFragmentShader( FragmentShaderData, FragmentShaderDataSize );
|
||||
cVertexShader * vs = eeNew( cVertexShader, ( VertexShaderData, VertexShaderDataSize ) );
|
||||
cFragmentShader * fs = eeNew( cFragmentShader, ( FragmentShaderData, FragmentShaderDataSize ) );
|
||||
|
||||
if ( !vs->IsValid() || !fs->IsValid() ) {
|
||||
eeSAFE_DELETE( vs );
|
||||
|
||||
@@ -198,7 +198,7 @@ void cShape::CacheAlphaMask() {
|
||||
Uint32 size = ( mSrcRect.Right - mSrcRect.Left ) * ( mSrcRect.Bottom - mSrcRect.Top );
|
||||
|
||||
eeSAFE_DELETE_ARRAY( mAlpha );
|
||||
mAlpha = new Uint8[ size ];
|
||||
mAlpha = eeNewArray( Uint8, size );
|
||||
|
||||
mTexture->Lock();
|
||||
|
||||
@@ -226,7 +226,7 @@ void cShape::CacheColors() {
|
||||
|
||||
eeSAFE_DELETE_ARRAY( mPixels );
|
||||
|
||||
mPixels = new Uint8[ size ];
|
||||
mPixels = eeNewArray( Uint8, size );
|
||||
|
||||
eeInt rY = 0;
|
||||
eeInt rX = 0;
|
||||
@@ -371,7 +371,7 @@ const Uint8* cShape::GetPixelsPtr() {
|
||||
return reinterpret_cast<const Uint8*> (&mPixels[0]);
|
||||
}
|
||||
|
||||
bool cShape::SaveToFile(const std::string& filepath, const EE_SAVETYPE& Format) {
|
||||
bool cShape::SaveToFile(const std::string& filepath, const EE_SAVE_TYPE& Format) {
|
||||
bool Res = false;
|
||||
|
||||
Lock();
|
||||
|
||||
@@ -85,7 +85,7 @@ class EE_API cShape {
|
||||
|
||||
const Uint8* GetPixelsPtr();
|
||||
|
||||
bool SaveToFile(const std::string& filepath, const EE_SAVETYPE& Format);
|
||||
bool SaveToFile(const std::string& filepath, const EE_SAVE_TYPE& Format);
|
||||
protected:
|
||||
Uint8 * mPixels;
|
||||
Uint8 * mAlpha;
|
||||
|
||||
@@ -29,19 +29,19 @@ cShape * cShapeGroup::Add( cShape * Shape ) {
|
||||
}
|
||||
|
||||
cShape * cShapeGroup::Add( const Uint32& TexId, const std::string& Name ) {
|
||||
return Add( new cShape( TexId, Name ) );
|
||||
return Add( eeNew( cShape, ( TexId, Name ) ) );
|
||||
}
|
||||
|
||||
cShape * cShapeGroup::Add( const Uint32& TexId, const eeRecti& SrcRect, const std::string& Name ) {
|
||||
return Add( new cShape( TexId, SrcRect, Name ) );
|
||||
return Add( eeNew( cShape, ( TexId, SrcRect, Name ) ) );
|
||||
}
|
||||
|
||||
cShape * cShapeGroup::Add( const Uint32& TexId, const eeRecti& SrcRect, const eeFloat& DestWidth, const eeFloat& DestHeight, const std::string& Name ) {
|
||||
return Add( new cShape( TexId, SrcRect, DestWidth, DestHeight, Name ) );
|
||||
return Add( eeNew ( cShape, ( TexId, SrcRect, DestWidth, DestHeight, Name ) ) );
|
||||
}
|
||||
|
||||
cShape * cShapeGroup::Add( const Uint32& TexId, const eeRecti& SrcRect, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeFloat& OffsetX, const eeFloat& OffsetY, const std::string& Name ) {
|
||||
return Add( new cShape( TexId, SrcRect, DestWidth, DestHeight, OffsetX, OffsetY, Name ) );
|
||||
return Add( eeNew ( cShape, ( TexId, SrcRect, DestWidth, DestHeight, OffsetX, OffsetY, Name ) ) );
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -274,7 +274,7 @@ bool cSprite::AddSubFrame(const Uint32& TexId, const eeUint& NumFrame, const eeU
|
||||
return false;
|
||||
|
||||
cTexture * Tex = cTextureFactory::instance()->GetTexture( TexId );
|
||||
cShape * S = cGlobalShapeGroup::instance()->Add( new cShape() );
|
||||
cShape * S = cGlobalShapeGroup::instance()->Add( eeNew( cShape, () ) );
|
||||
|
||||
S->Texture( TexId );
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ void cTexture::SetPixel( const eeUint& x, const eeUint& y, const eeColorA& Color
|
||||
mFlags |= TEX_FLAG_MODIFIED;
|
||||
}
|
||||
|
||||
bool cTexture::SaveToFile( const std::string& filepath, const EE_SAVETYPE& Format ) {
|
||||
bool cTexture::SaveToFile( const std::string& filepath, const EE_SAVE_TYPE& Format ) {
|
||||
bool Res = false;
|
||||
|
||||
if ( mTexture ) {
|
||||
|
||||
@@ -92,7 +92,7 @@ class EE_API cTexture : public cImage {
|
||||
void SetTextureFilter(const EE_TEX_FILTER& filter);
|
||||
|
||||
/** Save the Texture to a new File */
|
||||
bool SaveToFile( const std::string& filepath, const EE_SAVETYPE& Format );
|
||||
bool SaveToFile( const std::string& filepath, const EE_SAVE_TYPE& Format );
|
||||
|
||||
/** Replace a color on the texture */
|
||||
void ReplaceColor( const eeColorA& ColorKey, const eeColorA& NewColor);
|
||||
|
||||
@@ -66,7 +66,7 @@ Uint32 cTextureFactory::PushTexture( const std::string& Filepath, const Uint32&
|
||||
FPath = FPath.substr( pos + 1 );
|
||||
|
||||
Pos = FindFreeSlot();
|
||||
Tex = mTextures[ Pos ] = new cTexture();
|
||||
Tex = mTextures[ Pos ] = eeNew( cTexture, () );
|
||||
|
||||
Tex->Create( TexId, Width, Height, MyWidth, MyHeight, Mipmap, Channels, FPath, ColorKey, ClampMode, CompressTexture, MemSize );
|
||||
Tex->TexId( Pos );
|
||||
@@ -251,7 +251,7 @@ eeUint cTextureFactory::GetValidTextureSize(const eeUint& Size) {
|
||||
return NextPowOfTwo(Size);
|
||||
}
|
||||
|
||||
bool cTextureFactory::SaveImage( const std::string& filepath, const EE_SAVETYPE& Format, const eeUint& Width, const eeUint& Height, const eeUint& Channels, const unsigned char* data ) {
|
||||
bool cTextureFactory::SaveImage( const std::string& filepath, const EE_SAVE_TYPE& Format, const eeUint& Width, const eeUint& Height, const eeUint& Channels, const unsigned char* data ) {
|
||||
return 0 != SOIL_save_image ( filepath.c_str(), Format, Width, Height, Channels, data );
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ class EE_API cTextureFactory: public tSingleton<cTextureFactory>, protected cMut
|
||||
/** Saves an image from an array of unsigned chars to disk
|
||||
* @return False if failed, otherwise returns True
|
||||
*/
|
||||
bool SaveImage( const std::string& filepath, const EE_SAVETYPE& Format, const eeUint& Width, const eeUint& Height, const eeUint& Channels, const unsigned char* data );
|
||||
bool SaveImage( const std::string& filepath, const EE_SAVE_TYPE& Format, const eeUint& Width, const eeUint& Height, const eeUint& Channels, const unsigned char* data );
|
||||
|
||||
/** Determine if the TextureId passed exists */
|
||||
bool TextureIdExists( const Uint32& TexId );
|
||||
@@ -181,9 +181,10 @@ class EE_API cTextureFactory: public tSingleton<cTextureFactory>, protected cMut
|
||||
* @return The texture, NULL if not exists
|
||||
*/
|
||||
cTexture * GetByHash( const Uint32& Hash );
|
||||
|
||||
~cTextureFactory();
|
||||
protected:
|
||||
cTextureFactory();
|
||||
~cTextureFactory();
|
||||
|
||||
GLint mCurrentTexture;
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ void cTextureFontLoader::LoadFromTex() {
|
||||
}
|
||||
|
||||
void cTextureFontLoader::LoadFont() {
|
||||
mFont = new cTextureFont( mFontName );
|
||||
mFont = eeNew( cTextureFont, ( mFontName ) );
|
||||
|
||||
if ( TEF_LT_PATH == mLoadType )
|
||||
LoadFromPath();
|
||||
|
||||
@@ -84,7 +84,7 @@ void cTextureGroupLoader::Load( const std::string& TextureGroupPath ) {
|
||||
std::string path( FileRemoveFileName( mTextureGroupPath ) + name );
|
||||
|
||||
if ( !mSkipResourceLoad )
|
||||
mRL.Add( new cTextureLoader( path ) );
|
||||
mRL.Add( eeNew( cTextureLoader, ( path ) ) );
|
||||
|
||||
fs.read( reinterpret_cast<char*> (&tTexGroup.Shapes[0]), sizeof(sShapeHdr) * tTextureHdr.ShapeCount );
|
||||
|
||||
@@ -139,9 +139,9 @@ void cTextureGroupLoader::LoadFromMemory( const Uint8* Data, const Uint32& DataS
|
||||
std::string path( FileRemoveFileName( mTextureGroupPath ) + name );
|
||||
|
||||
if ( NULL != mPack )
|
||||
mRL.Add( new cTextureLoader( mPack, path ) );
|
||||
mRL.Add( eeNew( cTextureLoader, ( mPack, path ) ) );
|
||||
else
|
||||
mRL.Add( new cTextureLoader( mAppPath + path ) );
|
||||
mRL.Add( eeNew( cTextureLoader, ( mAppPath + path ) ) );
|
||||
|
||||
memcpy( (void*)(&tTexGroup.Shapes[0]), dataPtr, sizeof(sShapeHdr) * tTextureHdr.ShapeCount );
|
||||
dataPtr += sizeof(sShapeHdr) * tTextureHdr.ShapeCount;
|
||||
@@ -179,7 +179,7 @@ void cTextureGroupLoader::CreateShapes() {
|
||||
if ( mTexGrHdr.Flags & HDR_TEXTURE_GROUP_REMOVE_EXTENSION )
|
||||
name = FileRemoveExtension( name );
|
||||
|
||||
tSG = new cShapeGroup( name );
|
||||
tSG = eeNew( cShapeGroup, ( name ) );
|
||||
cShapeGroupManager::instance()->Add( tSG );
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ void cTextureGroupLoader::CreateShapes() {
|
||||
|
||||
eeRecti tRect( tSh->X, tSh->Y, tSh->X + tSh->Width, tSh->Y + tSh->Height );
|
||||
|
||||
cShape * tShape = new cShape( tTex->TexId(), tRect, tSh->DestWidth, tSh->DestHeight, tSh->OffsetX, tSh->OffsetY, ShapeName );
|
||||
cShape * tShape = eeNew( cShape, ( tTex->TexId(), tRect, tSh->DestWidth, tSh->DestHeight, tSh->OffsetX, tSh->OffsetY, ShapeName ) );
|
||||
|
||||
//if ( tSh->Flags & HDR_SHAPE_FLAG_FLIPED )
|
||||
// Should rotate the shape, but.. shape rotation is not stored.
|
||||
@@ -306,7 +306,7 @@ bool cTextureGroupLoader::UpdateTextureAtlas( std::string TextureAtlasPath, std:
|
||||
|
||||
tp.PackTextures();
|
||||
|
||||
tp.Save( tapath, (EE_SAVETYPE)mTexGrHdr.Format );
|
||||
tp.Save( tapath, (EE_SAVE_TYPE)mTexGrHdr.Format );
|
||||
} else if ( 1 == NeedUpdate ) {
|
||||
std::string etgpath = FileRemoveExtension( tapath ) + ".etg";
|
||||
std::fstream fs ( etgpath.c_str() , std::ios::out | std::ios::binary );
|
||||
@@ -358,7 +358,7 @@ bool cTextureGroupLoader::UpdateTextureAtlas( std::string TextureAtlasPath, std:
|
||||
|
||||
fs.write( reinterpret_cast<const char*> (&tTexGroup->Shapes[0]), sizeof(sShapeHdr) * tTexHdr->ShapeCount );
|
||||
|
||||
Img.SaveToFile( tapath, (EE_SAVETYPE)mTexGrHdr.Format );
|
||||
Img.SaveToFile( tapath, (EE_SAVE_TYPE)mTexGrHdr.Format );
|
||||
|
||||
SOIL_free_image_data( imgPtr );
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ void cTextureLoader::LoadFromPath() {
|
||||
if ( mIsDDS ) {
|
||||
std::fstream fs ( mFilepath.c_str() , std::ios::in | std::ios::binary );
|
||||
mSize = FileSize( mFilepath );
|
||||
mPixels = (Uint8*) malloc( mSize );
|
||||
mPixels = (Uint8*) eeMalloc( mSize );
|
||||
fs.read( reinterpret_cast<char*> ( mPixels ), mSize );
|
||||
fs.close();
|
||||
|
||||
@@ -191,7 +191,7 @@ void cTextureLoader::LoadFromMemory() {
|
||||
mIsDDS = 0 != stbi_dds_test_memory( mImagePtr, mSize );
|
||||
|
||||
if ( mIsDDS ) {
|
||||
mPixels = (Uint8*) malloc( mSize );
|
||||
mPixels = (Uint8*) eeMalloc( mSize );
|
||||
memcpy( mPixels, mImagePtr, mSize );
|
||||
stbi_dds_info_from_memory( mPixels, mSize, &mImgWidth, &mImgHeight, &mChannels, &mIsDDSCompressed );
|
||||
} else {
|
||||
@@ -234,8 +234,13 @@ void cTextureLoader::LoadFromPixels() {
|
||||
mTexId = cTextureFactory::instance()->PushTexture( mFilepath, tTexId, mImgWidth, mImgHeight, width, height, mMipmap, mChannels, mColorKey, mClampMode, mCompressTexture || mIsDDSCompressed, mLocalCopy, mSize );
|
||||
}
|
||||
|
||||
if ( TEX_LT_PIXELS != mLoadType )
|
||||
eeSAFE_FREE( mPixels );
|
||||
if ( TEX_LT_PIXELS != mLoadType ) {
|
||||
if ( mIsDDS ) {
|
||||
eeFree( mPixels );
|
||||
} else {
|
||||
SOIL_free_image_data( mPixels );
|
||||
}
|
||||
}
|
||||
|
||||
mPixels = NULL;
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ void cTexturePacker::SetOptions( const Uint32& MaxWidth, const Uint32& MaxHeight
|
||||
}
|
||||
|
||||
void cTexturePacker::NewFree( Int32 x, Int32 y, Int32 width, Int32 height ) {
|
||||
cTexturePackerNode * node = new cTexturePackerNode( x, y, width, height );
|
||||
cTexturePackerNode * node = eeNew( cTexturePackerNode, ( x, y, width, height ) );
|
||||
node->SetNext( mFreeList );
|
||||
mFreeList = node;
|
||||
}
|
||||
@@ -328,7 +328,7 @@ void cTexturePacker::InsertTexture( cTexturePackerTex * t, cTexturePackerNode *
|
||||
}
|
||||
|
||||
void cTexturePacker::CreateChild() {
|
||||
mChild = new cTexturePacker( mWidth, mHeight, mForcePowOfTwo, mPixelBorder, mAllowFlipping );
|
||||
mChild = eeNew( cTexturePacker, ( mWidth, mHeight, mForcePowOfTwo, mPixelBorder, mAllowFlipping ) );
|
||||
|
||||
std::list<cTexturePackerTex>::iterator it;
|
||||
cTexturePackerTex * t = NULL;
|
||||
@@ -484,7 +484,7 @@ Int32 cTexturePacker::PackTextures() { // pack the textures, the return code is
|
||||
return ( mWidth * mHeight ) - mTotalArea;
|
||||
}
|
||||
|
||||
void cTexturePacker::Save( const std::string& Filepath, const EE_SAVETYPE& Format, const bool& SaveExtensions ) {
|
||||
void cTexturePacker::Save( const std::string& Filepath, const EE_SAVE_TYPE& Format, const bool& SaveExtensions ) {
|
||||
if ( !mPacked )
|
||||
PackTextures();
|
||||
|
||||
@@ -509,7 +509,7 @@ void cTexturePacker::Save( const std::string& Filepath, const EE_SAVETYPE& Forma
|
||||
Uint8 * data = SOIL_load_image( t->Name().c_str(), &w, &h, &c, 0 );
|
||||
|
||||
if ( NULL != data && t->Width() == w && t->Height() == h ) {
|
||||
cImage * ImgCopy = new cImage( data, w, h, c );
|
||||
cImage * ImgCopy = eeNew( cImage, ( data, w, h, c ) );
|
||||
|
||||
if ( t->Flipped() )
|
||||
Img.Flip();
|
||||
@@ -675,7 +675,7 @@ sTextureHdr cTexturePacker::CreateTextureHdr( cTexturePacker * Packer ) {
|
||||
return TexHdr;
|
||||
}
|
||||
|
||||
void cTexturePacker::ChildSave( const EE_SAVETYPE& Format ) {
|
||||
void cTexturePacker::ChildSave( const EE_SAVE_TYPE& Format ) {
|
||||
if ( NULL != mChild ) {
|
||||
cTexturePacker * Parent = mChild->GetParent();
|
||||
cTexturePacker * LastParent = NULL;
|
||||
|
||||
@@ -54,7 +54,7 @@ class EE_API cTexturePacker {
|
||||
|
||||
Int32 PackTextures();
|
||||
|
||||
void Save( const std::string& Filepath, const EE_SAVETYPE& Format = EE_SAVE_TYPE_DDS, const bool& SaveExtensions = false );
|
||||
void Save( const std::string& Filepath, const EE_SAVE_TYPE& Format = EE_SAVE_TYPE_DDS, const bool& SaveExtensions = false );
|
||||
|
||||
void Close();
|
||||
|
||||
@@ -89,7 +89,7 @@ class EE_API cTexturePacker {
|
||||
bool mForcePowOfTwo;
|
||||
Int32 mPixelBorder;
|
||||
bool mSaveExtensions;
|
||||
EE_SAVETYPE mFormat;
|
||||
EE_SAVE_TYPE mFormat;
|
||||
|
||||
cTexturePacker * GetChild() const;
|
||||
|
||||
@@ -99,7 +99,7 @@ class EE_API cTexturePacker {
|
||||
|
||||
const std::string& GetFilepath() const;
|
||||
|
||||
void ChildSave( const EE_SAVETYPE& Format );
|
||||
void ChildSave( const EE_SAVE_TYPE& Format );
|
||||
|
||||
void SaveShapes();
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ bool cTTFFont::iLoad( const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& Ve
|
||||
|
||||
mHeight = mFont->Height() + OutlineTotal;
|
||||
|
||||
mPixels = new eeColorA[ TexSize ];
|
||||
mPixels = eeNewArray( eeColorA, TexSize );
|
||||
memset( mPixels, 0x00000000, TexSize * 4 );
|
||||
|
||||
CurrentPos.Left = OutlineSize;
|
||||
@@ -185,7 +185,7 @@ bool cTTFFont::iLoad( const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& Ve
|
||||
mGlyphs[i] = TempGlyph;
|
||||
|
||||
//Free surface
|
||||
eeSAFE_DELETE_ARRAY( TempGlyphSurface );
|
||||
hkSAFE_DELETE_ARRAY( TempGlyphSurface );
|
||||
}
|
||||
|
||||
if ( OutlineSize ) {
|
||||
@@ -297,7 +297,7 @@ void cTTFFont::RebuildFromGlyphs() {
|
||||
}
|
||||
}
|
||||
|
||||
bool cTTFFont::SaveTexture( const std::string& Filepath, const EE_SAVETYPE& Format ) {
|
||||
bool cTTFFont::SaveTexture( const std::string& Filepath, const EE_SAVE_TYPE& Format ) {
|
||||
cTexture* Tex = cTextureFactory::instance()->GetTexture(mTexId);
|
||||
|
||||
if ( Tex != NULL )
|
||||
@@ -332,7 +332,7 @@ bool cTTFFont::SaveCoordinates( const std::string& Filepath ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cTTFFont::Save( const std::string& TexturePath, const std::string& CoordinatesDatPath, const EE_SAVETYPE& Format ) {
|
||||
bool cTTFFont::Save( const std::string& TexturePath, const std::string& CoordinatesDatPath, const EE_SAVE_TYPE& Format ) {
|
||||
return SaveTexture(TexturePath, Format) && SaveCoordinates( CoordinatesDatPath );
|
||||
}
|
||||
|
||||
|
||||
@@ -58,21 +58,21 @@ class EE_API cTTFFont : public cFont {
|
||||
bool LoadFromMemory( Uint8* TTFData, const eeUint& TTFDataSize, const eeUint& Size, EE_TTF_FONTSTYLE Style = EE_TTF_STYLE_NORMAL, const bool& VerticalDraw = false, const Uint16& NumCharsToGen = 512, const eeColor& FontColor = eeColor(), const Uint8& OutlineSize = 0, const eeColor& OutlineColor = eeColor(0,0,0) );
|
||||
|
||||
/** Save the texture generated from the TTF file to disk */
|
||||
bool SaveTexture( const std::string& Filepath, const EE_SAVETYPE& Format = EE_SAVE_TYPE_PNG );
|
||||
bool SaveTexture( const std::string& Filepath, const EE_SAVE_TYPE& Format = EE_SAVE_TYPE_PNG );
|
||||
|
||||
/** Save the characters coordinates to use it later to load the Texture Font */
|
||||
bool SaveCoordinates( const std::string& Filepath );
|
||||
|
||||
/** Save the texture generated from the TTF file and the character coordinates. */
|
||||
bool Save( const std::string& TexturePath, const std::string& CoordinatesDatPath, const EE_SAVETYPE& Format = EE_SAVE_TYPE_PNG );
|
||||
|
||||
bool Save( const std::string& TexturePath, const std::string& CoordinatesDatPath, const EE_SAVE_TYPE& Format = EE_SAVE_TYPE_PNG );
|
||||
|
||||
protected:
|
||||
friend class cTTFFontLoader;
|
||||
|
||||
|
||||
bool ThreadedLoading() const { return mThreadedLoading; }
|
||||
|
||||
|
||||
void ThreadedLoading( const bool& isThreaded ) { mThreadedLoading = isThreaded; }
|
||||
|
||||
|
||||
void UpdateLoading();
|
||||
private:
|
||||
hkFont * mFont;
|
||||
@@ -90,7 +90,7 @@ class EE_API cTTFFont : public cFont {
|
||||
bool mTTFInit;
|
||||
|
||||
bool mLoadedFromMemory;
|
||||
|
||||
|
||||
bool mThreadedLoading;
|
||||
bool mTexReady;
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ cTTFFontLoader::~cTTFFontLoader() {
|
||||
void cTTFFontLoader::Start() {
|
||||
cObjectLoader::Start();
|
||||
|
||||
mFont = new cTTFFont( mFontName );
|
||||
mFont = eeNew( cTTFFont, ( mFontName ) );
|
||||
|
||||
mFont->ThreadedLoading( mThreaded );
|
||||
|
||||
|
||||
156
src/graphics/cvertexbuffer.cpp
Normal file
156
src/graphics/cvertexbuffer.cpp
Normal file
@@ -0,0 +1,156 @@
|
||||
#include "cvertexbuffer.hpp"
|
||||
#include "cvertexbufferogl.hpp"
|
||||
#include "cvertexbuffervbo.hpp"
|
||||
|
||||
namespace EE { namespace Graphics {
|
||||
|
||||
cVertexBuffer * cVertexBuffer::Create( const Uint32& VertexFlags, EE_DRAW_TYPE DrawType, const Int32& ReserveVertexSize, const Int32& ReserveIndexSize, EE_VBO_USAGE_TYPE UsageType ) {
|
||||
if ( GLEW_ARB_vertex_buffer_object )
|
||||
return eeNew( cVertexBufferVBO, ( VertexFlags, DrawType, ReserveVertexSize, ReserveIndexSize, UsageType ) );
|
||||
|
||||
return eeNew( cVertexBufferOGL, ( VertexFlags, DrawType, ReserveVertexSize, ReserveIndexSize, UsageType ) );
|
||||
}
|
||||
|
||||
cVertexBuffer::cVertexBuffer( const Uint32& VertexFlags, EE_DRAW_TYPE DrawType, const Int32& ReserveVertexSize, const Int32& ReserveIndexSize, EE_VBO_USAGE_TYPE UsageType ) :
|
||||
mVertexFlags( VertexFlags ),
|
||||
mDrawType( DrawType ),
|
||||
mUsageType( UsageType ),
|
||||
mElemDraw(-1)
|
||||
{
|
||||
if( ReserveVertexSize > 0 ) {
|
||||
for( Int32 i = 0; i < VERTEX_FLAGS_COUNT; i++ ) {
|
||||
if( VERTEX_FLAG_QUERY( mVertexFlags, i ) ) {
|
||||
if ( i != VERTEX_FLAG_COLOR )
|
||||
mVertexArray[ i ].reserve( ReserveVertexSize * eeVertexElements[ i ] );
|
||||
else
|
||||
mColorArray.reserve( ReserveVertexSize * eeVertexElements[ i ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cVertexBuffer::~cVertexBuffer() {
|
||||
for( Int32 i = 0; i < VERTEX_FLAGS_COUNT_ARR; i++ )
|
||||
mVertexArray[ i ].clear();
|
||||
|
||||
mColorArray.clear();
|
||||
mIndexArray.clear();
|
||||
}
|
||||
|
||||
void cVertexBuffer::AddVertex( const Uint32& Type, const eeVector2f& Vertex ) {
|
||||
if ( Type < VERTEX_FLAGS_COUNT_ARR ) {
|
||||
mVertexArray[ Type ].push_back( Vertex.x );
|
||||
mVertexArray[ Type ].push_back( Vertex.y );
|
||||
}
|
||||
}
|
||||
|
||||
void cVertexBuffer::AddVertex( const eeVector2f& Vertex ) {
|
||||
AddVertex( VERTEX_FLAG_POSITION, Vertex );
|
||||
}
|
||||
|
||||
void cVertexBuffer::AddVertexCoord( const eeVector2f& VertexCoord, const Uint32& TextureLevel ) {
|
||||
AddVertex( VERTEX_FLAG_TEXTURE0 + TextureLevel, VertexCoord );
|
||||
}
|
||||
|
||||
void cVertexBuffer::AddColor( const eeColorA& Color ) {
|
||||
mColorArray.push_back( Color.R() );
|
||||
mColorArray.push_back( Color.G() );
|
||||
mColorArray.push_back( Color.B() );
|
||||
mColorArray.push_back( Color.A() );
|
||||
}
|
||||
|
||||
void cVertexBuffer::AddIndex( const Uint32& Index ) {
|
||||
mIndexArray.push_back( Index );
|
||||
|
||||
VERTEX_FLAG_SET( mVertexFlags, VERTEX_FLAG_USE_INDICES );
|
||||
}
|
||||
|
||||
void cVertexBuffer::ResizeArray( const Uint32& Type, const Uint32& Size ) {
|
||||
if ( Type != VERTEX_FLAG_COLOR )
|
||||
mVertexArray[ Type ].resize( Size );
|
||||
else
|
||||
mColorArray.resize( Size );
|
||||
}
|
||||
|
||||
void cVertexBuffer::ResizeIndices( const Uint32& Size ) {
|
||||
mIndexArray.resize( Size );
|
||||
}
|
||||
|
||||
eeFloat * cVertexBuffer::GetArray( const Uint32& Type ) {
|
||||
if ( Type && Type < VERTEX_FLAGS_COUNT_ARR && mVertexArray[ Type ].size() )
|
||||
return &mVertexArray[ Type - 1 ][0];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Uint8 * cVertexBuffer::GetColorArray() {
|
||||
if ( mColorArray.size() )
|
||||
return &mColorArray[0];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Uint32 * cVertexBuffer::GetIndices() {
|
||||
if ( mIndexArray.size() )
|
||||
return &mIndexArray[0];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Uint32 cVertexBuffer::GetVertexCount() {
|
||||
return mVertexArray[ VERTEX_FLAG_POSITION ].size() / eeVertexElements[ VERTEX_FLAG_POSITION ];
|
||||
}
|
||||
|
||||
Uint32 cVertexBuffer::GetIndexCount() {
|
||||
return mIndexArray.size();
|
||||
}
|
||||
|
||||
eeVector2f cVertexBuffer::GetVector2( const Uint32& Type, const Uint32& Index ) {
|
||||
/// assert
|
||||
if( Type < VERTEX_FLAGS_COUNT_ARR && !VERTEX_FLAG_QUERY( mVertexFlags, Type ) )
|
||||
return eeVector2f(0.f,0.f);
|
||||
|
||||
Int32 pos = Index * eeVertexElements[ Type ];
|
||||
|
||||
return eeVector2f( mVertexArray[ Type ][ pos ], mVertexArray[ Type ][ pos + 1 ] );
|
||||
}
|
||||
|
||||
eeColorA cVertexBuffer::GetColor( const Uint32& Index ) {
|
||||
/// assert
|
||||
if( !VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_COLOR ) )
|
||||
return eeColorA();
|
||||
|
||||
Int32 pos = Index * eeVertexElements[ VERTEX_FLAG_COLOR ];
|
||||
|
||||
return eeColorA( mColorArray[ pos ], mColorArray[ pos + 1 ], mColorArray[ pos + 2 ], mColorArray[ pos + 3 ] );
|
||||
}
|
||||
|
||||
Uint32 cVertexBuffer::GetIndex( const Uint32& Index ) {
|
||||
/// assert
|
||||
return mIndexArray[ Index ];
|
||||
}
|
||||
|
||||
void cVertexBuffer::SetElementNum( Int32 Num ) {
|
||||
mElemDraw = Num;
|
||||
}
|
||||
|
||||
const Int32& cVertexBuffer::GetElementNum() const {
|
||||
return mElemDraw;
|
||||
}
|
||||
|
||||
void cVertexBuffer::Unbind() {
|
||||
if( !VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_POSITION ) ) {
|
||||
glEnableClientState( GL_VERTEX_ARRAY );
|
||||
}
|
||||
|
||||
if( !VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_COLOR ) ) {
|
||||
glEnableClientState( GL_COLOR_ARRAY );
|
||||
}
|
||||
|
||||
if( !VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_TEXTURE0 ) ) {
|
||||
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
glEnable( GL_TEXTURE_2D );
|
||||
}
|
||||
}
|
||||
|
||||
}}
|
||||
72
src/graphics/cvertexbuffer.hpp
Normal file
72
src/graphics/cvertexbuffer.hpp
Normal file
@@ -0,0 +1,72 @@
|
||||
#ifndef EE_GRAPHICSCVERTEXBUFFER_HPP
|
||||
#define EE_GRAPHICSCVERTEXBUFFER_HPP
|
||||
|
||||
#include "base.hpp"
|
||||
#include "vbohelper.hpp"
|
||||
|
||||
namespace EE { namespace Graphics {
|
||||
|
||||
class cVertexBuffer {
|
||||
public:
|
||||
static cVertexBuffer * Create( const Uint32& VertexFlags = VERTEX_FLAGS_DEFAULT, EE_DRAW_TYPE DrawType = EE_DT_QUADS, const Int32& ReserveVertexSize = 0, const Int32& ReserveIndexSize = 0, EE_VBO_USAGE_TYPE UsageType = VBO_USAGE_TYPE_STATIC );
|
||||
|
||||
cVertexBuffer( const Uint32& VertexFlags = VERTEX_FLAGS_DEFAULT, EE_DRAW_TYPE DrawType = EE_DT_QUADS, const Int32& ReserveVertexSize = 0, const Int32& ReserveIndexSize = 0, EE_VBO_USAGE_TYPE UsageType = VBO_USAGE_TYPE_STATIC );
|
||||
|
||||
virtual ~cVertexBuffer();
|
||||
|
||||
void AddVertex( const Uint32& Type, const eeVector2f& Vertex );
|
||||
|
||||
void AddVertex( const eeVector2f& Vertex );
|
||||
|
||||
void AddVertexCoord( const eeVector2f& VertexCoord, const Uint32& TextureLevel = 0 );
|
||||
|
||||
void AddColor( const eeColorA& Color );
|
||||
|
||||
void AddIndex( const Uint32& Index );
|
||||
|
||||
void ResizeArray( const Uint32& Type, const Uint32& Size );
|
||||
|
||||
void ResizeIndices( const Uint32& Size );
|
||||
|
||||
eeFloat * GetArray( const Uint32& Type );
|
||||
|
||||
Uint8 * GetColorArray();
|
||||
|
||||
Uint32 * GetIndices();
|
||||
|
||||
Uint32 GetVertexCount();
|
||||
|
||||
Uint32 GetIndexCount();
|
||||
|
||||
eeVector2f GetVector2( const Uint32& Type, const Uint32& Index );
|
||||
|
||||
eeColorA GetColor( const Uint32& Index );
|
||||
|
||||
Uint32 GetIndex( const Uint32& Index );
|
||||
|
||||
void SetElementNum( Int32 Num );
|
||||
|
||||
const Int32& GetElementNum() const;
|
||||
|
||||
virtual void Bind() = 0;
|
||||
|
||||
virtual void Unbind();
|
||||
|
||||
virtual void Draw() = 0;
|
||||
|
||||
virtual bool Compile() = 0;
|
||||
protected:
|
||||
Uint32 mVertexFlags;
|
||||
EE_DRAW_TYPE mDrawType;
|
||||
EE_VBO_USAGE_TYPE mUsageType;
|
||||
Int32 mElemDraw;
|
||||
std::vector<eeFloat> mVertexArray[ VERTEX_FLAGS_COUNT - 1 ];
|
||||
std::vector<Uint8> mColorArray;
|
||||
std::vector<Uint32> mIndexArray;
|
||||
|
||||
virtual void SetVertexStates() = 0;
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
66
src/graphics/cvertexbufferogl.cpp
Normal file
66
src/graphics/cvertexbufferogl.cpp
Normal 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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}}
|
||||
27
src/graphics/cvertexbufferogl.hpp
Normal file
27
src/graphics/cvertexbufferogl.hpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef EE_GRAPHICSCVERTEXBUFFEROGL_HPP
|
||||
#define EE_GRAPHICSCVERTEXBUFFEROGL_HPP
|
||||
|
||||
#include "cvertexbuffer.hpp"
|
||||
|
||||
namespace EE { namespace Graphics {
|
||||
|
||||
class cVertexBufferOGL : public cVertexBuffer {
|
||||
public:
|
||||
cVertexBufferOGL( const Uint32& VertexFlags = VERTEX_FLAGS_DEFAULT, EE_DRAW_TYPE DrawType = EE_DT_QUADS, const Int32& ReserveVertexSize = 0, const Int32& ReserveIndexSize = 0, EE_VBO_USAGE_TYPE UsageType = VBO_USAGE_TYPE_STATIC );
|
||||
|
||||
virtual ~cVertexBufferOGL();
|
||||
|
||||
void Bind();
|
||||
|
||||
void Draw();
|
||||
|
||||
bool Compile();
|
||||
protected:
|
||||
void SetVertexStates();
|
||||
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
135
src/graphics/cvertexbuffervbo.cpp
Normal file
135
src/graphics/cvertexbuffervbo.cpp
Normal file
@@ -0,0 +1,135 @@
|
||||
#include "cvertexbuffervbo.hpp"
|
||||
|
||||
namespace EE { namespace Graphics {
|
||||
|
||||
cVertexBufferVBO::cVertexBufferVBO( const Uint32& VertexFlags, EE_DRAW_TYPE DrawType, const Int32& ReserveVertexSize, const Int32& ReserveIndexSize, EE_VBO_USAGE_TYPE UsageType ) :
|
||||
cVertexBuffer( VertexFlags, DrawType, ReserveVertexSize, ReserveIndexSize, UsageType ),
|
||||
mCompiled( false ),
|
||||
mElementHandle( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
cVertexBufferVBO::~cVertexBufferVBO() {
|
||||
for( Int32 i = 0; i < VERTEX_FLAGS_COUNT; i++ ) {
|
||||
if( VERTEX_FLAG_QUERY( mVertexFlags, i ) ) {
|
||||
glDeleteBuffers( 1,(GLuint *)&mArrayHandle[ i ] );
|
||||
}
|
||||
}
|
||||
|
||||
if( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_USE_INDICES ) ) {
|
||||
glDeleteBuffers( 1, (GLuint *)&mElementHandle );
|
||||
}
|
||||
}
|
||||
|
||||
void cVertexBufferVBO::Bind() {
|
||||
if ( !mCompiled ) {
|
||||
Compile();
|
||||
|
||||
if ( !mCompiled )
|
||||
return;
|
||||
}
|
||||
|
||||
SetVertexStates();
|
||||
}
|
||||
|
||||
bool cVertexBufferVBO::Compile() {
|
||||
if( mCompiled )
|
||||
return false;
|
||||
|
||||
GLenum usageType = GL_STATIC_DRAW_ARB;
|
||||
if( mUsageType== VBO_USAGE_TYPE_DYNAMIC ) usageType = GL_DYNAMIC_DRAW_ARB;
|
||||
else if( mUsageType== VBO_USAGE_TYPE_STREAM ) usageType = GL_STREAM_DRAW_ARB;
|
||||
|
||||
//Create the VBO vertex arrays
|
||||
for( Int32 i = 0; i < VERTEX_FLAGS_COUNT; i++ ) {
|
||||
if( VERTEX_FLAG_QUERY( mVertexFlags, i ) ) {
|
||||
glGenBuffersARB( 1,(GLuint *)&mArrayHandle[ i ] );
|
||||
|
||||
glBindBufferARB( GL_ARRAY_BUFFER_ARB, mArrayHandle[i] );
|
||||
|
||||
if ( mArrayHandle[i] ) {
|
||||
if ( i != VERTEX_FLAG_COLOR )
|
||||
glBufferDataARB( GL_ARRAY_BUFFER_ARB, mVertexArray[i].size() * sizeof(eeFloat), &( mVertexArray[i][0] ), usageType );
|
||||
else
|
||||
glBufferDataARB( GL_ARRAY_BUFFER_ARB, mColorArray.size(), &mColorArray[0], usageType );
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
//Create the VBO index array
|
||||
if( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_USE_INDICES ) ) {
|
||||
glGenBuffersARB( 1, (GLuint *)&mElementHandle );
|
||||
|
||||
glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, mElementHandle );
|
||||
|
||||
glBufferDataARB( GL_ELEMENT_ARRAY_BUFFER_ARB, GetIndexCount() * sizeof(Uint32), &mIndexArray[0], usageType );
|
||||
|
||||
glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 );
|
||||
}
|
||||
|
||||
mCompiled = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void cVertexBufferVBO::Draw() {
|
||||
if ( !mCompiled )
|
||||
return;
|
||||
|
||||
if( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_USE_INDICES ) ) {
|
||||
Int32 lSize = mElemDraw;
|
||||
|
||||
if( mElemDraw < 0 )
|
||||
lSize = GetIndexCount();
|
||||
|
||||
glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, mElementHandle );
|
||||
|
||||
glDrawElements( mDrawType, lSize, GL_UNSIGNED_INT, (char*)NULL );
|
||||
|
||||
glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 );
|
||||
} else {
|
||||
glDrawArrays( mDrawType, 0, GetVertexCount() );
|
||||
}
|
||||
}
|
||||
|
||||
void cVertexBufferVBO::SetVertexStates() {
|
||||
/// POSITION
|
||||
if( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_POSITION ) ) {
|
||||
glEnableClientState( GL_VERTEX_ARRAY );
|
||||
glBindBufferARB( GL_ARRAY_BUFFER_ARB, mArrayHandle[ VERTEX_FLAG_POSITION ] );
|
||||
glVertexPointer( eeVertexElements[ VERTEX_FLAG_POSITION ], GL_FLOAT, 0, (char*)NULL );
|
||||
} else {
|
||||
glDisableClientState( GL_VERTEX_ARRAY );
|
||||
}
|
||||
|
||||
/// COLOR
|
||||
if( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_COLOR ) ) {
|
||||
glEnableClientState( GL_COLOR_ARRAY );
|
||||
glBindBufferARB( GL_ARRAY_BUFFER_ARB, mArrayHandle[ VERTEX_FLAG_COLOR ] );
|
||||
glColorPointer( eeVertexElements[ VERTEX_FLAG_COLOR ], GL_UNSIGNED_BYTE, 0, (char*)NULL );
|
||||
} 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 );
|
||||
glBindBufferARB( GL_ARRAY_BUFFER_ARB, mArrayHandle[ VERTEX_FLAG_TEXTURE0 + i ] );
|
||||
glTexCoordPointer( eeVertexElements[ VERTEX_FLAG_TEXTURE0 + i ], GL_FLOAT, 0, (char*)NULL );
|
||||
} else {
|
||||
//glClientActiveTextureARB( GL_TEXTURE0_ARB );
|
||||
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
glDisable( GL_TEXTURE_2D );
|
||||
}
|
||||
}
|
||||
|
||||
glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 );
|
||||
}
|
||||
|
||||
}}
|
||||
31
src/graphics/cvertexbuffervbo.hpp
Normal file
31
src/graphics/cvertexbuffervbo.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef EE_GRAPHICSCVERTEXBUFFERVBO_HPP
|
||||
#define EE_GRAPHICSCVERTEXBUFFERVBO_HPP
|
||||
|
||||
#include "cvertexbuffer.hpp"
|
||||
|
||||
namespace EE { namespace Graphics {
|
||||
|
||||
class cVertexBufferVBO : public cVertexBuffer {
|
||||
public:
|
||||
cVertexBufferVBO( const Uint32& VertexFlags = VERTEX_FLAGS_DEFAULT, EE_DRAW_TYPE DrawType = EE_DT_QUADS, const Int32& ReserveVertexSize = 0, const Int32& ReserveIndexSize = 0, EE_VBO_USAGE_TYPE UsageType = VBO_USAGE_TYPE_STATIC );
|
||||
|
||||
virtual ~cVertexBufferVBO();
|
||||
|
||||
void Bind();
|
||||
|
||||
void Draw();
|
||||
|
||||
bool Compile();
|
||||
protected:
|
||||
void SetVertexStates();
|
||||
|
||||
bool mCompiled;
|
||||
|
||||
Uint32 mElementHandle;
|
||||
|
||||
Uint32 mArrayHandle[ VERTEX_FLAGS_COUNT ];
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -5,53 +5,53 @@ namespace EE { namespace Graphics {
|
||||
|
||||
/** @enum EE_FILLMODE Defines the fill mode for the primitives. */
|
||||
enum EE_FILLMODE {
|
||||
DRAW_LINE, //!< Draw only lines
|
||||
DRAW_FILL //!< Draw filled objects
|
||||
DRAW_LINE, //!< Draw only lines
|
||||
DRAW_FILL //!< Draw filled objects
|
||||
};
|
||||
|
||||
/** @enum EE_TEX_FILTER Defines the texture filter used. */
|
||||
enum EE_TEX_FILTER {
|
||||
TEX_LINEAR, //!< Linear filtering (Smoothed Zoom)
|
||||
TEX_NEAREST //!< No filtering (Pixeled Zoom)
|
||||
TEX_LINEAR, //!< Linear filtering (Smoothed Zoom)
|
||||
TEX_NEAREST //!< No filtering (Pixeled Zoom)
|
||||
};
|
||||
|
||||
/** @enum EE_RENDERALPHAS Defines the Blend Function to use */
|
||||
enum EE_RENDERALPHAS {
|
||||
ALPHA_NONE, //!< Disable the GL_BLEND
|
||||
ALPHA_NORMAL, //!< glBlendFunc(GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA);
|
||||
ALPHA_BLENDONE, //!< glBlendFunc(GL_SRC_ALPHA , GL_ONE);
|
||||
ALPHA_BLENDTWO, //!< glBlendFunc(GL_SRC_ALPHA , GL_SRC_ALPHA); \n glBlendFunc(GL_DST_ALPHA , GL_ONE);
|
||||
ALPHA_BLENDTHREE, //!< glBlendFunc(GL_SRC_ALPHA , GL_ONE); \n glBlendFunc(GL_DST_ALPHA , GL_SRC_ALPHA);
|
||||
ALPHA_ALPHACHANNELS, //!< glBlendFunc(GL_SRC_ALPHA , GL_SRC_ALPHA);
|
||||
ALPHA_DESTALPHA, //!< glBlendFunc(GL_SRC_ALPHA , GL_DST_ALPHA);
|
||||
ALPHA_MULTIPLY //!< glBlendFunc(GL_DST_COLOR,GL_ZERO);
|
||||
ALPHA_NONE, //!< Disable the GL_BLEND
|
||||
ALPHA_NORMAL, //!< glBlendFunc(GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA);
|
||||
ALPHA_BLENDONE, //!< glBlendFunc(GL_SRC_ALPHA , GL_ONE);
|
||||
ALPHA_BLENDTWO, //!< glBlendFunc(GL_SRC_ALPHA , GL_SRC_ALPHA); \n glBlendFunc(GL_DST_ALPHA , GL_ONE);
|
||||
ALPHA_BLENDTHREE, //!< glBlendFunc(GL_SRC_ALPHA , GL_ONE); \n glBlendFunc(GL_DST_ALPHA , GL_SRC_ALPHA);
|
||||
ALPHA_ALPHACHANNELS, //!< glBlendFunc(GL_SRC_ALPHA , GL_SRC_ALPHA);
|
||||
ALPHA_DESTALPHA, //!< glBlendFunc(GL_SRC_ALPHA , GL_DST_ALPHA);
|
||||
ALPHA_MULTIPLY //!< glBlendFunc(GL_DST_COLOR,GL_ZERO);
|
||||
};
|
||||
|
||||
/** @enum EE_RENDERTYPE Defines the method to use to render a texture. */
|
||||
enum EE_RENDERTYPE {
|
||||
RN_NORMAL = 0, //!< Render the texture without any change
|
||||
RN_MIRROR = 1, //!< Render the texture mirrored
|
||||
RN_FLIP = 2, //!< Render the texture fliped
|
||||
RN_FLIPMIRROR = 3, //!< Render the texture fliped and mirrored
|
||||
RN_ISOMETRIC = 4, //!< Render the texture as an isometric tile
|
||||
RN_ISOMETRICVERTICAL = 5, //!< Render the texture as an isometric vertical tile
|
||||
RN_ISOMETRICVERTICALNEGATIVE = 6 //!< Render the texture as an isometric vectical tile mirrored
|
||||
RN_NORMAL = 0, //!< Render the texture without any change
|
||||
RN_MIRROR = 1, //!< Render the texture mirrored
|
||||
RN_FLIP = 2, //!< Render the texture fliped
|
||||
RN_FLIPMIRROR = 3, //!< Render the texture fliped and mirrored
|
||||
RN_ISOMETRIC = 4, //!< Render the texture as an isometric tile
|
||||
RN_ISOMETRICVERTICAL = 5, //!< Render the texture as an isometric vertical tile
|
||||
RN_ISOMETRICVERTICALNEGATIVE = 6 //!< Render the texture as an isometric vectical tile mirrored
|
||||
};
|
||||
|
||||
/** @enum EE_SAVEFORMAT Defines the format to save a texture. */
|
||||
enum EE_SAVETYPE {
|
||||
EE_SAVE_TYPE_TGA = 0,
|
||||
EE_SAVE_TYPE_BMP = 1,
|
||||
EE_SAVE_TYPE_PNG = 2,
|
||||
EE_SAVE_TYPE_DDS = 3
|
||||
/** @enum EE_SAVE_TYPE Defines the format to save a texture. */
|
||||
enum EE_SAVE_TYPE {
|
||||
EE_SAVE_TYPE_TGA = 0,
|
||||
EE_SAVE_TYPE_BMP = 1,
|
||||
EE_SAVE_TYPE_PNG = 2,
|
||||
EE_SAVE_TYPE_DDS = 3
|
||||
};
|
||||
|
||||
/** @enum EE_TTF_FONTSTYLE Set the TTF Font style. */
|
||||
enum EE_TTF_FONTSTYLE {
|
||||
EE_TTF_STYLE_NORMAL = 0,
|
||||
EE_TTF_STYLE_BOLD = 1,
|
||||
EE_TTF_STYLE_ITALIC = 2,
|
||||
EE_TTF_STYLE_UNDERLINE = 4
|
||||
EE_TTF_STYLE_NORMAL = 0,
|
||||
EE_TTF_STYLE_BOLD = 1,
|
||||
EE_TTF_STYLE_ITALIC = 2,
|
||||
EE_TTF_STYLE_UNDERLINE = 4
|
||||
};
|
||||
|
||||
/** @enum EE_CLAMP_MODE Set the clamp mode of the texture. */
|
||||
@@ -60,18 +60,18 @@ enum EE_CLAMP_MODE {
|
||||
EE_CLAMP_REPEAT
|
||||
};
|
||||
|
||||
/** @enum EE_BATCH_RENDERER_METHOD The batch renderer, rendering methods */
|
||||
enum EE_BATCH_RENDER_METHOD {
|
||||
EE_GL_POINTS = 0x0000,
|
||||
EE_GL_LINES = 0x0001,
|
||||
EE_GL_LINE_LOOP = 0x0002,
|
||||
EE_GL_LINE_STRIP = 0x0003,
|
||||
EE_GL_TRIANGLES = 0x0004,
|
||||
EE_GL_TRIANGLE_STRIP = 0x0005,
|
||||
EE_GL_TRIANGLE_FAN = 0x0006,
|
||||
EE_GL_QUADS = 0x0007,
|
||||
EE_GL_QUAD_STRIP = 0x0008,
|
||||
EE_GL_POLYGON = 0x0009
|
||||
/** @enum EE_DRAW_TYPE The batch renderer, rendering methods */
|
||||
enum EE_DRAW_TYPE {
|
||||
EE_DT_POINTS = 0x0000,
|
||||
EE_DT_LINES = 0x0001,
|
||||
EE_DT_LINE_LOOP = 0x0002,
|
||||
EE_DT_LINE_STRIP = 0x0003,
|
||||
EE_DT_TRIANGLES = 0x0004,
|
||||
EE_DT_TRIANGLE_STRIP = 0x0005,
|
||||
EE_DT_TRIANGLE_FAN = 0x0006,
|
||||
EE_DT_QUADS = 0x0007,
|
||||
EE_DT_QUAD_STRIP = 0x0008,
|
||||
EE_DT_POLYGON = 0x0009
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
45
src/graphics/vbohelper.hpp
Normal file
45
src/graphics/vbohelper.hpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#ifndef EE_GRAPHICS_VBOHELPER_HPP
|
||||
#define EE_GRAPHICS_VBOHELPER_HPP
|
||||
|
||||
namespace EE { namespace Graphics {
|
||||
|
||||
enum EE_VBO_USAGE_TYPE
|
||||
{
|
||||
VBO_USAGE_TYPE_STATIC,
|
||||
VBO_USAGE_TYPE_DYNAMIC,
|
||||
VBO_USAGE_TYPE_STREAM,
|
||||
VBO_USAGE_TYPE_COUNT
|
||||
};
|
||||
|
||||
#define VERTEX_FLAG_POSITION ( 0 )
|
||||
#define VERTEX_FLAG_TEXTURE0 ( 1 )
|
||||
#define VERTEX_FLAG_TEXTURE1 ( 2 )
|
||||
#define VERTEX_FLAG_TEXTURE2 ( 3 )
|
||||
#define VERTEX_FLAG_TEXTURE3 ( 4 )
|
||||
#define VERTEX_FLAG_TEXTURE4 ( 5 )
|
||||
#define VERTEX_FLAG_COLOR ( 6 )
|
||||
|
||||
#define VERTEX_FLAGS_COUNT_ARR ( 6 )
|
||||
#define VERTEX_FLAGS_COUNT ( 7 )
|
||||
|
||||
#define VERTEX_FLAG_USE_INDICES ( 7 )
|
||||
|
||||
const int eeVertexElements[] = {
|
||||
2, //Position
|
||||
2, //Texture0
|
||||
2, //Texture1
|
||||
2, //Texture2
|
||||
2, //Texture3
|
||||
2, //Texture4
|
||||
4 //Color0
|
||||
};
|
||||
|
||||
#define VERTEX_FLAG_GET(X) ( 1 << (X) )
|
||||
#define VERTEX_FLAG_SET(F, X) if ( !( F & VERTEX_FLAG_GET( X ) ) ) F |= VERTEX_FLAG_GET( X );
|
||||
#define VERTEX_FLAG_QUERY(F, X) ( F & VERTEX_FLAG_GET(X) )
|
||||
|
||||
#define VERTEX_FLAGS_DEFAULT ( VERTEX_FLAG_GET( VERTEX_FLAG_POSITION ) | VERTEX_FLAG_GET( VERTEX_FLAG_TEXTURE0 ) | VERTEX_FLAG_GET( VERTEX_FLAG_COLOR ) )
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -1535,8 +1535,9 @@ void
|
||||
(
|
||||
unsigned char *img_data
|
||||
)
|
||||
{
|
||||
free( (void*)img_data );
|
||||
{
|
||||
if ( img_data )
|
||||
free( (void*)img_data );
|
||||
}
|
||||
|
||||
const char*
|
||||
|
||||
@@ -10,12 +10,16 @@ class EE_API cLog : public tSingleton<cLog> {
|
||||
friend class tSingleton<cLog>;
|
||||
public:
|
||||
void Save(const std::string& filepath = "./");
|
||||
|
||||
void Write(const std::string& Text, const bool& newLine = true);
|
||||
|
||||
void Writef( const char* format, ... );
|
||||
|
||||
std::string Buffer() const { return mData; }
|
||||
|
||||
~cLog();
|
||||
protected:
|
||||
cLog();
|
||||
~cLog();
|
||||
private:
|
||||
std::string mData, mFilePath;
|
||||
bool mSave;
|
||||
|
||||
@@ -150,7 +150,7 @@ bool cPak::ExtractFileToMemory( const std::string& path, Uint8** data, Uint32* d
|
||||
|
||||
if ( Pos != -1 ) {
|
||||
*dataSize = pakFiles[Pos].file_length;
|
||||
*data = new Uint8[ (*dataSize) ];
|
||||
*data = eeNew( Uint8, (*dataSize) );
|
||||
|
||||
myPak.fs.seekg( pakFiles[Pos].file_position, std::ios::beg );
|
||||
myPak.fs.read( reinterpret_cast<char*> ( *data ), pakFiles[Pos].file_length );
|
||||
|
||||
@@ -189,7 +189,7 @@ bool cZip::ExtractFileToMemory( const std::string& path, Uint8** data, Uint32* d
|
||||
|
||||
if ( NULL != zf ) {
|
||||
*dataSize = zf->bytes_left;
|
||||
*data = new Uint8[ (*dataSize) ];
|
||||
*data = eeNew( Uint8, (*dataSize) );
|
||||
|
||||
Result = zip_fread( zf, reinterpret_cast<void*> (&data[0]), zf->bytes_left );
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#ifndef EE_SYSTEMSINGLETON_H
|
||||
#define EE_SYSTEMSINGLETON_H
|
||||
|
||||
#include "../base.hpp"
|
||||
|
||||
namespace EE { namespace System {
|
||||
|
||||
@@ -12,7 +14,7 @@ class tSingleton {
|
||||
/** Get the singleton pointer */
|
||||
static T* CreateSingleton() {
|
||||
if (ms_singleton == 0)
|
||||
ms_singleton = new T;
|
||||
ms_singleton = eeNew( T, () );
|
||||
|
||||
return ms_singleton;
|
||||
}
|
||||
@@ -30,7 +32,7 @@ class tSingleton {
|
||||
/** Destroy the singleton instance */
|
||||
static void DestroySingleton() {
|
||||
if( ms_singleton != 0 ) {
|
||||
delete ms_singleton;
|
||||
eeDelete( ms_singleton );
|
||||
ms_singleton = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "../ee.h"
|
||||
|
||||
/**
|
||||
@TODO Create a Vertex Buffer Object class ( with and without GL_ARB_vertex_buffer_object ).
|
||||
@TODO Add a memory manager ( and a STL Allocator implemented in all the engine ).
|
||||
@TODO Support multitexturing.
|
||||
@TODO Create a basic UI system ( add basic controls, add skinning support ).
|
||||
@TODO Add some Surface Grid class, to create special effects ( waved texture, and stuff like that ).
|
||||
@@ -72,7 +72,7 @@ class cEETest : private cThread {
|
||||
void LoadTextures();
|
||||
void CmdSetPartsNum ( const std::vector < std::wstring >& params );
|
||||
|
||||
std::vector<cParticleSystem> PS;
|
||||
std::vector<cParticleSystem, eeAllocator< cParticleSystem > > PS;
|
||||
|
||||
cTimeElapsed cElapsed;
|
||||
eeFloat PSElapsed;
|
||||
@@ -192,6 +192,7 @@ class cEETest : private cThread {
|
||||
cSprite mBlindy;
|
||||
|
||||
cFrameBuffer * mFB;
|
||||
cVertexBuffer * mVBO;
|
||||
};
|
||||
|
||||
|
||||
@@ -289,6 +290,18 @@ void cEETest::Init() {
|
||||
if ( NULL != mFB )
|
||||
mFB->ClearColor( eeColorAf( 0, 0, 0, 0.5f ) );
|
||||
|
||||
|
||||
eePolygon2f Poly = CreateRoundedPolygon( 0.f, 0.f, 250.f, 50.f );
|
||||
|
||||
mVBO = cVertexBuffer::Create( VERTEX_FLAG_GET( VERTEX_FLAG_POSITION ) | VERTEX_FLAG_GET( VERTEX_FLAG_COLOR ), EE_DT_POLYGON );
|
||||
|
||||
for ( Uint32 i = 0; i < Poly.Size(); i++ ) {
|
||||
mVBO->AddVertex( Poly[i] );
|
||||
mVBO->AddColor( eeColorA( 100 + i, 255 - i, 150 + i, 200 ) );
|
||||
}
|
||||
|
||||
mVBO->Compile();
|
||||
|
||||
Launch();
|
||||
} else {
|
||||
std::cout << "Failed to start EE++" << std::endl;
|
||||
@@ -298,9 +311,9 @@ void cEETest::Init() {
|
||||
}
|
||||
|
||||
void cEETest::LoadFonts() {
|
||||
mFontLoader.Add( new cTextureFontLoader( "conchars", new cTextureLoader( &PAK, "conchars.png", false, eeRGB(0,0,0) ), (eeUint)32 ) );
|
||||
mFontLoader.Add( new cTextureFontLoader( "ProggySquareSZ", new cTextureLoader( &PAK, "ProggySquareSZ.png" ), &PAK, "ProggySquareSZ.dat" ) );
|
||||
mFontLoader.Add( new cTTFFontLoader( "arial", &PAK, "arial.ttf", 12, EE_TTF_STYLE_NORMAL, false, 512, eeColor(255,255,255), 1, eeColor(0,0,0) ) );
|
||||
mFontLoader.Add( eeNew( cTextureFontLoader, ( "conchars", eeNew( cTextureLoader, ( &PAK, "conchars.png", false, eeRGB(0,0,0) ) ), (eeUint)32 ) ) );
|
||||
mFontLoader.Add( eeNew( cTextureFontLoader, ( "ProggySquareSZ", eeNew( cTextureLoader, ( &PAK, "ProggySquareSZ.png" ) ), &PAK, "ProggySquareSZ.dat" ) ) );
|
||||
mFontLoader.Add( eeNew( cTTFFontLoader, ( "arial", &PAK, "arial.ttf", 12, EE_TTF_STYLE_NORMAL, false, 512, eeColor(255,255,255), 1, eeColor(0,0,0) ) ) );
|
||||
mFontLoader.Load( boost::bind( &cEETest::OnFontLoaded, this, _1 ) );
|
||||
}
|
||||
|
||||
@@ -326,7 +339,7 @@ void cEETest::CreateShaders() {
|
||||
|
||||
if ( mUseShaders ) {
|
||||
mBlurFactor = 0.01f;
|
||||
mShaderProgram = new cShaderProgram( &PAK, "shader/blur.vert", "shader/blur.frag" );
|
||||
mShaderProgram = eeNew( cShaderProgram, ( &PAK, "shader/blur.vert", "shader/blur.frag" ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,7 +352,7 @@ void cEETest::CreateUI() {
|
||||
Params.Border.Color( 0xFF979797 );
|
||||
//Params.Background.Corners(5);
|
||||
Params.Background.Colors( eeColorA( 0x66FAFAFA ), eeColorA( 0xCCFAFAFA ), eeColorA( 0xCCFAFAFA ), eeColorA( 0x66FAFAFA ) );
|
||||
cUIControlAnim * C = new cUITest( Params );
|
||||
cUIControlAnim * C = eeNew( cUITest, ( Params ) );
|
||||
C->Visible( true );
|
||||
C->Enabled( true );
|
||||
C->Pos( 320, 240 );
|
||||
@@ -351,7 +364,7 @@ void cEETest::CreateUI() {
|
||||
Params.Background.Colors( eeColorA( 0x7700FF00 ), eeColorA( 0x7700CC00 ), eeColorA( 0x7700CC00 ), eeColorA( 0x7700FF00 ) );
|
||||
Params.Parent( C );
|
||||
Params.Size = eeSize( 50, 50 );
|
||||
cUITest * Child = new cUITest( Params );
|
||||
cUITest * Child = eeNew( cUITest, ( Params ) );
|
||||
Child->Pos( 25, 50 );
|
||||
Child->Visible( true );
|
||||
Child->Enabled( true );
|
||||
@@ -360,7 +373,7 @@ void cEETest::CreateUI() {
|
||||
Params.Background.Colors( eeColorA( 0x77FFFF00 ), eeColorA( 0x77CCCC00 ), eeColorA( 0x77CCCC00 ), eeColorA( 0x77FFFF00 ) );
|
||||
Params.Parent( Child );
|
||||
Params.Size = eeSize( 25, 25 );
|
||||
cUITest * Child2 = new cUITest( Params );
|
||||
cUITest * Child2 = eeNew( cUITest, ( Params ) );
|
||||
Child2->Pos( 15, 15 );
|
||||
Child2->Visible( true );
|
||||
Child2->Enabled( true );
|
||||
@@ -372,7 +385,7 @@ void cEETest::CreateUI() {
|
||||
GfxParams.Flags |= UI_CLIP_ENABLE;
|
||||
GfxParams.Size = eeSize( 64, 64 );
|
||||
GfxParams.Shape = cGlobalShapeGroup::instance()->Add( TN[2] );
|
||||
cUIGfx * Gfx = new cUIGfx( GfxParams );
|
||||
cUIGfx * Gfx = eeNew( cUIGfx, ( GfxParams ) );
|
||||
Gfx->Angle( 45.f );
|
||||
Gfx->Visible( true );
|
||||
Gfx->Enabled( true );
|
||||
@@ -386,7 +399,7 @@ void cEETest::CreateUI() {
|
||||
TextParams.Size = eeSize( 320, 240 );
|
||||
TextParams.Flags = UI_VALIGN_TOP | UI_HALIGN_RIGHT;
|
||||
TextParams.Font = TTF;
|
||||
cUITextBox * Text = new cUITextBox( TextParams );
|
||||
cUITextBox * Text = eeNew( cUITextBox, ( TextParams ) );
|
||||
Text->Visible( true );
|
||||
Text->Enabled( false );
|
||||
Text->Text( L"Turn around\nJust Turn Around\nAround!" );
|
||||
@@ -401,7 +414,7 @@ void cEETest::CreateUI() {
|
||||
InputParams.Flags = UI_VALIGN_CENTER | UI_HALIGN_LEFT | UI_FILL_BACKGROUND | UI_CLIP_ENABLE | UI_BORDER;
|
||||
InputParams.Font = TTF;
|
||||
InputParams.SupportNewLine = false;
|
||||
cUITextInput * Input = new cUITextInput( InputParams );
|
||||
cUITextInput * Input = eeNew( cUITextInput, ( InputParams ) );
|
||||
Input->Visible( true );
|
||||
Input->Enabled( true );
|
||||
|
||||
@@ -443,11 +456,11 @@ void cEETest::LoadTextures() {
|
||||
std::string name( files[i] );
|
||||
|
||||
if ( "jpg" == FileExtension( name ) ) {
|
||||
mResLoad.Add( new cTextureLoader( &PakTest, name ) );
|
||||
mResLoad.Add( eeNew( cTextureLoader, ( &PakTest, name ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
mResLoad.Add( new cSoundLoader( &SndMng, "mysound", &PAK, "sound.ogg" ) );
|
||||
mResLoad.Add( eeNew( cSoundLoader, ( &SndMng, "mysound", &PAK, "sound.ogg" ) ) );
|
||||
|
||||
mResLoad.Load( boost::bind( &cEETest::OnTextureLoaded, this, _1 ) );
|
||||
|
||||
@@ -541,7 +554,7 @@ void cEETest::LoadTextures() {
|
||||
CL2.AddFrame(TN[0], 96, 96);
|
||||
CL2.Color( eeRGBA( 255, 255, 255, 255 ) );
|
||||
|
||||
mTGL = new cTextureGroupLoader( MyPath + "data/bnb/bnb.etg" );
|
||||
mTGL = eeNew( cTextureGroupLoader, ( MyPath + "data/bnb/bnb.etg" ) );
|
||||
|
||||
mBlindy.AddFramesByPattern( "rn" );
|
||||
mBlindy.UpdatePos( 320.f, 0.f );
|
||||
@@ -878,6 +891,10 @@ void cEETest::Render() {
|
||||
mBlindy.UpdatePos( 128-16, 128-16 );
|
||||
mBlindy.Draw();
|
||||
|
||||
mVBO->Bind();
|
||||
mVBO->Draw();
|
||||
mVBO->Unbind();
|
||||
|
||||
mFB->Unbind();
|
||||
|
||||
if ( NULL != mFB->GetTexture() )
|
||||
@@ -1139,6 +1156,7 @@ void cEETest::End() {
|
||||
|
||||
eeSAFE_DELETE( mTGL );
|
||||
eeSAFE_DELETE( mFB );
|
||||
eeSAFE_DELETE( mVBO );
|
||||
|
||||
cEngine::DestroySingleton();
|
||||
}
|
||||
@@ -1170,9 +1188,9 @@ int main (int argc, char * argv []) {
|
||||
/* std::string Path( "/home/downloads/files/temp/bnb/allin/" );
|
||||
*/
|
||||
/*
|
||||
cTextureGroupLoader * tgl = new cTextureGroupLoader();
|
||||
cTextureGroupLoader * tgl = eeNew( cTextureGroupLoader, () );
|
||||
tgl->UpdateTextureAtlas( AppPath() + "data/bnb/bnb.etg", Path );
|
||||
delete tgl;
|
||||
eeDelete( tgl );
|
||||
*/
|
||||
/*
|
||||
cTexturePacker tp( 512, 512 );
|
||||
@@ -1186,8 +1204,13 @@ int main (int argc, char * argv []) {
|
||||
|
||||
tp.Save( AppPath() + "data/bnb/bnb.png", EE_SAVE_TYPE_PNG );
|
||||
*/
|
||||
cEETest Test;
|
||||
Test.Process();
|
||||
cEETest * Test = eeNew( cEETest, () );
|
||||
|
||||
Test->Process();
|
||||
|
||||
eeDelete( Test );
|
||||
|
||||
EE::MemoryManager::LogResults();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ cUIControl::cUIControl( const CreateParams& Params ) :
|
||||
|
||||
cUIControl::~cUIControl() {
|
||||
while( NULL != mChild )
|
||||
delete mChild;
|
||||
eeDelete( mChild );
|
||||
|
||||
if ( NULL != mParentCtrl )
|
||||
mParentCtrl->ChildRemove( this );
|
||||
@@ -431,7 +431,7 @@ void cUIControl::CheckClose() {
|
||||
|
||||
while( NULL != ChildLoop ) {
|
||||
if ( ChildLoop->ControlFlags() & UI_CTRL_FLAG_CLOSE ) {
|
||||
delete ChildLoop;
|
||||
eeDelete( ChildLoop );
|
||||
|
||||
ChildLoop = mChild;
|
||||
|
||||
@@ -515,7 +515,7 @@ void cUIControl::MatrixUnset() {
|
||||
|
||||
void cUIControl::ChildDeleteAll() {
|
||||
while( NULL != mChild )
|
||||
delete mChild;
|
||||
eeDelete( mChild );
|
||||
}
|
||||
|
||||
void cUIControl::ChildAdd( cUIControl * ChildCtrl ) {
|
||||
|
||||
@@ -193,6 +193,8 @@ class EE_API cUIControl {
|
||||
cUIBackground * Background();
|
||||
|
||||
cUIBorder * Border();
|
||||
|
||||
virtual ~cUIControl();
|
||||
protected:
|
||||
friend class cUIManager;
|
||||
friend class cUIDragable;
|
||||
@@ -223,8 +225,6 @@ class EE_API cUIControl {
|
||||
std::map< Uint32, std::map<Uint32, UIEventCallback> > mEvents;
|
||||
Uint32 mNumCallBacks;
|
||||
|
||||
virtual ~cUIControl();
|
||||
|
||||
virtual void OnVisibleChange();
|
||||
|
||||
virtual void OnEnabledChange();
|
||||
|
||||
@@ -140,7 +140,7 @@ bool cUIControlAnim::Animating() {
|
||||
|
||||
void cUIControlAnim::StartAlphaAnim( const eeFloat& From, const eeFloat& To, const eeFloat& TotalTime, cInterpolation::OnPathEndCallback PathEndCallback ) {
|
||||
if ( NULL == mAlphaAnim )
|
||||
mAlphaAnim = new cInterpolation();
|
||||
mAlphaAnim = eeNew( cInterpolation, () );
|
||||
|
||||
mAlphaAnim->ClearWaypoints();
|
||||
mAlphaAnim->AddWaypoint( From );
|
||||
@@ -153,7 +153,7 @@ void cUIControlAnim::StartAlphaAnim( const eeFloat& From, const eeFloat& To, con
|
||||
|
||||
void cUIControlAnim::StartScaleAnim( const eeFloat& From, const eeFloat& To, const eeFloat& TotalTime, cInterpolation::OnPathEndCallback PathEndCallback ) {
|
||||
if ( NULL == mScaleAnim )
|
||||
mScaleAnim = new cInterpolation();
|
||||
mScaleAnim = eeNew( cInterpolation, () );
|
||||
|
||||
mScaleAnim->ClearWaypoints();
|
||||
mScaleAnim->AddWaypoint( From );
|
||||
@@ -166,7 +166,7 @@ void cUIControlAnim::StartScaleAnim( const eeFloat& From, const eeFloat& To, con
|
||||
|
||||
void cUIControlAnim::StartMovement( const eeVector2i& From, const eeVector2i& To, const eeFloat& TotalTime, cWaypoints::OnPathEndCallback PathEndCallback ) {
|
||||
if ( NULL == mMoveAnim )
|
||||
mMoveAnim = new cWaypoints();
|
||||
mMoveAnim = eeNew( cWaypoints, () );
|
||||
|
||||
mMoveAnim->ClearWaypoints();
|
||||
mMoveAnim->AddWaypoint( eeVector2f( (eeFloat)From.x, (eeFloat)From.y ) );
|
||||
@@ -179,7 +179,7 @@ void cUIControlAnim::StartMovement( const eeVector2i& From, const eeVector2i& To
|
||||
|
||||
void cUIControlAnim::StartRotation( const eeFloat& From, const eeFloat& To, const eeFloat& TotalTime, cInterpolation::OnPathEndCallback PathEndCallback ) {
|
||||
if ( NULL == mAngleAnim )
|
||||
mAngleAnim = new cInterpolation();
|
||||
mAngleAnim = eeNew( cInterpolation, () );
|
||||
|
||||
mAngleAnim->ClearWaypoints();
|
||||
mAngleAnim->AddWaypoint( From );
|
||||
@@ -264,28 +264,28 @@ void cUIControlAnim::UpdateQuad() {
|
||||
|
||||
cInterpolation * cUIControlAnim::AngleInterpolation() {
|
||||
if ( NULL == mAngleAnim )
|
||||
mAngleAnim = new cInterpolation();
|
||||
mAngleAnim = eeNew( cInterpolation, () );
|
||||
|
||||
return mAngleAnim;
|
||||
}
|
||||
|
||||
cInterpolation * cUIControlAnim::ScaleInterpolation() {
|
||||
if ( NULL == mScaleAnim )
|
||||
mScaleAnim = new cInterpolation();
|
||||
mScaleAnim = eeNew( cInterpolation, () );
|
||||
|
||||
return mScaleAnim;
|
||||
}
|
||||
|
||||
cInterpolation * cUIControlAnim::AlphaInterpolation() {
|
||||
if ( NULL == mAlphaAnim )
|
||||
mAlphaAnim = new cInterpolation();
|
||||
mAlphaAnim = eeNew( cInterpolation, () );
|
||||
|
||||
return mAlphaAnim;
|
||||
}
|
||||
|
||||
cWaypoints * cUIControlAnim::MovementInterpolation() {
|
||||
if ( NULL == mMoveAnim )
|
||||
mMoveAnim = new cWaypoints();
|
||||
mMoveAnim = eeNew( cWaypoints, () );
|
||||
|
||||
return mMoveAnim;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ void cUIManager::Init() {
|
||||
Shutdown();
|
||||
|
||||
mInit = true;
|
||||
mControl = new cUIControlAnim( cUIControl::CreateParams( NULL, eeVector2i( 0, 0 ), eeSize( cEngine::instance()->GetWidth(), cEngine::instance()->GetHeight() ) ) );
|
||||
mControl = eeNew( cUIControlAnim, ( cUIControl::CreateParams( NULL, eeVector2i( 0, 0 ), eeSize( cEngine::instance()->GetWidth(), cEngine::instance()->GetHeight() ) ) ) );
|
||||
mControl->Visible( true );
|
||||
mControl->Enabled( true );
|
||||
|
||||
|
||||
@@ -421,13 +421,38 @@ std::string SaveTypeToExtension( const Uint32& Format ) {
|
||||
}
|
||||
|
||||
void DirPathAddSlashAtEnd( std::string& path ) {
|
||||
if ( path[ path.size() - 1 ] != '/' && path[ path.size() - 1 ] != '\\' ) {
|
||||
if ( path[ path.size() - 1 ] != '/' && path[ path.size() - 1 ] != '\\' )
|
||||
path += GetOSlash();
|
||||
}
|
||||
|
||||
std::string GetOSlash() {
|
||||
#if EE_PLATFORM == EE_PLATFORM_WIN32
|
||||
path += '\\';
|
||||
return std::string( "\\" );
|
||||
#else
|
||||
path += '/';
|
||||
return std::string( "/" );
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string SizeToString( const Uint32& MemSize ) {
|
||||
std::string size = " bytes";
|
||||
eeDouble mem = static_cast<eeDouble>( MemSize );
|
||||
Uint8 c = 0;
|
||||
|
||||
while ( mem > 1024 ) {
|
||||
c++;
|
||||
mem = mem / 1024;
|
||||
}
|
||||
|
||||
switch (c) {
|
||||
case 0: size = " bytes"; break;
|
||||
case 1: size = " KB"; break;
|
||||
case 2: size = " MB"; break;
|
||||
case 3: size = " GB"; break;
|
||||
case 4: size = " TB"; break;
|
||||
default: size = " WTF";
|
||||
}
|
||||
|
||||
return std::string( toStr( mem ) + size );
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -88,7 +88,15 @@ namespace EE { namespace Utils {
|
||||
std::string EE_API SaveTypeToExtension( const Uint32& Format );
|
||||
|
||||
/** If the directory path not end with a slash, it will add it. */
|
||||
void DirPathAddSlashAtEnd( std::string& path );
|
||||
void EE_API DirPathAddSlashAtEnd( std::string& path );
|
||||
|
||||
/** @return The default slash path code of the current OS */
|
||||
std::string EE_API GetOSlash();
|
||||
|
||||
/** Convert a size represented in bytes, to a string converted in byes/kb/mb/tb.
|
||||
* @example 10485760 -> "10.0 MB"
|
||||
*/
|
||||
std::string SizeToString( const Uint32& MemSize );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "../graphics/cshaderprogrammanager.hpp"
|
||||
#include "../graphics/cshapegroupmanager.hpp"
|
||||
#include "../ui/cuimanager.hpp"
|
||||
#include "../audio/caudiolistener.hpp"
|
||||
|
||||
using namespace EE::Graphics;
|
||||
|
||||
@@ -102,6 +103,8 @@ cEngine::~cEngine() {
|
||||
|
||||
cInput::DestroySingleton();
|
||||
|
||||
Audio::cAudioListener::DestroySingleton();
|
||||
|
||||
cLog::DestroySingleton();
|
||||
|
||||
SDL_Quit();
|
||||
@@ -446,7 +449,7 @@ void cEngine::SetFrameRateLimit(const Uint32& FrameRateLimit) {
|
||||
mFrames.FPS.Limit = (eeFloat)FrameRateLimit;
|
||||
}
|
||||
|
||||
bool cEngine::TakeScreenshot( std::string filepath, const EE_SAVETYPE& Format ) {
|
||||
bool cEngine::TakeScreenshot( std::string filepath, const EE_SAVE_TYPE& Format ) {
|
||||
bool CreateNewFile = false;
|
||||
std::string File, Ext;
|
||||
|
||||
@@ -469,12 +472,7 @@ bool cEngine::TakeScreenshot( std::string filepath, const EE_SAVETYPE& Format )
|
||||
if ( !IsDirectory( filepath ) )
|
||||
MakeDir( filepath );
|
||||
|
||||
switch ( Format ) {
|
||||
case EE_SAVE_TYPE_TGA: Ext = ".tga"; break;
|
||||
case EE_SAVE_TYPE_BMP: Ext = ".bmp"; break;
|
||||
case EE_SAVE_TYPE_PNG: Ext = ".png"; break;
|
||||
case EE_SAVE_TYPE_DDS: Ext = ".dds"; break;
|
||||
}
|
||||
Ext = "." + SaveTypeToExtension( Format );
|
||||
|
||||
while ( !find && FileNum < 10000 ) {
|
||||
TmpPath = StrFormated( "%s%05d%s", filepath.c_str(), FileNum, Ext.c_str() );
|
||||
|
||||
@@ -100,7 +100,7 @@ class EE_API cEngine : public tSingleton<cEngine> {
|
||||
* You can set only the path to save the files, like "screenshots/"
|
||||
* @return False if failed, otherwise returns True
|
||||
*/
|
||||
bool TakeScreenshot( std::string filepath = "", const EE_SAVETYPE& Format = EE_SAVE_TYPE_PNG );
|
||||
bool TakeScreenshot( std::string filepath = "", const EE_SAVE_TYPE& Format = EE_SAVE_TYPE_PNG );
|
||||
|
||||
/** @return The resolutions that support the video card */
|
||||
std::vector< std::pair<unsigned int, unsigned int> > GetPossibleResolutions() const;
|
||||
@@ -245,9 +245,10 @@ class EE_API cEngine : public tSingleton<cEngine> {
|
||||
#endif
|
||||
|
||||
void SetDefaultContext();
|
||||
|
||||
~cEngine();
|
||||
protected:
|
||||
cEngine();
|
||||
~cEngine();
|
||||
private:
|
||||
bool mInit;
|
||||
VideoInfo mVideoInfo;
|
||||
|
||||
@@ -424,9 +424,10 @@ class EE_API cInput : public tSingleton<cInput> {
|
||||
|
||||
/** Set the double click interval in milliseconds */
|
||||
void DoubleClickInterval( const Uint32& Interval );
|
||||
|
||||
~cInput();
|
||||
protected:
|
||||
cInput();
|
||||
~cInput();
|
||||
|
||||
cEngine* EE;
|
||||
EE_Event mEvent;
|
||||
|
||||
@@ -50,7 +50,7 @@ void cJoystickManager::Create( const Uint32& index ) {
|
||||
if ( NULL != mJoysticks[ index ] )
|
||||
mJoysticks[ index ]->ReOpen();
|
||||
else
|
||||
mJoysticks[ index ] = new cJoystick( index );
|
||||
mJoysticks[ index ] = eeNew( cJoystick, ( index ) );
|
||||
}
|
||||
|
||||
void cJoystickManager::Close() {
|
||||
|
||||
Reference in New Issue
Block a user