Index: trunk/src/gfx/image.cc
===================================================================
--- trunk/src/gfx/image.cc	(revision 227)
+++ trunk/src/gfx/image.cc	(revision 228)
@@ -48,4 +48,19 @@
 }
 
+void image::fill( region r, uint8 value, int stride )
+{
+	if ( stride == 0 ) stride = r.size.x * static_cast<sint32>( m_depth );
+
+	sint32 bpos  = (r.pos.y*m_size.x + r.pos.x ) * static_cast<sint32>( m_depth );
+	sint32 bline = m_size.x*static_cast<sint32>( m_depth );
+
+	for( int i = 0; i < r.size.y; ++i )
+	{
+		// TODO: test 
+		std::fill( m_data + bpos + bline * i, m_data + bpos + bline * i + stride, value );
+	}
+}
+
+
 void image::set_region( region r, const uint8 * data, int stride )
 {
@@ -64,4 +79,36 @@
 }
 
+void image::set_region( region r, const image_data* idata )
+{
+	if ( idata->get_depth() == m_depth )
+	{
+		set_region( r, idata->get_data() );
+		return;
+	}
+
+	fill( r, 255 );
+
+	sint32 bpos       = (r.pos.y*m_size.x + r.pos.x ) * static_cast<sint32>( m_depth );
+	sint32 bline      = m_size.x*static_cast<sint32>( m_depth );
+
+	const uint8* data = idata->get_data();
+	sint32 depth      = idata->get_depth();
+	sint32 dstride    = r.size.x * static_cast<sint32>( depth );
+
+	for( int y = 0; y < r.size.y; ++y )
+	{
+		sint32 pos = bpos + bline * y;
+		for( int x = 0; x < r.size.x; ++x )
+		{
+			sint32 xy = pos + x * m_depth;
+			for( int e = 0; e < depth; ++e )
+			{
+				m_data[ xy + e ] = data[ y*dstride + x * depth + e ];
+			}
+		}
+	}
+}
+
+
 image::~image()
 {
Index: trunk/src/gl/gl_device.cc
===================================================================
--- trunk/src/gl/gl_device.cc	(revision 227)
+++ trunk/src/gl/gl_device.cc	(revision 228)
@@ -15,7 +15,7 @@
 using namespace nv;
 
-window* gl_device::create_window( uint16 width, uint16 height )
+window* gl_device::create_window( uint16 width, uint16 height, bool fullscreen )
 {
-	return new gl_window( this, width, height );
+	return new gl_window( this, width, height, fullscreen );
 }
 
Index: trunk/src/gl/gl_window.cc
===================================================================
--- trunk/src/gl/gl_window.cc	(revision 227)
+++ trunk/src/gl/gl_window.cc	(revision 228)
@@ -203,12 +203,14 @@
 
 
-gl_window::gl_window( device* dev, uint16 width, uint16 height )
+gl_window::gl_window( device* dev, uint16 width, uint16 height, bool fullscreen )
 	: m_device( dev ), m_width( width ), m_height( height ), m_title("NV Engine"), m_handle( nullptr )
 {
 #if NV_SDL_VERSION == NV_SDL_12
 	uint32 flags = SDL_OPENGL;
+	if (fullscreen) flags |= SDL_FULLSCREEN;
 	m_handle = SDL_SetVideoMode( width, height, 32, flags );
 #elif NV_SDL_VERSION == NV_SDL_20
 	uint32 flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN;
+	if (fullscreen) flags |= SDL_FULLSCREEN;
 	m_handle = SDL_CreateWindow("Nova Engine", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
 		width, height, flags );
Index: trunk/src/lua/lua_map_tile.cc
===================================================================
--- trunk/src/lua/lua_map_tile.cc	(revision 227)
+++ trunk/src/lua/lua_map_tile.cc	(revision 228)
@@ -130,5 +130,5 @@
 		{
 			nv::uint8 c = tile->data[ y * tile->size_x + x ];
-			if ( c != 0 ) area->set_cell( coord + nv::ivec2( x, y ), tile->data[ y * tile->size_x + x ] );
+			if ( c != 0 ) area->set_cell( coord + nv::ivec2( x, y ), c );
 		}
 
Index: trunk/src/lua/lua_state.cc
===================================================================
--- trunk/src/lua/lua_state.cc	(revision 227)
+++ trunk/src/lua/lua_state.cc	(revision 228)
@@ -234,5 +234,7 @@
 		for(; lib->func != NULL; lib++)
 		{
-			lib->func( m_state );
+			lua_pushcfunction( m_state, lib->func );
+			lua_call(m_state, 0, 1);
+			lua_setglobal( m_state, lib->name );
 		}
 		register_nova( this );
