Index: trunk/src/gl/gl_window.cc
===================================================================
--- trunk/src/gl/gl_window.cc	(revision 170)
+++ trunk/src/gl/gl_window.cc	(revision 171)
@@ -18,8 +18,14 @@
 	kevent.key.code    = KEY_NONE;
 
+#if NV_SDL_VERSION == NV_SDL_20
+	uint32 ucode = ke.keysym.sym;
+#else
+	uint32 ucode = ke.keysym.unicode;
+#endif
+
 	// if result is a typable char place it into the structure
-	if (ke.keysym.unicode >= 32 && ke.keysym.unicode < 128 )
-	{
-		kevent.key.ascii = static_cast<char8>( ke.keysym.unicode );
+	if (ucode >= 32 && ucode < 128 )
+	{
+		kevent.key.ascii = static_cast<char8>( ucode );
 	}
 
@@ -67,5 +73,5 @@
 	case SDLK_DELETE       : kevent.key.code = KEY_DELETE; break;
 	case SDLK_INSERT       : kevent.key.code = KEY_INSERT; break;
-	case SDLK_KP5          : kevent.key.code = KEY_CENTER; break;
+	//case SDLK_KP5          : kevent.key.code = KEY_CENTER; break;
 	case SDLK_ESCAPE       : kevent.key.code = KEY_ESCAPE; break;
 	case SDLK_QUOTE        : kevent.key.code = KEY_QUOTE; break;
@@ -91,6 +97,6 @@
 	mevent.mbutton.button  = MOUSE_NONE;
 	mevent.mbutton.pressed = (mb.state != SDL_RELEASED);
-	mevent.mbutton.x       = mb.x;
-	mevent.mbutton.y       = mb.y;
+	mevent.mbutton.x       = static_cast< uint16 >( mb.x );
+	mevent.mbutton.y       = static_cast< uint16 >( mb.y );
 
 	switch ( mb.button )
@@ -99,6 +105,6 @@
 	case SDL_BUTTON_MIDDLE    : mevent.mbutton.button = MOUSE_MIDDLE; break;
 	case SDL_BUTTON_RIGHT     : mevent.mbutton.button = MOUSE_RIGHT; break;
-	case SDL_BUTTON_WHEELUP   : mevent.mbutton.button = MOUSE_WHEEL_UP; break;
-	case SDL_BUTTON_WHEELDOWN : mevent.mbutton.button = MOUSE_WHEEL_DOWN; break;
+	//case SDL_BUTTON_WHEELUP   : mevent.mbutton.button = MOUSE_WHEEL_UP; break;
+	//case SDL_BUTTON_WHEELDOWN : mevent.mbutton.button = MOUSE_WHEEL_DOWN; break;
 	default : break;
 	}
@@ -111,6 +117,6 @@
 	mevent.type          = EV_MOUSE_MOVE;
 	mevent.mmove.pressed = (mm.state != SDL_RELEASED);
-	mevent.mmove.x       = mm.x;
-	mevent.mmove.y       = mm.y;
+	mevent.mmove.x       = static_cast< uint16 >( mm.x );
+	mevent.mmove.y       = static_cast< uint16 >( mm.y );
 	return true;
 }
@@ -125,4 +131,5 @@
 	case SDL_MOUSEBUTTONDOWN : return sdl_mouse_button_to_io_event( e.button, ioevent );
 	case SDL_MOUSEBUTTONUP   : return sdl_mouse_button_to_io_event( e.button, ioevent );
+/* // SDL 2.0 incompatible 
 	case SDL_ACTIVEEVENT     : 
 		ioevent.type = EV_ACTIVE; 
@@ -134,8 +141,9 @@
 		ioevent.resize.y = e.resize.h;
 		return true;
+	case SDL_NOEVENT         : return false;
+	case SDL_VIDEOEXPOSE     : return false;
+*/
 	case SDL_SYSWMEVENT      : ioevent.type = EV_SYSTEM; return true;
 	case SDL_QUIT            : ioevent.type = EV_QUIT;   return true;
-	case SDL_NOEVENT         : return false;
-	case SDL_VIDEOEXPOSE     : return false;
 	case SDL_JOYAXISMOTION   : return false;
 	case SDL_JOYBALLMOTION   : return false;
@@ -149,11 +157,15 @@
 
 gl_window::gl_window( device* dev, uint16 width, uint16 height )
-	: m_device( dev ), m_width( width ), m_height( height ), m_title("NV Engine"), m_screen( nullptr )
-{
+	: 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;
-	
-	m_screen = SDL_SetVideoMode( width, height, 32, flags );
-	
-	if ( m_screen == 0 )
+	m_handle = SDL_SetVideoMode( width, height, 32, flags );
+#elif NV_SDL_VERSION == NV_SDL_20
+	uint32 flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN;
+	m_handle = SDL_CreateWindow("Nova Engine", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
+		width, height, flags );
+#endif
+	if ( m_handle == 0 )
 	{
 		NV_LOG( LOG_CRITICAL, "Video mode set failed: " << SDL_GetError( ) );
@@ -161,11 +173,5 @@
 	}
 
-	nv::load_gl_library();
-	NV_LOG( LOG_INFO, "OpenGL Vendor       : " << glGetString(GL_VENDOR) );
-	NV_LOG( LOG_INFO, "OpenGL Renderer     : " << glGetString(GL_RENDERER) );
-	NV_LOG( LOG_INFO, "OpenGL Version      : " << glGetString(GL_VERSION) );
-	NV_LOG( LOG_INFO, "OpenGL GLSL Version : " << glGetString(GL_SHADING_LANGUAGE_VERSION) );
-
-	m_context = new gl_context( m_device );
+	m_context = new gl_context( m_device, m_handle );
 	m_context->set_viewport( nv::ivec4( 0, 0, m_width, m_height ) );
 }
@@ -188,5 +194,9 @@
 void gl_window::set_title( const string& title )
 {
+#if NV_SDL_VERSION == NV_SDL_20
+	SDL_SetWindowTitle( static_cast<SDL_Window*>( m_handle ), title.c_str() );
+#else
 	SDL_WM_SetCaption( title.c_str(), title.c_str() );
+#endif
 	m_title = title;
 }
@@ -206,5 +216,9 @@
 void gl_window::swap_buffers()
 {
+#if NV_SDL_VERSION == NV_SDL_20
+	SDL_GL_SwapWindow( static_cast<SDL_Window*>( m_handle ) );
+#else
 	SDL_GL_SwapBuffers();
+#endif
 }
 
@@ -212,3 +226,6 @@
 {
 	delete m_context;
-}
+#if NV_SDL_VERSION == NV_SDL_20
+	SDL_DestroyWindow( static_cast<SDL_Window*>( m_handle ) );
+#endif
+}
