[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3778 - in trunk/pingus/src: . display screen
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3778 - in trunk/pingus/src: . display screen |
Date: |
Fri, 11 Jul 2008 11:46:35 +0200 |
Author: grumbel
Date: 2008-07-11 11:46:33 +0200 (Fri, 11 Jul 2008)
New Revision: 3778
Modified:
trunk/pingus/src/display/display.cpp
trunk/pingus/src/display/display.hpp
trunk/pingus/src/display/drawing_context.cpp
trunk/pingus/src/display/drawing_context.hpp
trunk/pingus/src/ground_map.cpp
trunk/pingus/src/screen/screen_manager.cpp
trunk/pingus/src/sprite.cpp
trunk/pingus/src/sprite.hpp
trunk/pingus/src/sprite_impl.cpp
trunk/pingus/src/sprite_impl.hpp
trunk/pingus/src/surface.cpp
trunk/pingus/src/surface.hpp
Log:
Some small renames and cleanups
Modified: trunk/pingus/src/display/display.cpp
===================================================================
--- trunk/pingus/src/display/display.cpp 2008-07-11 08:51:48 UTC (rev
3777)
+++ trunk/pingus/src/display/display.cpp 2008-07-11 09:46:33 UTC (rev
3778)
@@ -179,12 +179,6 @@
SDL_UnlockSurface(Display::get_screen());
}
-void
-Display::draw_line(int x1, int y1, int x2, int y2, const Color& color)
-{
- Display::draw_line(Vector2i(x1, y1), Vector2i(x2, y2), color);
-}
-
static
void clip(int& i, int min, int max)
{
@@ -329,18 +323,12 @@
}
void
-Display::draw_rect(int x1, int y1, int x2, int y2, const Color& color)
-{
- Display::draw_line(Vector2i(x1, y1), Vector2i(x2-1, y1), color);
- Display::draw_line(Vector2i(x1, y2-1), Vector2i(x2-1, y2-1), color);
- Display::draw_line(Vector2i(x1, y1), Vector2i(x1, y2-1), color);
- Display::draw_line(Vector2i(x2-1, y1), Vector2i(x2-1, y2-1), color);
-}
-
-void
Display::draw_rect(const Rect& rect, const Color& color)
{
- Display::draw_rect(rect.left, rect.top, rect.right, rect.bottom, 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);
+ draw_line(Vector2i(rect.left, rect.top), Vector2i(rect.left,
rect.bottom-1), color);
+ draw_line(Vector2i(rect.right-1, rect.top), Vector2i(rect.right-1,
rect.bottom-1), color);
}
void
@@ -420,4 +408,16 @@
SDL_SetClipRect(screen, &cliprect_stack.back());
}
+void
+Display::draw_surface(SDL_Surface* sur, const Vector2i& pos)
+{
+
+}
+
+void
+Display::draw_surface(SDL_Surface* sur, const Vector2i& pos, const Rect& rect)
+{
+
+}
+
/* EOF */
Modified: trunk/pingus/src/display/display.hpp
===================================================================
--- trunk/pingus/src/display/display.hpp 2008-07-11 08:51:48 UTC (rev
3777)
+++ trunk/pingus/src/display/display.hpp 2008-07-11 09:46:33 UTC (rev
3778)
@@ -28,25 +28,25 @@
class Color;
class DisplayHook;
-/** This is a kind of wrapper class around CL_Display, it provides
- ways to set the cursor and hooks for flip_display() */
class Display
{
private:
- static std::vector<SDL_Rect> cliprect_stack;
+ static std::vector<SDL_Rect> cliprect_stack;
static SDL_Surface* screen;
+
public:
- static void draw_line(int x1, int y1, int x2, int y2, const Color& color);
+ static void draw_surface(SDL_Surface* sur, const Vector2i& pos);
+ static void draw_surface(SDL_Surface* sur, const Vector2i& pos, const Rect&
rect);
+
static void draw_line(const Vector2i& pos1, const Vector2i& pos2, const
Color& color);
- static void draw_rect(int x1, int y1, int x2, int y2, const Color& color);
static void draw_rect(const Rect& rect, const Color& color);
static void fill_rect(const Rect& rect, const Color& color);
static void flip_display(bool sync=false);
- static int get_width();
- static int get_height();
+ static int get_width();
+ static int get_height();
static Size get_size();
static void set_video_mode(int width, int height);
@@ -57,6 +57,7 @@
static void push_cliprect(const Rect&);
static void pop_cliprect();
+
private:
Display ();
Display (const Display&);
Modified: trunk/pingus/src/display/drawing_context.cpp
===================================================================
--- trunk/pingus/src/display/drawing_context.cpp 2008-07-11 08:51:48 UTC
(rev 3777)
+++ trunk/pingus/src/display/drawing_context.cpp 2008-07-11 09:46:33 UTC
(rev 3778)
@@ -72,7 +72,7 @@
virtual ~SpriteDrawingRequest() {}
void render(SDL_Surface* target, const Rect& rect) {
- sprite.draw(pos.x + rect.left, pos.y + rect.top, target);
+ sprite.render(pos.x + rect.left, pos.y + rect.top, target);
}
};
@@ -196,7 +196,7 @@
}
void
-DrawingContext::render(SDL_Surface* screen, const Rect& parent_rect)
+DrawingContext::render(SDL_Surface* target, const Rect& parent_rect)
{
Rect this_rect(Math::max(rect.left + parent_rect.left, parent_rect.left),
Math::max(rect.top + parent_rect.top, parent_rect.top),
@@ -218,7 +218,7 @@
for(DrawingRequests::iterator i = drawingrequests.begin(); i !=
drawingrequests.end(); ++i)
{
//std::cout << this << ": " << (*i)->get_z_pos() << std::endl;
- (*i)->render(screen, this_rect); // FIXME: Should we clip size against
parent rect?
+ (*i)->render(target, this_rect); // FIXME: Should we clip size against
parent rect?
}
if (do_clipping)
Modified: trunk/pingus/src/display/drawing_context.hpp
===================================================================
--- trunk/pingus/src/display/drawing_context.hpp 2008-07-11 08:51:48 UTC
(rev 3777)
+++ trunk/pingus/src/display/drawing_context.hpp 2008-07-11 09:46:33 UTC
(rev 3778)
@@ -53,8 +53,8 @@
DrawingContext(const Rect& rect, bool clip = true);
virtual ~DrawingContext();
- /** Draws everything in the drawing context to the screen */
- void render(SDL_Surface* screen, const Rect& rect);
+ /** Draws everything in the drawing context to the target */
+ void render(SDL_Surface* target, const Rect& rect);
/** Empties the drawing context */
void clear();
Modified: trunk/pingus/src/ground_map.cpp
===================================================================
--- trunk/pingus/src/ground_map.cpp 2008-07-11 08:51:48 UTC (rev 3777)
+++ trunk/pingus/src/ground_map.cpp 2008-07-11 09:46:33 UTC (rev 3778)
@@ -32,7 +32,6 @@
Sprite sprite;
Surface surface;
- void prepare();
public:
MapTile();
~MapTile();
@@ -52,31 +51,23 @@
}
void
-MapTile::prepare()
-{
- if (!surface)
- {
- surface = Surface(tile_size, tile_size);
- //Blitter::clear_canvas(surface);
- }
-}
-
-void
-MapTile::remove(Surface obj, int x, int y,
+MapTile::remove(Surface src, int x, int y,
int real_x, int real_y, GroundMap* parent)
{
if (sprite)
{
- parent->put_alpha_surface(surface, obj, x, y, real_x, real_y);
+ parent->put_alpha_surface(surface, src, x, y, real_x, real_y);
sprite = Sprite(surface);
}
}
void
-MapTile::put(Surface obj, int x, int y)
+MapTile::put(Surface src, int x, int y)
{
- prepare();
- surface.blit(obj, x, y);
+ if (!surface)
+ surface = Surface(tile_size, tile_size);
+
+ surface.blit(src, x, y);
sprite = Sprite(surface);
}
Modified: trunk/pingus/src/screen/screen_manager.cpp
===================================================================
--- trunk/pingus/src/screen/screen_manager.cpp 2008-07-11 08:51:48 UTC (rev
3777)
+++ trunk/pingus/src/screen/screen_manager.cpp 2008-07-11 09:46:33 UTC (rev
3778)
@@ -264,7 +264,7 @@
// Draw the mouse pointer
if (swcursor_enabled)
- cursor.draw(mouse_pos.x, mouse_pos.y, Display::get_screen());
+ cursor.render(mouse_pos.x, mouse_pos.y, Display::get_screen());
// Draw FPS Counter
if (print_fps)
Modified: trunk/pingus/src/sprite.cpp
===================================================================
--- trunk/pingus/src/sprite.cpp 2008-07-11 08:51:48 UTC (rev 3777)
+++ trunk/pingus/src/sprite.cpp 2008-07-11 09:46:33 UTC (rev 3778)
@@ -86,10 +86,10 @@
}
void
-Sprite::draw(float x, float y, SDL_Surface* target)
+Sprite::render(float x, float y, SDL_Surface* target)
{
if (impl.get())
- impl->draw(x, y, target);
+ impl->render(x, y, target);
}
int
Modified: trunk/pingus/src/sprite.hpp
===================================================================
--- trunk/pingus/src/sprite.hpp 2008-07-11 08:51:48 UTC (rev 3777)
+++ trunk/pingus/src/sprite.hpp 2008-07-11 09:46:33 UTC (rev 3778)
@@ -29,8 +29,7 @@
class SpriteImpl;
class SpriteDescription;
class ResDescriptor;
-
-/** */
+
class Sprite
{
public:
@@ -47,7 +46,7 @@
void update(float delta = 0.033f);
- void draw(float x, float y, SDL_Surface* target);
+ void render(float x, float y, SDL_Surface* target);
void set_hotspot(Origin origin, int x, int y);
Vector2i get_offset() const;
void set_frame(int i);
@@ -80,7 +79,7 @@
private:
boost::shared_ptr<SpriteImpl> impl;
};
-
+
#endif
/* EOF */
Modified: trunk/pingus/src/sprite_impl.cpp
===================================================================
--- trunk/pingus/src/sprite_impl.cpp 2008-07-11 08:51:48 UTC (rev 3777)
+++ trunk/pingus/src/sprite_impl.cpp 2008-07-11 09:46:33 UTC (rev 3778)
@@ -77,7 +77,7 @@
void
SpriteImpl::optimize()
{
- surface.optimize();
+ surface = surface.optimize();
optimized = true;
}
@@ -110,7 +110,7 @@
}
void
-SpriteImpl::draw(float x, float y, SDL_Surface* dst)
+SpriteImpl::render(float x, float y, SDL_Surface* dst)
{
if (!optimized)
optimize();
Modified: trunk/pingus/src/sprite_impl.hpp
===================================================================
--- trunk/pingus/src/sprite_impl.hpp 2008-07-11 08:51:48 UTC (rev 3777)
+++ trunk/pingus/src/sprite_impl.hpp 2008-07-11 09:46:33 UTC (rev 3778)
@@ -54,7 +54,7 @@
void optimize();
void update(float delta);
- void draw(float x, float y, SDL_Surface* dst);
+ void render(float x, float y, SDL_Surface* dst);
void restart();
void finish();
Modified: trunk/pingus/src/surface.cpp
===================================================================
--- trunk/pingus/src/surface.cpp 2008-07-11 08:51:48 UTC (rev 3777)
+++ trunk/pingus/src/surface.cpp 2008-07-11 09:46:33 UTC (rev 3778)
@@ -27,16 +27,13 @@
{
public:
SDL_Surface* surface;
- bool optimized;
SurfaceImpl()
- : surface(0),
- optimized(false)
+ : surface(0)
{}
SurfaceImpl(SDL_Surface* surface)
- : surface(surface),
- optimized(false)
+ : surface(surface)
{}
~SurfaceImpl()
@@ -252,23 +249,24 @@
}
}
-void
+Surface
Surface::optimize()
{
- if (impl.get() && !impl->optimized)
+ if (impl.get())
{
- // FIXME: Could add a check to check if the surface is already optimized
- SDL_Surface* old_surface = impl->surface;
+ SDL_Surface* new_surface;
if (impl->surface->format->Amask != 0 || (impl->surface->flags &
SDL_SRCCOLORKEY))
- impl->surface = SDL_DisplayFormatAlpha(old_surface);
+ new_surface = SDL_DisplayFormatAlpha(impl->surface);
else
- impl->surface = SDL_DisplayFormat(old_surface);
+ new_surface = SDL_DisplayFormat(impl->surface);
- SDL_FreeSurface(old_surface);
-
- impl->optimized = true;
+ return Surface(new_surface);
}
+ else
+ {
+ return Surface();
+ }
}
Surface
Modified: trunk/pingus/src/surface.hpp
===================================================================
--- trunk/pingus/src/surface.hpp 2008-07-11 08:51:48 UTC (rev 3777)
+++ trunk/pingus/src/surface.hpp 2008-07-11 09:46:33 UTC (rev 3778)
@@ -59,12 +59,12 @@
int get_height() const;
int get_pitch() const;
- void blit(const Surface& source, int x, int y);
+ void blit(const Surface& src, int x, int y);
Color get_pixel(int x, int y) const;
void fill(const Color& color);
- void optimize();
+ Surface optimize();
Surface scale(int w, int h);
Surface mod(ResourceModifierNS::ResourceModifier mod);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3778 - in trunk/pingus/src: . display screen,
grumbel at BerliOS <=