[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3806 - in trunk/pingus/src: . display input screen
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3806 - in trunk/pingus/src: . display input screen |
Date: |
Sun, 13 Jul 2008 12:45:02 +0200 |
Author: grumbel
Date: 2008-07-13 12:44:48 +0200 (Sun, 13 Jul 2008)
New Revision: 3806
Modified:
trunk/pingus/src/config_manager.cpp
trunk/pingus/src/display/delta_framebuffer.cpp
trunk/pingus/src/display/delta_framebuffer.hpp
trunk/pingus/src/display/display.cpp
trunk/pingus/src/display/display.hpp
trunk/pingus/src/display/framebuffer.hpp
trunk/pingus/src/display/sdl_framebuffer.cpp
trunk/pingus/src/display/sdl_framebuffer.hpp
trunk/pingus/src/input/sdl_driver.cpp
trunk/pingus/src/pingus_main.cpp
trunk/pingus/src/screen/screen_manager.cpp
Log:
Change from set_video_mode(int, int, bool) to set_video_mode(Size, bool)
Moved some resize code from ScreenManager to Display so that fullscreen toggles
are properly catched
Added empty merge_rects() function placeholder to DeltaFramebuffer
Modified: trunk/pingus/src/config_manager.cpp
===================================================================
--- trunk/pingus/src/config_manager.cpp 2008-07-13 10:13:47 UTC (rev 3805)
+++ trunk/pingus/src/config_manager.cpp 2008-07-13 10:44:48 UTC (rev 3806)
@@ -81,7 +81,7 @@
{
screen_width = size.width;
screen_height = size.height;
- Display::set_video_mode(screen_width, screen_height, fullscreen_enabled);
+ Display::set_video_mode(Size(screen_width, screen_height),
fullscreen_enabled);
on_resolution_change(size);
}
}
@@ -102,7 +102,7 @@
{
fullscreen_enabled = v;
Size screen_size = Display::get_size();
- Display::set_video_mode(screen_size.width, screen_size.height,
fullscreen_enabled);
+ Display::set_video_mode(screen_size, fullscreen_enabled);
on_fullscreen_change(v);
}
}
Modified: trunk/pingus/src/display/delta_framebuffer.cpp
===================================================================
--- trunk/pingus/src/display/delta_framebuffer.cpp 2008-07-13 10:13:47 UTC
(rev 3805)
+++ trunk/pingus/src/display/delta_framebuffer.cpp 2008-07-13 10:44:48 UTC
(rev 3806)
@@ -38,6 +38,14 @@
}
};
+void merge_rectangles(const std::vector<SDL_Rect>& rects_in,
std::vector<SDL_Rect>& rects_out)
+{
+ for(std::vector<SDL_Rect>::const_iterator i = rects_in.begin(); i !=
rects_in.end(); ++i)
+ {
+ rects_out.push_back(*i);
+ }
+}
+
class DrawOpBuffer
{
private:
@@ -64,20 +72,20 @@
void render(SDLFramebuffer& fb, DrawOpBuffer& frontbuffer)
{
- std::vector<SDL_Rect> update_rects;
+ std::vector<SDL_Rect> changed_regions;
// Find all regions that need updating
for(DrawOps::iterator i = draw_obs.begin(); i != draw_obs.end(); ++i)
if (!frontbuffer.has_op(*i))
- update_rects.push_back(i->get_region());
+ changed_regions.push_back(i->get_region());
for(DrawOps::iterator i = frontbuffer.draw_obs.begin(); i !=
frontbuffer.draw_obs.end(); ++i)
if (!has_op(*i))
- update_rects.push_back(i->get_region());
+ changed_regions.push_back(i->get_region());
// Clip things to the screen
Size screen_size = fb.get_size();
- for(std::vector<SDL_Rect>::iterator i = update_rects.begin(); i !=
update_rects.end(); ++i)
+ for(std::vector<SDL_Rect>::iterator i = changed_regions.begin(); i !=
changed_regions.end(); ++i)
{
i->w = Math::clamp(0, int(i->w), Math::max(0, screen_size.width -
i->x));
i->h = Math::clamp(0, int(i->h), Math::max(0, screen_size.height -
i->y));
@@ -87,6 +95,8 @@
}
// Merge rectangles
+ std::vector<SDL_Rect> update_rects;
+ merge_rectangles(changed_regions, update_rects);
if (update_rects.size() == 0)
{ // No screen update needed
@@ -124,9 +134,10 @@
}
void
-DeltaFramebuffer::set_video_mode(int width, int height, bool fullscreen)
+DeltaFramebuffer::set_video_mode(const Size& size, bool fullscreen)
{
- framebuffer->set_video_mode(width, height, fullscreen);
+ frontbuffer->clear();
+ framebuffer->set_video_mode(size, fullscreen);
}
void
Modified: trunk/pingus/src/display/delta_framebuffer.hpp
===================================================================
--- trunk/pingus/src/display/delta_framebuffer.hpp 2008-07-13 10:13:47 UTC
(rev 3805)
+++ trunk/pingus/src/display/delta_framebuffer.hpp 2008-07-13 10:44:48 UTC
(rev 3806)
@@ -29,13 +29,13 @@
{
private:
std::auto_ptr<SDLFramebuffer> framebuffer;
- std::auto_ptr<DrawOpBuffer> frontbuffer;
- std::auto_ptr<DrawOpBuffer> backbuffer;
+ std::auto_ptr<DrawOpBuffer> frontbuffer;
+ std::auto_ptr<DrawOpBuffer> backbuffer;
public:
DeltaFramebuffer();
- void set_video_mode(int width, int height, bool fullscreen);
+ void set_video_mode(const Size& size, bool fullscreen);
void flip();
void push_cliprect(const Rect&);
Modified: trunk/pingus/src/display/display.cpp
===================================================================
--- trunk/pingus/src/display/display.cpp 2008-07-13 10:13:47 UTC (rev
3805)
+++ trunk/pingus/src/display/display.cpp 2008-07-13 10:44:48 UTC (rev
3806)
@@ -22,6 +22,7 @@
#include "../math/rect.hpp"
#include "../math/color.hpp"
#include "../math.hpp"
+#include "../screen/screen_manager.hpp"
#include "sdl_framebuffer.hpp"
#include "delta_framebuffer.hpp"
#include "display.hpp"
@@ -53,8 +54,26 @@
}
void
-Display::set_video_mode(int width, int height, bool fullscreen)
+Display::resize(const Size& size_)
{
+ Size size(size_);
+
+ // Limit Window size so some reasonable minimum
+ if (size.width < 640) size.width = 640;
+ if (size.height < 480) size.height = 480;
+
+ // FIXME: Calling this causes horrible flicker, since the screen
+ // goes black on a size change. Seems to be an SDL issue.
+ // This call also shouldn't be part of ScreenManager, but
Framebuffer/Display internal
+ Display::set_video_mode(size, fullscreen_enabled);
+
+ if (ScreenManager::instance())
+ ScreenManager::instance()->resize(size);
+}
+
+void
+Display::set_video_mode(const Size& size, bool fullscreen)
+{
if (!framebuffer.get())
{
if (delta_drawing)
@@ -65,13 +84,16 @@
if (fullscreen)
{
- Size size = find_closest_fullscreen_video_mode(Size(width, height));
- framebuffer->set_video_mode(size.width, size.height, fullscreen);
+ Size new_size = find_closest_fullscreen_video_mode(size);
+ framebuffer->set_video_mode(new_size, fullscreen);
}
else
{
- framebuffer->set_video_mode(width, height, fullscreen);
+ framebuffer->set_video_mode(size, fullscreen);
}
+
+ if (ScreenManager::instance())
+ ScreenManager::instance()->resize(framebuffer->get_size());
}
Framebuffer&
Modified: trunk/pingus/src/display/display.hpp
===================================================================
--- trunk/pingus/src/display/display.hpp 2008-07-13 10:13:47 UTC (rev
3805)
+++ trunk/pingus/src/display/display.hpp 2008-07-13 10:44:48 UTC (rev
3806)
@@ -39,7 +39,8 @@
static int get_height();
static Size get_size();
- static void set_video_mode(int width, int height, bool fullscreen);
+ static void set_video_mode(const Size& size, bool fullscreen);
+ static void resize(const Size& size);
static Framebuffer& get_framebuffer();
Modified: trunk/pingus/src/display/framebuffer.hpp
===================================================================
--- trunk/pingus/src/display/framebuffer.hpp 2008-07-13 10:13:47 UTC (rev
3805)
+++ trunk/pingus/src/display/framebuffer.hpp 2008-07-13 10:44:48 UTC (rev
3806)
@@ -21,12 +21,13 @@
#include "SDL.h"
#include "math/color.hpp"
#include "math/vector2i.hpp"
+#include "math/size.hpp"
#include "math/rect.hpp"
class Framebuffer
{
public:
- virtual void set_video_mode(int width, int height, bool fullscreen) =0;
+ virtual void set_video_mode(const Size& size, bool fullscreen) =0;
virtual void flip() =0;
virtual void push_cliprect(const Rect&) =0;
Modified: trunk/pingus/src/display/sdl_framebuffer.cpp
===================================================================
--- trunk/pingus/src/display/sdl_framebuffer.cpp 2008-07-13 10:13:47 UTC
(rev 3805)
+++ trunk/pingus/src/display/sdl_framebuffer.cpp 2008-07-13 10:44:48 UTC
(rev 3806)
@@ -388,14 +388,14 @@
}
void
-SDLFramebuffer::set_video_mode(int width, int height, bool fullscreen)
+SDLFramebuffer::set_video_mode(const Size& size, bool fullscreen)
{
Uint32 flags = SDL_RESIZABLE;
if (fullscreen)
flags |= SDL_FULLSCREEN;
- screen = SDL_SetVideoMode(width, height, 0, flags);
+ screen = SDL_SetVideoMode(size.width, size.height, 0, flags);
if (screen == NULL)
{
Modified: trunk/pingus/src/display/sdl_framebuffer.hpp
===================================================================
--- trunk/pingus/src/display/sdl_framebuffer.hpp 2008-07-13 10:13:47 UTC
(rev 3805)
+++ trunk/pingus/src/display/sdl_framebuffer.hpp 2008-07-13 10:44:48 UTC
(rev 3806)
@@ -34,7 +34,7 @@
SDLFramebuffer();
~SDLFramebuffer();
- void set_video_mode(int width, int height, bool fullscreen);
+ void set_video_mode(const Size& size, bool fullscreen);
void flip();
void update_rects(const std::vector<SDL_Rect>& rects);
Modified: trunk/pingus/src/input/sdl_driver.cpp
===================================================================
--- trunk/pingus/src/input/sdl_driver.cpp 2008-07-13 10:13:47 UTC (rev
3805)
+++ trunk/pingus/src/input/sdl_driver.cpp 2008-07-13 10:44:48 UTC (rev
3806)
@@ -18,6 +18,7 @@
#include "screen/screen_manager.hpp"
#include "math/size.hpp"
#include "file_reader.hpp"
+#include "display/display.hpp"
#include "sdl_driver.hpp"
namespace Input {
@@ -245,7 +246,7 @@
break;
case SDL_VIDEORESIZE:
- ScreenManager::instance()->resize(Size(event.resize.w,
event.resize.h));
+ Display::resize(Size(event.resize.w, event.resize.h));
break;
case SDL_KEYDOWN:
Modified: trunk/pingus/src/pingus_main.cpp
===================================================================
--- trunk/pingus/src/pingus_main.cpp 2008-07-13 10:13:47 UTC (rev 3805)
+++ trunk/pingus/src/pingus_main.cpp 2008-07-13 10:44:48 UTC (rev 3806)
@@ -731,7 +731,7 @@
exit(1);
}
atexit(SDL_Quit);
- Display::set_video_mode(screen_width, screen_height, fullscreen_enabled);
+ Display::set_video_mode(Size(screen_width, screen_height),
fullscreen_enabled);
SDL_WM_SetCaption("Pingus " VERSION " - SDL Edition", 0 /* icon */);
Modified: trunk/pingus/src/screen/screen_manager.cpp
===================================================================
--- trunk/pingus/src/screen/screen_manager.cpp 2008-07-13 10:13:47 UTC (rev
3805)
+++ trunk/pingus/src/screen/screen_manager.cpp 2008-07-13 10:44:48 UTC (rev
3806)
@@ -378,22 +378,11 @@
}
void
-ScreenManager::resize(const Size& size_)
+ScreenManager::resize(const Size& size)
{
- Size size(size_);
-
- // Limit Window size so some reasonable minimum
- if (size.width < 640) size.width = 640;
- if (size.height < 480) size.height = 480;
-
display_gc->set_rect(Rect(Vector2i(0, 0), size));
- // FIXME: Calling this causes horrible flicker, since the screen
- // goes black on a size change. Seems to be an SDL issue.
- // This call also shouldn't be part of ScreenManager, but
Framebuffer/Display internal
- Display::set_video_mode(size.width, size.height, fullscreen_enabled);
-
- // FIXME: We need to resize the other screens too
+ // The other screens will get resized when they become the current screen
get_current_screen()->resize(size);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3806 - in trunk/pingus/src: . display input screen,
grumbel at BerliOS <=