ソースを参照

Correctly support render window resizing

Daniele Bartolini 12 年 前
コミット
7d1ee7d593
3 ファイル変更29 行追加13 行削除
  1. 5 0
      src/Device.cpp
  2. 11 7
      src/os/linux/GLXRenderWindow.cpp
  3. 13 6
      src/os/linux/Input.cpp

+ 5 - 0
src/Device.cpp

@@ -304,6 +304,11 @@ void Device::frame()
 
 	m_input_manager->event_loop();
 
+	uint32_t window_width, window_height;
+	os::get_render_window_metrics(window_width, window_height);
+	m_renderer->set_scissor_params(0, 0, window_width, window_height);
+	m_renderer->set_viewport_params(0, 0, window_width, window_height);
+
 	m_renderer->begin_frame();
 
 	game_frame(last_delta_time());

+ 11 - 7
src/os/linux/GLXRenderWindow.cpp

@@ -41,6 +41,10 @@ Display*		display = NULL;
 Window			window = None;
 GLXContext		glx_context = NULL;
 GLXDrawable		glx_window = None;
+uint32_t		window_x = 0;
+uint32_t		window_y = 0;
+uint32_t		window_width = 0;
+uint32_t		window_height = 0;
 
 //-----------------------------------------------------------------------------
 bool create_render_window(uint32_t x, uint32_t y, uint32_t width, uint32_t height, bool fullscreen)
@@ -135,6 +139,11 @@ bool create_render_window(uint32_t x, uint32_t y, uint32_t width, uint32_t heigh
 	XFree(fbConfig);
 	XFlush(display);
 
+	window_x = x;
+	window_y = y;
+	window_width = width;
+	window_height = height;
+
 	return true;
 }
 
@@ -174,13 +183,8 @@ void swap_buffers()
 //-----------------------------------------------------------------------------
 void get_render_window_metrics(uint32_t& width, uint32_t& height)
 {
-	XWindowAttributes attribs;
-	XGetWindowAttributes(display, window, &attribs);
-
-	XFlush(display);
-
-	width = attribs.width;
-	height = attribs.height;
+	width = window_width;
+	height = window_height;
 }
 
 ////-----------------------------------------------------------------------------

+ 13 - 6
src/os/linux/Input.cpp

@@ -39,6 +39,10 @@ namespace os
 //-----------------------------------------------------------------------------
 extern Display*		display;
 extern Window		window;
+extern uint32_t		window_x;
+extern uint32_t		window_y;
+extern uint32_t		window_width;
+extern uint32_t		window_height;
 
 static bool			x11_detectable_autorepeat = false;
 static Cursor		x11_hidden_cursor = None;
@@ -180,12 +184,15 @@ void event_loop()
 
 		switch (event.type)
 		{
-//			case ConfigureNotify:
-//			{
-//				_NotifyMetricsChange(event.xconfigure.x, event.xconfigure.y,
-//										event.xconfigure.width, event.xconfigure.height);
-//				break;
-//			}
+			case ConfigureNotify:
+			{
+				window_x = event.xconfigure.x;
+				window_y = event.xconfigure.y;
+				window_width = event.xconfigure.width;
+				window_height = event.xconfigure.height;
+
+				break;
+			}
 			case ButtonPress:
 			case ButtonRelease:
 			{