Index: /trunk/nv.lua
===================================================================
--- /trunk/nv.lua	(revision 119)
+++ /trunk/nv.lua	(revision 120)
@@ -1,8 +1,33 @@
--- project definition for nv
 project "nv"
 	location (_ACTION)
-    language "C++"
+	language "C++"
 	kind "StaticLib"
 	includedirs { "." }
 	files { "nv/**.hh", "nv/**.inl", "src/**.cc" }
 	targetname "nv"
+
+-- injection!
+solution( solution().name )
+	configuration "*"
+		includedirs { os.getenv("GLM_PATH") }
+	configuration "gmake"
+		buildoptions "-std=c++0x"
+	configuration "vs*"
+		defines { "_SECURE_SCL=0", "_CRT_SECURE_NO_WARNINGS=1" }
+
+if _ACTION == "gmake-clang" then
+	premake.gcc.cc  = "clang"
+	premake.gcc.cxx = "clang++"
+	_ACTION = "gmake"
+end
+
+premake.action.add { 
+	trigger = "gmake-clang", 
+	description = "gmake file with clang overrides, needs 'make -R' to work",
+}
+
+if _ACTION == "clean" then
+	for action in premake.action.each() do
+		os.rmdir(action.trigger)
+	end
+end
Index: /trunk/nv/common.hh
===================================================================
--- /trunk/nv/common.hh	(revision 119)
+++ /trunk/nv/common.hh	(revision 120)
@@ -48,10 +48,10 @@
 #define NV_COMPILER NV_MSVC
 #define NV_COMP_VER _MSC_VER
+#elif defined( __clang__ )
+#define NV_COMPILER NV_CLANG
+#define NV_COMP_VER (((__clang_major__)*100) + (__clang_minor__*10) + __clang_patchlevel__)
 #elif defined( __GNUC__ )
 #define NV_COMPILER NV_GNUC
 #define NV_COMP_VER (((__GNUC__)*100) + (__GNUC_MINOR__*10) + __GNUC_PATCHLEVEL__)
-#elif defined( __clang__ )
-#define NV_COMPILER NV_CLANG
-#define NV_COMP_VER (((__clang_major__)*100) + (__clang_minor__*10) + __clang_patchlevel__)
 #else
 #error "Unknown compiler!"
Index: /trunk/nv/gfx/cached_buffer.hh
===================================================================
--- /trunk/nv/gfx/cached_buffer.hh	(revision 119)
+++ /trunk/nv/gfx/cached_buffer.hh	(revision 120)
@@ -47,5 +47,6 @@
 			if ( locked || result )
 			{
-				m_cache->add_offset<T>( m_data.size(), m_offset, static_cast<T>(value) );
+				// funny, but this is what GCC expects
+				m_cache->template add_offset<T>( m_data.size(), m_offset, static_cast<T>(value) );
 			}
 			return result;
Index: /trunk/nv/interface/clear_state.hh
===================================================================
--- /trunk/nv/interface/clear_state.hh	(revision 119)
+++ /trunk/nv/interface/clear_state.hh	(revision 120)
@@ -64,6 +64,6 @@
 		};
 
-		scissor_test scissor_test;
-		color_mask color_mask;
+		nv::scissor_test scissor_test;
+		nv::color_mask color_mask;
 		bool depth_mask;
 		uint32 front_stencil_mask;
Index: /trunk/nv/position.hh
===================================================================
--- /trunk/nv/position.hh	(revision 119)
+++ /trunk/nv/position.hh	(revision 120)
@@ -29,10 +29,6 @@
 		typedef rectangle type;
 		
-		union 
-		{
-			struct { position upper_left; position lower_right; };
-			struct { position ul;         position lr; };
-			struct { value_type x1,y1,x2,y2; };
-		};
+		position ul;
+		position lr;
 		/**
 		 *Creates a new rectangle assigned to {0, 0, 0, 0}.
@@ -139,5 +135,5 @@
 		 *@returns The width of the rectangle.
 		 */
-		value_type get_width() const { return x2 - x1; }
+		value_type get_width() const { return lr.x - ul.x; }
 
 		/**
@@ -146,5 +142,5 @@
 		 *@returns The height of the rectangle.
 		 */
-		value_type get_height() const { return y2 - y1; }
+		value_type get_height() const { return lr.y - ul.y; }
 
 		/**
@@ -153,5 +149,5 @@
 		 *@returns The area of the rectangle.
 		 */
-		value_type get_area() const { return (y2 - y1) * (x2 - x1); }
+		value_type get_area() const { return (lr.y - ul.y) * (lr.x - ul.x); }
 
 		/**
@@ -160,5 +156,5 @@
 		 *@returns True if the rectangle's upper-left is above and left (or equal to) the rectangle's lower-right, false if it is not.
 		 */
-		bool is_valid() const {	return x2 >= x1 && y2 >= y1; }
+		bool is_valid() const {	return lr.x >= ul.x && lr.y >= ul.y; }
 
 		/**
@@ -246,5 +242,5 @@
 		 *@returns True if the position is inside or on the edge of the rectangle, false otherwise.
 		 */
-		bool contains( const position& r ) const{ return y2 >= r.y && y1 <= r.y && x2 >= r.x && x1 <= r.x; }
+		bool contains( const position& r ) const{ return lr.y >= r.y && ul.y <= r.y && lr.x >= r.x && ul.x <= r.x; }
 
 		/**
@@ -262,5 +258,5 @@
 		 *@returns True if any part of the rectangle to check overlaps this rectangle, false otherwise.
 		 */
-		bool collides( const rectangle& r ) const { return y2 > r.y1 && y1 < r.y2 && x2 > r.x1 && x1 < r.x2; }
+		bool collides( const rectangle& r ) const { return lr.y > r.ul.y && ul.y < r.lr.y && lr.x > r.ul.x && ul.x < r.lr.x; }
 
 		/**
@@ -298,6 +294,6 @@
 		void repair() 
 		{
-			if (x1 > x2) std::swap( x1, x2 );
-			if (y1 > y2) std::swap( y1, y2 );
+			if (ul.x > lr.x) std::swap( ul.x, lr.x );
+			if (ul.y > lr.y) std::swap( ul.y, lr.y );
 		}
 
Index: /trunk/premake4.lua
===================================================================
--- /trunk/premake4.lua	(revision 119)
+++ /trunk/premake4.lua	(revision 120)
@@ -1,24 +1,4 @@
--- Error handling if user didn't provide any action/target
--- for the build
-if _ACTION == nil then
-	print "Error! You must specify target build"
-	print "Example: ./premake4 gmake"
-	print "    This will create makefiles for Linux"
-	print ""
-	print "Aborting!"
-	print ""
-	return
-end
-
 solution "nv"
 	configurations { "debug", "release" }
-
-	-- For starters, check the target build.
-	-- If this is a gmake build we must add these
-	-- flags to enable C++11 support.
-	if _ACTION == "gmake" then
-		buildoptions "-std=c++11"
-	end
-
 	targetdir "bin"
 	flags { "ExtraWarnings", "NoPCH" }
@@ -29,5 +9,5 @@
 		flags { "Symbols" }
 		targetdir "bin"
-		objdir (_ACTION.."/debug")
+		objdir (_ACTION or "".."/debug")
 
 	configuration "release"
@@ -35,5 +15,5 @@
 		flags { "Optimize" }
 		targetdir "bin"
-		objdir (_ACTION.."/release")
+		objdir (_ACTION or "".."/release")
 
 	dofile("nv.lua")
@@ -46,9 +26,2 @@
 	end
 }
-
-if _ACTION == "clean" then
-	for action in premake.action.each() do
-		os.rmdir(action.trigger)
-	end
-end
-
Index: /trunk/src/gl/gl_device.cc
===================================================================
--- /trunk/src/gl/gl_device.cc	(revision 119)
+++ /trunk/src/gl/gl_device.cc	(revision 120)
@@ -74,4 +74,9 @@
 	load_sdl_image_library();
 	SDL_Surface* image = IMG_Load( filename.c_str() );
+	if (!image)
+	{
+		NV_LOG( LOG_ERROR, "Image file " << filename.c_str() << " not found!" );
+		return nullptr;
+	}
 	image_data* data = new image_data( glm::ivec2( image->w, image->h ), image->format->BytesPerPixel, (nv::uint8*)image->pixels );
 	return data;
Index: /trunk/src/gui/gui_element.cc
===================================================================
--- /trunk/src/gui/gui_element.cc	(revision 119)
+++ /trunk/src/gui/gui_element.cc	(revision 120)
@@ -27,4 +27,5 @@
 		}
 	}
+	//((environment*)m_root)->update( this, elapsed );
 }
 
@@ -90,5 +91,5 @@
 	}
 
-	m_absolute = m_relative + pabsolute.upper_left;
+	m_absolute = m_relative + pabsolute.ul;
 
 	for ( object* o : *this )
Index: /trunk/src/library.cc
===================================================================
--- /trunk/src/library.cc	(revision 119)
+++ /trunk/src/library.cc	(revision 120)
@@ -115,5 +115,5 @@
 #if NV_PLATFORM == NV_WINDOWS
     // We do hate WinAPI for code like this, don't we?
-    LPVOID buffer;
+    LPTSTR buffer = NULL;
     FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
         NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &buffer, 0, NULL );
Index: /trunk/src/object.cc
===================================================================
--- /trunk/src/object.cc	(revision 119)
+++ /trunk/src/object.cc	(revision 120)
@@ -7,4 +7,5 @@
 #include "nv/object.hh"
 
+#include <algorithm>
 #include "nv/root.hh"
 #include "nv/types.hh"
Index: /trunk/tests/render_test/premake4.lua
===================================================================
--- /trunk/tests/render_test/premake4.lua	(revision 119)
+++ /trunk/tests/render_test/premake4.lua	(revision 120)
@@ -1,12 +1,2 @@
-if _ACTION == nil then
-	print "Error! You must specify target build"
-	print "Example: ./premake4 gmake"
-	print "    This will create makefiles for Linux"
-	print ""
-	print "Aborting!"
-	print ""
-	return
-end
-
 solution "nv_render_test"
 	configurations { "debug", "release" }
@@ -15,20 +5,13 @@
 	flags { "ExtraWarnings", "NoPCH" }
 
-	-- For starters, check the target build.
-	-- If this is a gmake build we must add these
-	-- flags to enable C++11 support.
-	if _ACTION == "gmake" then
-		buildoptions "-std=c++11"
-	end
-
 	configuration "debug"
 		defines { "DEBUG" }
 		flags { "Symbols", "StaticRuntime" }
-		objdir (_ACTION.."/debug")
+		objdir (_ACTION or "".."/debug")
 
 	configuration "release"
 		defines { "NDEBUG" }
 		flags { "Optimize", "StaticRuntime" }
-		objdir (_ACTION.."/release")
+		objdir (_ACTION or "".."/release")
 
 	dofile("render_test.lua")
Index: /trunk/tests/render_test/render_test.lua
===================================================================
--- /trunk/tests/render_test/render_test.lua	(revision 119)
+++ /trunk/tests/render_test/render_test.lua	(revision 120)
@@ -5,5 +5,4 @@
 	includedirs { "../../" }
 	targetname "rl"
-	defines { "_SCL_SECURE_NO_WARNINGS" }
 	links { "nv" }
  
