瀏覽代碼

Merge pull request #142 from mmicko/master

Addition for compiling on non C++11 compilers
Branimir Karadžić 11 年之前
父節點
當前提交
c889ebc231

+ 4 - 2
examples/14-shadowvolumes/shadowvolumes.cpp

@@ -8,8 +8,10 @@
 
 
 #include <string>
 #include <string>
 #include <vector>
 #include <vector>
-#include <unordered_map>
 #include <map>
 #include <map>
+#include <tinystl/allocator.h>
+#include <tinystl/unordered_map.h>
+namespace stl = tinystl;
 
 
 namespace std { namespace tr1 {} }
 namespace std { namespace tr1 {} }
 using namespace std::tr1;
 using namespace std::tr1;
@@ -695,7 +697,7 @@ struct HalfEdges
 	{
 	{
 		m_data = (HalfEdge*)malloc(2 * _numIndices * sizeof(HalfEdge) );
 		m_data = (HalfEdge*)malloc(2 * _numIndices * sizeof(HalfEdge) );
 
 
-		std::unordered_map<uint16_t, std::vector<uint16_t> > edges;
+		stl::unordered_map<uint16_t, std::vector<uint16_t> > edges;
 		for (uint32_t ii = 0; ii < _numIndices; ii+=3)
 		for (uint32_t ii = 0; ii < _numIndices; ii+=3)
 		{
 		{
 			uint16_t idx0 = _indices[ii];
 			uint16_t idx0 = _indices[ii];

+ 1 - 1
examples/20-nanovg/nanovg.cpp

@@ -984,7 +984,7 @@ void freeDemoData(struct NVGcontext* vg, struct DemoData* data)
 		nvgDeleteImage(vg, data->images[i]);
 		nvgDeleteImage(vg, data->images[i]);
 }
 }
 
 
-#if _MSC_VER < 1800
+#if defined(_MSC_VER) && (_MSC_VER < 1800)
 inline float round(float _f)
 inline float round(float _f)
 {
 {
 	return float(int(_f) );
 	return float(int(_f) );

+ 5 - 3
examples/common/entry/cmd.cpp

@@ -13,7 +13,9 @@
 #include "dbg.h"
 #include "dbg.h"
 #include "cmd.h"
 #include "cmd.h"
 #include <string>
 #include <string>
-#include <unordered_map>
+#include <tinystl/allocator.h>
+#include <tinystl/unordered_map.h>
+namespace stl = tinystl;
 
 
 struct CmdContext
 struct CmdContext
 {
 {
@@ -30,7 +32,7 @@ struct CmdContext
 		uint32_t cmd = bx::hashMurmur2A(_name, (uint32_t)strlen(_name) );
 		uint32_t cmd = bx::hashMurmur2A(_name, (uint32_t)strlen(_name) );
 		BX_CHECK(m_lookup.end() == m_lookup.find(cmd), "Command \"%s\" already exist.", _name);
 		BX_CHECK(m_lookup.end() == m_lookup.find(cmd), "Command \"%s\" already exist.", _name);
 		Func fn = { _fn, _userData };
 		Func fn = { _fn, _userData };
-		m_lookup.insert(std::make_pair(cmd, fn) );
+		m_lookup.insert(stl::make_pair(cmd, fn) );
 	}
 	}
 
 
 	void exec(const char* _cmd)
 	void exec(const char* _cmd)
@@ -82,7 +84,7 @@ struct CmdContext
 		void* m_userData;
 		void* m_userData;
 	};
 	};
 
 
-	typedef std::unordered_map<uint32_t, Func> CmdLookup;
+	typedef stl::unordered_map<uint32_t, Func> CmdLookup;
 	CmdLookup m_lookup;
 	CmdLookup m_lookup;
 };
 };
 
 

+ 7 - 4
examples/common/entry/input.cpp

@@ -5,11 +5,14 @@
 
 
 #include <memory.h>
 #include <memory.h>
 #include <string>
 #include <string>
-#include <unordered_map>
 
 
 #include "entry_p.h"
 #include "entry_p.h"
 #include "input.h"
 #include "input.h"
 
 
+#include <tinystl/allocator.h>
+#include <tinystl/unordered_map.h>
+namespace stl = tinystl;
+
 struct Mouse
 struct Mouse
 {
 {
 	Mouse()
 	Mouse()
@@ -112,12 +115,12 @@ struct Input
 
 
 	void addBindings(const char* _name, const InputBinding* _bindings)
 	void addBindings(const char* _name, const InputBinding* _bindings)
 	{
 	{
-		m_inputBindingsMap.insert(std::make_pair(_name, _bindings) );
+		m_inputBindingsMap.insert(stl::make_pair(_name, _bindings) );
 	}
 	}
 
 
 	void removeBindings(const char* _name)
 	void removeBindings(const char* _name)
 	{
 	{
-		m_inputBindingsMap.erase(_name);
+		m_inputBindingsMap.erase(m_inputBindingsMap.find(_name));
 	}
 	}
 
 
 	void process(const InputBinding* _bindings)
 	void process(const InputBinding* _bindings)
@@ -169,7 +172,7 @@ struct Input
 		m_keyboard.reset();
 		m_keyboard.reset();
 	}
 	}
 
 
-	typedef std::unordered_map<std::string, const InputBinding*> InputBindingMap;
+	typedef stl::unordered_map<const char*, const InputBinding*> InputBindingMap;
 	InputBindingMap m_inputBindingsMap;
 	InputBindingMap m_inputBindingsMap;
 	Mouse m_mouse;
 	Mouse m_mouse;
 	Keyboard m_keyboard;
 	Keyboard m_keyboard;

+ 5 - 3
tools/geometryc/geometryc.cpp

@@ -13,7 +13,9 @@
 #include <algorithm>
 #include <algorithm>
 #include <vector>
 #include <vector>
 #include <string>
 #include <string>
-#include <unordered_map>
+#include <tinystl/allocator.h>
+#include <tinystl/unordered_map.h>
+namespace stl = tinystl;
 
 
 #include <forsythtriangleorderoptimizer.h>
 #include <forsythtriangleorderoptimizer.h>
 
 
@@ -79,7 +81,7 @@ struct Index3
 	int32_t m_vertexIndex;
 	int32_t m_vertexIndex;
 };
 };
 
 
-typedef std::unordered_map<uint64_t, Index3> Index3Map;
+typedef stl::unordered_map<uint64_t, Index3> Index3Map;
 
 
 struct Triangle
 struct Triangle
 {
 {
@@ -478,7 +480,7 @@ int main(int _argc, const char* _argv[])
 					uint64_t hash2 = uint64_t(index.m_normal)<<40;
 					uint64_t hash2 = uint64_t(index.m_normal)<<40;
 					uint64_t hash = hash0^hash1^hash2;
 					uint64_t hash = hash0^hash1^hash2;
 
 
-					std::pair<Index3Map::iterator, bool> result = indexMap.insert(std::make_pair(hash, index) );
+					stl::pair<Index3Map::iterator, bool> result = indexMap.insert(stl::make_pair(hash, index) );
 					if (!result.second)
 					if (!result.second)
 					{
 					{
 						Index3& oldIndex = result.first->second;
 						Index3& oldIndex = result.first->second;