mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 02:25:37 -05:00
Enable tinystl by default.
This commit is contained in:
parent
7c81905ed2
commit
ab969f0a1a
8 changed files with 34 additions and 50 deletions
2
LICENSE
2
LICENSE
|
@ -20,3 +20,5 @@ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY
|
|||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
https://github.com/bkaradzic/bgfx
|
||||
|
|
|
@ -337,10 +337,13 @@ public:
|
|||
|
||||
virtual void free(void* _ptr, const char* _file, uint32_t _line) BX_OVERRIDE
|
||||
{
|
||||
dbgPrintf("%s(%d): FREE %p\n", _file, _line, _ptr);
|
||||
BX_UNUSED(_file, _line);
|
||||
::free(_ptr);
|
||||
--m_numBlocks;
|
||||
if (NULL != _ptr)
|
||||
{
|
||||
dbgPrintf("%s(%d): FREE %p\n", _file, _line, _ptr);
|
||||
BX_UNUSED(_file, _line);
|
||||
::free(_ptr);
|
||||
--m_numBlocks;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void* realloc(void* _ptr, size_t _size, const char* _file, uint32_t _line) BX_OVERRIDE
|
||||
|
|
|
@ -13,21 +13,8 @@
|
|||
#include "font_manager.h"
|
||||
#include "../cube_atlas.h"
|
||||
|
||||
#if BGFX_CONFIG_USE_TINYSTL
|
||||
namespace tinystl
|
||||
{
|
||||
} // namespace tinystl
|
||||
# include <TINYSTL/unordered_map.hh>
|
||||
#include <tinystl/unordered_map.h>
|
||||
namespace stl = tinystl;
|
||||
#else
|
||||
# include <unordered_map>
|
||||
namespace std { namespace tr1 {} }
|
||||
namespace stl
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::tr1;
|
||||
}
|
||||
#endif // BGFX_CONFIG_USE_TINYSTL
|
||||
|
||||
struct FTHolder
|
||||
{
|
||||
|
|
1
makefile
1
makefile
|
@ -17,7 +17,6 @@ all:
|
|||
premake4 --file=premake/premake4.lua --gcc=ios-simulator gmake
|
||||
premake4 --file=premake/premake4.lua --gcc=qnx-arm gmake
|
||||
premake4 --file=premake/premake4.lua xcode4
|
||||
make -s --no-print-directory -C src
|
||||
|
||||
android-arm-debug:
|
||||
make -R -C .build/projects/gmake-android-arm config=debug
|
||||
|
|
|
@ -8,7 +8,6 @@ project "bgfx"
|
|||
kind "StaticLib"
|
||||
|
||||
includedirs {
|
||||
BGFX_DIR .. "../tinystl/include",
|
||||
BGFX_DIR .. "../bx/include",
|
||||
}
|
||||
|
||||
|
|
37
src/bgfx.cpp
37
src/bgfx.cpp
|
@ -5,22 +5,6 @@
|
|||
|
||||
#include "bgfx_p.h"
|
||||
|
||||
#if BGFX_CONFIG_USE_TINYSTL
|
||||
namespace tinystl
|
||||
{
|
||||
void* bgfx_allocator::static_allocate(size_t _bytes)
|
||||
{
|
||||
return BX_ALLOC(g_allocator, _bytes);
|
||||
}
|
||||
|
||||
void bgfx_allocator::static_deallocate(void* _ptr, size_t /*_bytes*/)
|
||||
{
|
||||
BX_FREE(g_allocator, _ptr);
|
||||
}
|
||||
|
||||
} // namespace tinystl
|
||||
#endif // BGFX_CONFIG_USE_TINYSTL
|
||||
|
||||
namespace bgfx
|
||||
{
|
||||
#define BGFX_MAIN_THREAD_MAGIC 0x78666762
|
||||
|
@ -62,6 +46,16 @@ namespace bgfx
|
|||
}
|
||||
#endif // BX_PLATFORM_*
|
||||
|
||||
void* TinyStlAllocator::static_allocate(size_t _bytes)
|
||||
{
|
||||
return BX_ALLOC(bgfx::g_allocator, _bytes);
|
||||
}
|
||||
|
||||
void TinyStlAllocator::static_deallocate(void* _ptr, size_t /*_bytes*/)
|
||||
{
|
||||
BX_FREE(bgfx::g_allocator, _ptr);
|
||||
}
|
||||
|
||||
struct CallbackStub : public CallbackI
|
||||
{
|
||||
virtual ~CallbackStub()
|
||||
|
@ -134,12 +128,13 @@ namespace bgfx
|
|||
|
||||
virtual void free(void* _ptr, const char* _file, uint32_t _line) BX_OVERRIDE
|
||||
{
|
||||
BX_CHECK(_ptr != NULL, "Freeing NULL! Fix it!");
|
||||
if (NULL != _ptr)
|
||||
{
|
||||
--m_numBlocks;
|
||||
|
||||
--m_numBlocks;
|
||||
|
||||
BX_UNUSED(_file, _line);
|
||||
::free(_ptr);
|
||||
BX_UNUSED(_file, _line);
|
||||
::free(_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void* realloc(void* _ptr, size_t _size, const char* _file, uint32_t _line) BX_OVERRIDE
|
||||
|
|
15
src/bgfx_p.h
15
src/bgfx_p.h
|
@ -82,19 +82,18 @@ namespace bgfx
|
|||
#include <list> // mingw wants it to be before tr1/unordered_*...
|
||||
|
||||
#if BGFX_CONFIG_USE_TINYSTL
|
||||
namespace tinystl
|
||||
namespace bgfx
|
||||
{
|
||||
struct bgfx_allocator
|
||||
struct TinyStlAllocator
|
||||
{
|
||||
static void* static_allocate(size_t _bytes);
|
||||
static void static_deallocate(void* _ptr, size_t /*_bytes*/);
|
||||
};
|
||||
} // namespace tinystl
|
||||
# define TINYSTL_ALLOCATOR tinystl::bgfx_allocator
|
||||
|
||||
# include <TINYSTL/string.h>
|
||||
# include <TINYSTL/unordered_map.h>
|
||||
# include <TINYSTL/unordered_set.h>
|
||||
} // namespace bgfx
|
||||
# define TINYSTL_ALLOCATOR bgfx::TinyStlAllocator
|
||||
# include <tinystl/string.h>
|
||||
# include <tinystl/unordered_map.h>
|
||||
# include <tinystl/unordered_set.h>
|
||||
namespace stl = tinystl;
|
||||
#else
|
||||
# include <string>
|
||||
|
|
|
@ -212,7 +212,7 @@
|
|||
#endif // BGFX_CONFIG_MAX_CONSTANT_BUFFER_SIZE
|
||||
|
||||
#ifndef BGFX_CONFIG_USE_TINYSTL
|
||||
# define BGFX_CONFIG_USE_TINYSTL 0
|
||||
# define BGFX_CONFIG_USE_TINYSTL 1
|
||||
#endif // BGFX_CONFIG_USE_TINYSTL
|
||||
|
||||
#ifndef BGFX_CONFIG_MAX_INSTANCE_DATA_COUNT
|
||||
|
|
Loading…
Reference in a new issue