Преглед на файлове

merge latest upstream/master

Markus Schöngart преди 11 години
родител
ревизия
466ed7fd31

+ 83 - 0
Build/.gitignore

@@ -27,6 +27,7 @@ luainvaders
 sdl2
 sdl2
 sfml
 sfml
 sfml2
 sfml2
+ogre3d
 scores.txt
 scores.txt
 options.dat
 options.dat
 log.txt
 log.txt
@@ -51,6 +52,88 @@ template
 treeview
 treeview
 tutorial_drag
 tutorial_drag
 
 
+#VisualStudio Project artifacts
+libRocket.sln
+libRocket.sdf
+ALL_BUILD.vcproj
+ALL_BUILD.vcxproj
+ALL_BUILD.vcxproj.filters
+INSTALL.vcproj
+INSTALL.vcxproj
+INSTALL.vcxproj.filters
+ZERO_CHECK.vcproj
+ZERO_CHECK.vcxproj
+ZERO_CHECK.vcxproj.filters
+RocketCore.vcproj
+RocketCore.vcxproj
+RocketCore.vcxproj.filters
+RocketControls.vcproj
+RocketControls.vcxproj
+RocketControls.vcxproj.filters
+RocketDebugger.vcproj
+RocketDebugger.vcxproj
+RocketDebugger.vcxproj.filters
+_rocketcore.vcproj
+_rocketcore.vcxproj
+_rocketcore.vcxproj.filters
+_rocketcontrols.vcproj
+_rocketcontrols.vcxproj
+_rocketcontrols.vcxproj.filters
+RocketCoreLua.vcproj
+RocketCoreLua.vcxproj
+RocketCoreLua.vcxproj.filters
+RocketControlsLua.vcproj
+RocketControlsLua.vcxproj
+RocketControlsLua.vcxproj.filters
+customlog.vcproj
+customlog.vcxproj
+customlog.vcxproj.filters
+datagrid.vcproj
+datagrid.vcxproj
+datagrid.vcxproj.filters
+datagrid_tree.vcproj
+datagrid_tree.vcxproj
+datagrid_tree.vcxproj.filters
+drag.vcproj
+drag.vcxproj
+drag.vcxproj.filters
+invaders.vcproj
+invaders.vcxproj
+invaders.vcxproj.filters
+pyinvaders.vcproj
+pyinvaders.vcxproj
+pyinvaders.vcxproj.filters
+luainvaders.vcproj
+luainvaders.vcxproj
+luainvaders.vcxproj.filters
+loaddocument.vcproj
+loaddocument.vcxproj
+loaddocument.vcxproj.filters
+shell.vcproj
+shell.vcxproj
+shell.vcxproj.filters
+template.vcproj
+template.vcxproj
+template.vcxproj.filters
+treeview.vcproj
+treeview.vcxproj
+treeview.vcxproj.filters
+tutorial_drag.vcproj
+tutorial_drag.vcxproj
+tutorial_drag.vcxproj.filters
+sfml.vcproj
+sfml.vcxproj
+sfml.vcxproj.filters
+sfml2.vcproj
+sfml2.vcxproj
+sfml2.vcxproj.filters
+sdl2.vcproj
+sdl2.vcxproj
+sdl2.vcxproj.filters
+ogre3d.vcproj
+ogre3d.vcxproj
+ogre3d.vcxproj.filters
+
 #Win32 artifacts
 #Win32 artifacts
 libRocketCore.dll
 libRocketCore.dll
 libRocketCore.lib
 libRocketCore.lib

+ 120 - 11
Build/CMakeLists.txt

@@ -2,6 +2,8 @@
 # Build script for libRocket =======
 # Build script for libRocket =======
 #===================================
 #===================================
 
 
+# This has to be before most other options so CMake properly handles the 
+# compiler variables, it MUST bebefore the project() definition
 if(APPLE)
 if(APPLE)
 	if(IOS_PLATFORM)
 	if(IOS_PLATFORM)
 		set(CMAKE_TOOLCHAIN_FILE cmake/Platform/iOS.cmake)
 		set(CMAKE_TOOLCHAIN_FILE cmake/Platform/iOS.cmake)
@@ -81,7 +83,7 @@ if(APPLE)
 	# Disables naked builtins from AssertMacros.h which
 	# Disables naked builtins from AssertMacros.h which
 	# This prevents naming collisions such as those from the check()
 	# This prevents naming collisions such as those from the check()
 	# function macro with LuaType::check
 	# function macro with LuaType::check
-	add_definitions(-D_ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0)
+	add_definitions(-D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0)
 endif(APPLE)
 endif(APPLE)
 
 
 #===================================
 #===================================
@@ -100,6 +102,9 @@ endif(NOT IOS)
 
 
 option(BUILD_PYTHON_BINDINGS "Build python bindings" OFF)
 option(BUILD_PYTHON_BINDINGS "Build python bindings" OFF)
 option(BUILD_LUA_BINDINGS "Build Lua bindings" OFF)
 option(BUILD_LUA_BINDINGS "Build Lua bindings" OFF)
+if(APPLE)
+	option(BUILD_FRAMEWORK "Build Framework bundle for OSX" OFF)
+endif()
 option(BUILD_SAMPLES "Build samples" OFF)
 option(BUILD_SAMPLES "Build samples" OFF)
 if(WIN32)
 if(WIN32)
 	option(SKIP_DIRECTX_SAMPLES "Skip build of all DirectX related samples.  Only applies if BUILD_SAMPLES is ON" OFF)
 	option(SKIP_DIRECTX_SAMPLES "Skip build of all DirectX related samples.  Only applies if BUILD_SAMPLES is ON" OFF)
@@ -113,11 +118,19 @@ if(IOS)
 	endif(BUILD_SHARED_LIBS)
 	endif(BUILD_SHARED_LIBS)
 endif(IOS)
 endif(IOS)
 
 
-if(IOS)
-	if(BUILD_SHARED_LIBS)
-		message(FATAL_ERROR "BUILD_SHARED_LIBS must be OFF for iOS builds.  iOS does not support shared libraries.")
-	endif(BUILD_SHARED_LIBS)
-endif(IOS)
+if(BUILD_FRAMEWORK)
+	if(APPLE)
+		if(NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode")
+			message(FATAL_ERROR "You should use Xcode generator with BUILD_FRAMEWORK enabled")
+		endif()
+		set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_64_BIT)")
+		if(NOT BUILD_SHARED_LIBS)
+			message(FATAL_ERROR "BUILD_SHARED_LIBS must be ON with BUILD_FRAMEWORK enabled")
+		endif()
+	else(APPLE)
+		message(FATAL_ERROR "BUILD_FRAMEWORK is only supported on Mac OS X with the Xcode generator")
+	endif(APPLE)
+endif()
 
 
 if(NOT BUILD_SHARED_LIBS)
 if(NOT BUILD_SHARED_LIBS)
     add_definitions(-DSTATIC_LIB)
     add_definitions(-DSTATIC_LIB)
@@ -204,6 +217,7 @@ include_directories(
 # Include list of source files
 # Include list of source files
 include(FileList)
 include(FileList)
 
 
+if(NOT BUILD_FRAMEWORK)
 #===================================
 #===================================
 # Build libraries ==================
 # Build libraries ==================
 #===================================
 #===================================
@@ -213,10 +227,11 @@ set(LIBRARIES Core Controls Debugger)
 foreach(library ${LIBRARIES})
 foreach(library ${LIBRARIES})
     set(NAME Rocket${library})
     set(NAME Rocket${library})
 
 
-    add_library(${NAME} ${${library}_SRC_FILES}
+    add_library(${NAME}
                         ${${library}_HDR_FILES}
                         ${${library}_HDR_FILES}
                         ${${library}_PUB_HDR_FILES}
                         ${${library}_PUB_HDR_FILES}
                         ${MASTER_${library}_PUB_HDR_FILES}
                         ${MASTER_${library}_PUB_HDR_FILES}
+			${${library}_SRC_FILES}
     )
     )
 
 
     set_target_properties(${NAME} PROPERTIES
     set_target_properties(${NAME} PROPERTIES
@@ -238,6 +253,71 @@ foreach(library ${LIBRARIES})
             RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
             RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
     )
     )
 endforeach(library)
 endforeach(library)
+else(NOT BUILD_FRAMEWORK)
+	#===================================
+	# Build combined Framework =========
+	#===================================
+
+	set(NAME Rocket)
+
+	set(MASTER_PUB_HDR_FILES
+		${MASTER_Core_PUB_HDR_FILES}
+		${MASTER_Controls_PUB_HDR_FILES}
+		${MASTER_Debugger_PUB_HDR_FILES}
+	)
+
+	add_library(${NAME}
+		${Core_HDR_FILES}
+		${MASTER_Core_PUB_HDR_FILES}
+		${Core_PUB_HDR_FILES}
+		${Core_SRC_FILES}
+		${Controls_HDR_FILES}
+		${MASTER_Controls_PUB_HDR_FILES}
+		${Controls_PUB_HDR_FILES}
+		${Controls_SRC_FILES}
+		${Debugger_HDR_FILES}
+		${MASTER_Debugger_PUB_HDR_FILES}
+		${Debugger_PUB_HDR_FILES}
+		${Debugger_SRC_FILES}
+	)
+
+	set_target_properties(${NAME} PROPERTIES
+		VERSION ${PROJECT_VERSION}
+		SOVERSION ${LIBROCKET_VERSION_MAJOR}
+	)
+
+	set_target_properties(${NAME} PROPERTIES
+		OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_64_BIT)"
+	)
+		set_property(SOURCE ${MASTER_PUB_HDR_FILES}
+			PROPERTY MACOSX_PACKAGE_LOCATION Headers
+		)
+		set_property(SOURCE ${Core_PUB_HDR_FILES}
+			PROPERTY MACOSX_PACKAGE_LOCATION Headers/Core
+		)
+		set_property(SOURCE ${Controls_PUB_HDR_FILES}
+			PROPERTY MACOSX_PACKAGE_LOCATION Headers/Controls
+		)
+		set_property(SOURCE ${Debugger_PUB_HDR_FILES}
+			PROPERTY MACOSX_PACKAGE_LOCATION Headers/Debugger
+		)
+		set_target_properties(${NAME} PROPERTIES
+			FRAMEWORK TRUE
+			FRAMEWORK_VERSION ${PROJECT_VERSION}
+			MACOSX_FRAMEWORK_IDENTIFIER com.librocketb.${NAME}
+			MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${LIBROCKET_VERSION_MAJOR}.${LIBROCKET_VERSION_MINOR}.${LIBROCKET_VERSION_PATCH}.${LIBROCKET_VERSION_TWEAK}
+			MACOSX_FRAMEWORK_BUNDLE_VERSION ${PROJECT_VERSION}
+			XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
+			PUBLIC_HEADER ${MASTER_PUB_HDR_FILES}
+		)
+
+    install(TARGETS ${NAME}
+            LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+            ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+            RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+            FRAMEWORK DESTINATION Library/Frameworks
+    )
+endif(NOT BUILD_FRAMEWORK)
 
 
 # Build python bindings
 # Build python bindings
 if(BUILD_PYTHON_BINDINGS)
 if(BUILD_PYTHON_BINDINGS)
@@ -305,18 +385,32 @@ endif()
 # Link libraries ===================
 # Link libraries ===================
 #===================================
 #===================================
 
 
+if(NOT BUILD_FRAMEWORK)
 target_link_libraries(RocketCore ${CORE_LINK_LIBS})
 target_link_libraries(RocketCore ${CORE_LINK_LIBS})
 target_link_libraries(RocketControls RocketCore)
 target_link_libraries(RocketControls RocketCore)
 target_link_libraries(RocketDebugger RocketCore)
 target_link_libraries(RocketDebugger RocketCore)
+else(NOT BUILD_FRAMEWORK)
+target_link_libraries(Rocket ${CORE_LINK_LIBS})
+endif(NOT BUILD_FRAMEWORK)
 
 
 if(BUILD_PYTHON_BINDINGS)
 if(BUILD_PYTHON_BINDINGS)
-    target_link_libraries(_rocketcore RocketCore ${PY_BINDINGS_LINK_LIBS})
-    target_link_libraries(_rocketcontrols RocketControls ${PY_BINDINGS_LINK_LIBS})
+	if(NOT BUILD_FRAMEWORK)
+		target_link_libraries(_rocketcore RocketCore ${PY_BINDINGS_LINK_LIBS})
+		target_link_libraries(_rocketcontrols RocketControls ${PY_BINDINGS_LINK_LIBS})
+	else(NOT BUILD_FRAMEWORK)
+		target_link_libraries(_rocketcore Rocket ${PY_BINDINGS_LINK_LIBS})
+		target_link_libraries(_rocketcontrols Rocket ${PY_BINDINGS_LINK_LIBS})
+	endif(NOT BUILD_FRAMEWORK)
 endif()
 endif()
 
 
 if(BUILD_LUA_BINDINGS)
 if(BUILD_LUA_BINDINGS)
-    target_link_libraries(RocketCoreLua RocketCore ${LUA_BINDINGS_LINK_LIBS})
-    target_link_libraries(RocketControlsLua RocketControls RocketCoreLua ${LUA_BINDINGS_LINK_LIBS})
+	if(NOT BUILD_FRAMEWORK)
+		target_link_libraries(RocketCoreLua RocketCore ${LUA_BINDINGS_LINK_LIBS})
+		target_link_libraries(RocketControlsLua RocketControls RocketCoreLua ${LUA_BINDINGS_LINK_LIBS})
+	else(NOT BUILD_FRAMEWORK)
+		target_link_libraries(RocketCoreLua Rocket ${LUA_BINDINGS_LINK_LIBS})
+		target_link_libraries(RocketControlsLua Rocket RocketCoreLua ${LUA_BINDINGS_LINK_LIBS})
+	endif(NOT BUILD_FRAMEWORK)
 endif()
 endif()
 
 
 
 
@@ -330,6 +424,14 @@ macro(bl_sample NAME)
     	add_executable(${NAME} WIN32 ${${NAME}_SRC_FILES} ${${NAME}_HDR_FILES} )
     	add_executable(${NAME} WIN32 ${${NAME}_SRC_FILES} ${${NAME}_HDR_FILES} )
 	elseif(APPLE)
 	elseif(APPLE)
 		add_executable(${NAME} MACOSX_BUNDLE ${${NAME}_SRC_FILES} ${${NAME}_HDR_FILES} )
 		add_executable(${NAME} MACOSX_BUNDLE ${${NAME}_SRC_FILES} ${${NAME}_HDR_FILES} )
+
+		# The first rpath is to the proper location where the framework/library SHOULD be, the second is to the location actually seen
+		# in the build environment
+if(BUILD_FRAMEWORK)
+		set_target_properties(${NAME} PROPERTIES LINK_FLAGS "-rpath @executable_path/../Frameworks")
+else()
+		set_target_properties(${NAME} PROPERTIES LINK_FLAGS "-rpath @executable_path/../lib")
+endif()
     else()
     else()
     	add_executable(${NAME} ${${NAME}_SRC_FILES} ${${NAME}_HDR_FILES} )
     	add_executable(${NAME} ${${NAME}_SRC_FILES} ${${NAME}_HDR_FILES} )
     endif()
     endif()
@@ -348,12 +450,19 @@ if(BUILD_SAMPLES)
     set(samples treeview customlog drag loaddocument transform)
     set(samples treeview customlog drag loaddocument transform)
     set(tutorials template datagrid datagrid_tree tutorial_drag)
     set(tutorials template datagrid datagrid_tree tutorial_drag)
     
     
+if(NOT BUILD_FRAMEWORK)
     set(sample_LIBRARIES
     set(sample_LIBRARIES
     	shell 
     	shell 
     	RocketCore 
     	RocketCore 
     	RocketControls
     	RocketControls
     	RocketDebugger
     	RocketDebugger
     )
     )
+else(NOT BUILD_FRAMEWORK)
+    set(sample_LIBRARIES
+    	shell 
+    	Rocket
+    )
+endif(NOT BUILD_FRAMEWORK)
 
 
 	# Find OpenGL 
 	# Find OpenGL 
 	find_package(OpenGL REQUIRED)
 	find_package(OpenGL REQUIRED)

+ 4 - 4
Include/Rocket/Controls/Lua/Header.h

@@ -36,11 +36,11 @@
 
 
 #if !defined STATIC_LIB
 #if !defined STATIC_LIB
 	#ifdef ROCKET_PLATFORM_WIN32
 	#ifdef ROCKET_PLATFORM_WIN32
-		#if defined RocketcoreLua_EXPORTS 
+		#if defined RocketCoreLua_EXPORTS 
 			#define ROCKETLUA_API __declspec(dllexport)
 			#define ROCKETLUA_API __declspec(dllexport)
-        #elif defined RocketcontrolsLua_EXPORTS
-            #define ROCKETLUA_API __declspec(dllexport)
-        #else
+		#elif defined RocketControlsLua_EXPORTS
+			#define ROCKETLUA_API __declspec(dllexport)
+        	#else
 			#define ROCKETLUA_API __declspec(dllimport)
 			#define ROCKETLUA_API __declspec(dllimport)
 		#endif
 		#endif
 	#else
 	#else

+ 4 - 4
Include/Rocket/Core/Lua/Header.h

@@ -36,11 +36,11 @@
 
 
 #if !defined STATIC_LIB
 #if !defined STATIC_LIB
 	#ifdef ROCKET_PLATFORM_WIN32
 	#ifdef ROCKET_PLATFORM_WIN32
-		#if defined RocketcoreLua_EXPORTS 
+		#if defined RocketCoreLua_EXPORTS 
 			#define ROCKETLUA_API __declspec(dllexport)
 			#define ROCKETLUA_API __declspec(dllexport)
-        #elif defined RocketcontrolsLua_EXPORTS
-            #define ROCKETLUA_API __declspec(dllexport)
-        #else
+        	#elif defined RocketControlsLua_EXPORTS
+        	    #define ROCKETLUA_API __declspec(dllexport)
+        	#else
 			#define ROCKETLUA_API __declspec(dllimport)
 			#define ROCKETLUA_API __declspec(dllimport)
 		#endif
 		#endif
 	#else
 	#else

+ 22 - 8
Include/Rocket/Core/Lua/LuaType.inl

@@ -109,9 +109,19 @@ int LuaType<T>::push(lua_State *L, T* obj, bool gc)
         }
         }
         else
         else
         {
         {
-            if(IsReferenceCounted<T>())
-                ((Rocket::Core::ReferenceCountable*)obj)->AddReference();
+            //In case this is an address that has been pushed
+            //to lua before, we need to set it to nil
+            lua_pushnil(L); // ->[4] = nil
+            lua_setfield(L,-2,name); //represents t[k] = v, [-2 = 3] = t -> v = [4], k = <ClassName>; pop [4]
+        }
+
+        if(IsReferenceCounted<T>())
+        {
+            //If you look at the gc_T function, reference countables do not
+            //care about the "DO NOT TRASH" table
+            ((Rocket::Core::ReferenceCountable*)obj)->AddReference();
         }
         }
+
         lua_pop(L,1); // -> pop [3]
         lua_pop(L,1); // -> pop [3]
     }
     }
     lua_settop(L,ud); //[ud = 2] -> remove everything that is above 2, top = [2]
     lua_settop(L,ud); //[ud = 2] -> remove everything that is above 2, top = [2]
@@ -167,19 +177,23 @@ int LuaType<T>::gc_T(lua_State* L)
     T * obj = check(L,1); //[1] = this userdata
     T * obj = check(L,1); //[1] = this userdata
     if(obj == NULL)
     if(obj == NULL)
         return 0;
         return 0;
+    if(IsReferenceCounted<T>())
+    {
+        // ReferenceCountables do not care about the "DO NOT TRASH" table.
+        // Because userdata is pushed which contains a pointer to the pointer
+        // of 'obj', 'obj' will be garbage collected for every time 'obj' was pushed.
+        ((Rocket::Core::ReferenceCountable*)obj)->RemoveReference();
+        return 0;
+    }
     lua_getfield(L,LUA_REGISTRYINDEX,"DO NOT TRASH"); //->[2] = return value from this
     lua_getfield(L,LUA_REGISTRYINDEX,"DO NOT TRASH"); //->[2] = return value from this
     if(lua_istable(L,-1) ) //[-1 = 2], if it is a table
     if(lua_istable(L,-1) ) //[-1 = 2], if it is a table
     {
     {
         char name[32];
         char name[32];
         tostring(name,obj);
         tostring(name,obj);
         lua_getfield(L,-1, std::string(name).c_str()); //[-1 = 2] -> [3] = the value returned from if <ClassName> exists in the table to not gc
         lua_getfield(L,-1, std::string(name).c_str()); //[-1 = 2] -> [3] = the value returned from if <ClassName> exists in the table to not gc
-        if(lua_isnil(L,-1) ) //[-1 = 3] if it doesn't exist, then we are free to garbage collect c++ side
+        if(lua_isnoneornil(L,-1) ) //[-1 = 3] if it doesn't exist, then we are free to garbage collect c++ side
         {
         {
-            if(IsReferenceCounted<T>())
-            {
-                ((Rocket::Core::ReferenceCountable*)obj)->RemoveReference();
-            }
-            else
+            if(!IsReferenceCounted<T>())
             {
             {
                 delete obj;
                 delete obj;
                 obj = NULL;
                 obj = NULL;

+ 10 - 10
Include/Rocket/Core/Vector2.inl

@@ -62,12 +62,12 @@ Type Vector2< Type >::SquaredMagnitude() const
 template < typename Type >
 template < typename Type >
 Vector2< Type > Vector2< Type >::Normalise() const
 Vector2< Type > Vector2< Type >::Normalise() const
 {
 {
-	ROCKET_STATIC_ASSERT(sizeof(Type) == 0, Invalid_Operation);
-	return *this;
-}
+	float magnitude = Magnitude();
+	if (Math::IsZero(magnitude))
+		return *this;
 
 
-template <>
-ROCKETCORE_API Vector2< float > Vector2< float >::Normalise() const;
+	return *this / magnitude;
+}
 
 
 // Computes the dot-product between this vector and another.
 // Computes the dot-product between this vector and another.
 template < typename Type >
 template < typename Type >
@@ -81,12 +81,12 @@ Type Vector2< Type >::DotProduct(const Vector2< Type >& rhs) const
 template < typename Type >
 template < typename Type >
 Vector2< Type > Vector2< Type >::Rotate(float theta) const
 Vector2< Type > Vector2< Type >::Rotate(float theta) const
 {
 {
-	ROCKET_STATIC_ASSERT(sizeof(Type) == 0, Invalid_Operation);
-	return *this;
-}
+	float cos_theta = Math::Cos(theta);
+	float sin_theta = Math::Sin(theta);
 
 
-template <>
-ROCKETCORE_API Vector2< float > Vector2< float >::Rotate(float) const;
+	return Vector2< Type >(((Type)(cos_theta * x - sin_theta * y)),
+							((Type)(sin_theta * x + cos_theta * y)));
+}
 
 
 // Returns the negation of this vector.
 // Returns the negation of this vector.
 template < typename Type >
 template < typename Type >

+ 1 - 3
Samples/basic/sfml2/src/RenderInterfaceSFML.h

@@ -42,9 +42,7 @@
 // if the OpenGL Extension Wrangler Library (GLEW) should not be used
 // if the OpenGL Extension Wrangler Library (GLEW) should not be used
 // include the standard OpenGL library
 // include the standard OpenGL library
 #ifndef ENABLE_GLEW
 #ifndef ENABLE_GLEW
-// NOTE: add this if you receive a lot of errors in gl.h
-//#include <windows.h>
-#include <GL/gl.h>
+#include "../../../shell/include/ShellOpenGL.h"
 #endif
 #endif
 
 
 class RocketSFMLRenderer : public Rocket::Core::RenderInterface
 class RocketSFMLRenderer : public Rocket::Core::RenderInterface

+ 4 - 1
Samples/basic/sfml2/src/main.cpp

@@ -155,7 +155,7 @@ int main(int argc, char **argv)
 					SystemInterface.GetKeyModifiers(&MyWindow));
 					SystemInterface.GetKeyModifiers(&MyWindow));
 				break;
 				break;
 			case sf::Event::Closed:
 			case sf::Event::Closed:
-				return 1;
+				MyWindow.close();
 				break;
 				break;
 			};
 			};
 		};
 		};
@@ -163,5 +163,8 @@ int main(int argc, char **argv)
 		Context->Update();
 		Context->Update();
 	};
 	};
 
 
+	Context->RemoveReference();
+	Rocket::Core::Shutdown();
+
 	return 0;
 	return 0;
 };
 };

+ 4 - 2
Source/Core/Lua/Document.cpp

@@ -102,7 +102,8 @@ int DocumentCreateElement(lua_State* L, Document* obj)
 {
 {
     const char* tag = luaL_checkstring(L,1);
     const char* tag = luaL_checkstring(L,1);
     Element* ele = obj->CreateElement(tag);
     Element* ele = obj->CreateElement(tag);
-    LuaType<Element>::push(L,ele,false);
+    LuaType<Element>::push(L,ele,true);
+    ele->RemoveReference();
     return 1;
     return 1;
 }
 }
 
 
@@ -111,7 +112,8 @@ int DocumentCreateTextNode(lua_State* L, Document* obj)
     //need ElementText object first
     //need ElementText object first
     const char* text = luaL_checkstring(L,1);
     const char* text = luaL_checkstring(L,1);
     ElementText* et = obj->CreateTextNode(text);
     ElementText* et = obj->CreateTextNode(text);
-    LuaType<ElementText>::push(L, et, false);
+    LuaType<ElementText>::push(L, et, true);
+    et->RemoveReference();
 	return 1;
 	return 1;
 }
 }
 
 

+ 1 - 0
Source/Core/Lua/LuaElementInstancer.cpp

@@ -27,6 +27,7 @@
 
 
 #include "precompiled.h"
 #include "precompiled.h"
 #include "LuaElementInstancer.h"
 #include "LuaElementInstancer.h"
+#include <Rocket/Core/Platform.h>
 #include <Rocket/Core/Lua/LuaType.h>
 #include <Rocket/Core/Lua/LuaType.h>
 #include <Rocket/Core/Lua/Interpreter.h>
 #include <Rocket/Core/Lua/Interpreter.h>
 #include <Rocket/Core/Log.h>
 #include <Rocket/Core/Log.h>

+ 0 - 65
Source/Core/Vector2.cpp

@@ -1,65 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#include "precompiled.h"
-#include "../../Include/Rocket/Core/Types.h"
-
-namespace Rocket {
-namespace Core {
-
-Vector2i operator*(int lhs, const Vector2i& rhs)
-{
-	return Vector2i(lhs * rhs.x, lhs * rhs.y);
-}
-
-Vector2f operator*(float lhs, const Vector2f& rhs)
-{
-	return Vector2f(lhs * rhs.x, lhs * rhs.y);
-}
-
-template <>
-Vector2< float > Vector2< float >::Normalise() const
-{
-	float magnitude = Magnitude();
-	if (Math::IsZero(magnitude))
-		return *this;
-
-	return *this / magnitude;
-}
-
-template <>
-Vector2< float > Vector2< float >::Rotate(float theta) const
-{
-	float cos_theta = Math::Cos(theta);
-	float sin_theta = Math::Sin(theta);
-
-	return Vector2< float >(cos_theta * x - sin_theta * y,
-							sin_theta * x + cos_theta * y);
-}
-
-}
-}