[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3791 - in trunk/pingus: . src/display
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3791 - in trunk/pingus: . src/display |
Date: |
Fri, 11 Jul 2008 15:12:04 +0200 |
Author: grumbel
Date: 2008-07-11 15:12:03 +0200 (Fri, 11 Jul 2008)
New Revision: 3791
Added:
trunk/pingus/src/display/framebuffer.hpp
Modified:
trunk/pingus/SConstruct
trunk/pingus/src/display/display.cpp
trunk/pingus/src/display/sdl_framebuffer.cpp
trunk/pingus/src/display/sdl_framebuffer.hpp
Log:
Turning framebuffer into an interface
Modified: trunk/pingus/SConstruct
===================================================================
--- trunk/pingus/SConstruct 2008-07-11 13:05:20 UTC (rev 3790)
+++ trunk/pingus/SConstruct 2008-07-11 13:12:03 UTC (rev 3791)
@@ -121,7 +121,7 @@
'src/gui/checkbox.cpp',
'src/gui/combobox.cpp',
'src/display/display.cpp',
-'src/display/framebuffer.cpp',
+'src/display/sdl_framebuffer.cpp',
'src/gui/group_component.cpp',
'src/gui/gui_manager.cpp',
'src/gui/input_box.cpp',
Modified: trunk/pingus/src/display/display.cpp
===================================================================
--- trunk/pingus/src/display/display.cpp 2008-07-11 13:05:20 UTC (rev
3790)
+++ trunk/pingus/src/display/display.cpp 2008-07-11 13:12:03 UTC (rev
3791)
@@ -22,7 +22,7 @@
#include "../math/rect.hpp"
#include "../math/color.hpp"
#include "../math.hpp"
-#include "framebuffer.hpp"
+#include "sdl_framebuffer.hpp"
#include "display.hpp"
std::auto_ptr<Framebuffer> Display::framebuffer;
@@ -55,7 +55,7 @@
Display::set_video_mode(int width, int height, bool fullscreen)
{
if (!framebuffer.get())
- framebuffer = std::auto_ptr<Framebuffer>(new Framebuffer());
+ framebuffer = std::auto_ptr<Framebuffer>(new SDLFramebuffer());
framebuffer->set_video_mode(width, height, fullscreen);
}
Added: trunk/pingus/src/display/framebuffer.hpp
===================================================================
--- trunk/pingus/src/display/framebuffer.hpp 2008-07-11 13:05:20 UTC (rev
3790)
+++ trunk/pingus/src/display/framebuffer.hpp 2008-07-11 13:12:03 UTC (rev
3791)
@@ -0,0 +1,48 @@
+// Pingus - A free Lemmings clone
+// Copyright (C) 2008 Ingo Ruhnke <address@hidden>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef HEADER_FRAMEBUFFER_HPP
+#define HEADER_FRAMEBUFFER_HPP
+
+#include <vector>
+#include "SDL.h"
+#include "math/color.hpp"
+#include "math/vector2i.hpp"
+#include "math/rect.hpp"
+
+class Framebuffer
+{
+public:
+ virtual void set_video_mode(int width, int height, bool fullscreen) =0;
+ virtual void flip() =0;
+
+ virtual void push_cliprect(const Rect&) =0;
+ virtual void pop_cliprect() =0;
+
+ virtual void draw_surface(SDL_Surface* src, const Vector2i& pos) =0;
+ virtual void draw_surface(SDL_Surface* src, const Rect& srcrect, const
Vector2i& pos) =0;
+
+ virtual void draw_line(const Vector2i& pos1, const Vector2i& pos2, const
Color& color) =0;
+
+ virtual void draw_rect(const Rect& rect, const Color& color) =0;
+ virtual void fill_rect(const Rect& rect, const Color& color) =0;
+
+ virtual Size get_size() =0;
+};
+
+#endif
+
+/* EOF */
Property changes on: trunk/pingus/src/display/framebuffer.hpp
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: trunk/pingus/src/display/sdl_framebuffer.cpp
===================================================================
--- trunk/pingus/src/display/sdl_framebuffer.cpp 2008-07-11 13:05:20 UTC
(rev 3790)
+++ trunk/pingus/src/display/sdl_framebuffer.cpp 2008-07-11 13:12:03 UTC
(rev 3791)
@@ -17,7 +17,7 @@
#include <iostream>
#include "../math.hpp"
#include "display.hpp"
-#include "framebuffer.hpp"
+#include "sdl_framebuffer.hpp"
namespace {
@@ -136,17 +136,17 @@
} // namespace
-Framebuffer::Framebuffer()
+SDLFramebuffer::SDLFramebuffer()
: screen(0)
{
}
-Framebuffer::~Framebuffer()
+SDLFramebuffer::~SDLFramebuffer()
{
}
void
-Framebuffer::draw_surface(SDL_Surface* src, const Vector2i& pos)
+SDLFramebuffer::draw_surface(SDL_Surface* src, const Vector2i& pos)
{
SDL_Rect dstrect;
dstrect.x = (Sint16)pos.x;
@@ -158,7 +158,7 @@
}
void
-Framebuffer::draw_surface(SDL_Surface* src, const Rect& srcrect, const
Vector2i& pos)
+SDLFramebuffer::draw_surface(SDL_Surface* src, const Rect& srcrect, const
Vector2i& pos)
{
SDL_Rect dstrect;
dstrect.x = (Sint16)pos.x;
@@ -176,7 +176,7 @@
}
void
-Framebuffer::draw_line(const Vector2i& pos1, const Vector2i& pos2, const
Color& color)
+SDLFramebuffer::draw_line(const Vector2i& pos1, const Vector2i& pos2, const
Color& color)
{
int x, y, xlen, ylen, incr;
int sx = pos1.x;
@@ -310,7 +310,7 @@
}
void
-Framebuffer::draw_rect(const Rect& rect, const Color& color)
+SDLFramebuffer::draw_rect(const Rect& rect, const Color& color)
{
draw_line(Vector2i(rect.left, rect.top), Vector2i(rect.right-1,
rect.top), color);
draw_line(Vector2i(rect.left, rect.bottom-1), Vector2i(rect.right-1,
rect.bottom-1), color);
@@ -319,7 +319,7 @@
}
void
-Framebuffer::fill_rect(const Rect& rect_, const Color& color)
+SDLFramebuffer::fill_rect(const Rect& rect_, const Color& color)
{
Rect rect = rect_;
rect.normalize();
@@ -370,19 +370,19 @@
}
void
-Framebuffer::flip()
+SDLFramebuffer::flip()
{
SDL_Flip(screen);
}
Size
-Framebuffer::get_size()
+SDLFramebuffer::get_size()
{
return Size(screen->w, screen->h);
}
void
-Framebuffer::set_video_mode(int width, int height, bool fullscreen)
+SDLFramebuffer::set_video_mode(int width, int height, bool fullscreen)
{
Uint32 flags = SDL_RESIZABLE;
@@ -399,7 +399,7 @@
}
void
-Framebuffer::push_cliprect(const Rect& rect)
+SDLFramebuffer::push_cliprect(const Rect& rect)
{
SDL_Rect sdl_rect;
sdl_rect.x = rect.left;
@@ -417,7 +417,7 @@
}
void
-Framebuffer::pop_cliprect()
+SDLFramebuffer::pop_cliprect()
{
cliprect_stack.pop_back();
if (cliprect_stack.empty())
Modified: trunk/pingus/src/display/sdl_framebuffer.hpp
===================================================================
--- trunk/pingus/src/display/sdl_framebuffer.hpp 2008-07-11 13:05:20 UTC
(rev 3790)
+++ trunk/pingus/src/display/sdl_framebuffer.hpp 2008-07-11 13:12:03 UTC
(rev 3791)
@@ -14,24 +14,25 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#ifndef HEADER_FRAMEBUFFER_HPP
-#define HEADER_FRAMEBUFFER_HPP
+#ifndef HEADER_SDL_FRAMEBUFFER_HPP
+#define HEADER_SDL_FRAMEBUFFER_HPP
#include <vector>
#include "SDL.h"
#include "math/color.hpp"
#include "math/vector2i.hpp"
#include "math/rect.hpp"
+#include "framebuffer.hpp"
-class Framebuffer
+class SDLFramebuffer : public Framebuffer
{
private:
SDL_Surface* screen;
std::vector<SDL_Rect> cliprect_stack;
public:
- Framebuffer();
- ~Framebuffer();
+ SDLFramebuffer();
+ ~SDLFramebuffer();
void set_video_mode(int width, int height, bool fullscreen);
void flip();
@@ -50,8 +51,8 @@
Size get_size();
private:
- Framebuffer (const Framebuffer&);
- Framebuffer& operator= (const Framebuffer&);
+ SDLFramebuffer (const SDLFramebuffer&);
+ SDLFramebuffer& operator= (const SDLFramebuffer&);
};
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3791 - in trunk/pingus: . src/display,
grumbel at BerliOS <=