[Super-tux-commit] supertux/lib/video drawing_context.cpp,1.1,1.2 drawing_context.h,1.1,1.2 font.cpp
Brought to you by:
wkendrick
From: Tobias G. <to...@us...> - 2004-07-21 16:52:05
|
Update of /cvsroot/super-tux/supertux/lib/video In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32238/lib/video Modified Files: drawing_context.cpp drawing_context.h font.cpp font.h screen.cpp screen.h surface.cpp surface.h Log Message: The SuperTux library features a SuperTux namespace now. + minor Bugfixes and cleanups Index: font.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/font.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- font.cpp 20 Jul 2004 17:51:39 -0000 1.1 +++ font.cpp 21 Jul 2004 16:51:53 -0000 1.2 @@ -27,6 +27,8 @@ #include "video/drawing_context.h" #include "utils/lispreader.h" +using namespace SuperTux; + Font::Font(const std::string& file, FontType ntype, int nw, int nh, int nshadowsize) : chars(0), shadow_chars(0), type(ntype), w(nw), h(nh), @@ -129,7 +131,7 @@ #define SCROLL 60 #define ITEMS_SPACE 4 -void display_text_file(const std::string& file, float scroll_speed) +void SuperTux::display_text_file(const std::string& file, float scroll_speed) { std::string text; std::vector<std::string> names; Index: drawing_context.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/drawing_context.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- drawing_context.cpp 20 Jul 2004 17:51:39 -0000 1.1 +++ drawing_context.cpp 21 Jul 2004 16:51:53 -0000 1.2 @@ -25,6 +25,8 @@ #include "app/globals.h" #include "video/font.h" +using namespace SuperTux; + DrawingContext::DrawingContext() { transform.draw_effect = NONE_EFFECT; Index: surface.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/surface.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- surface.h 20 Jul 2004 17:51:39 -0000 1.1 +++ surface.h 21 Jul 2004 16:51:53 -0000 1.2 @@ -30,148 +30,159 @@ #include "SDL.h" -#include "video/screen.h" #include "math/vector.h" +#include "video/screen.h" -SDL_Surface* sdl_surface_from_sdl_surface(SDL_Surface* sdl_surf, bool use_alpha); -SDL_Surface* sdl_surface_from_nothing(); - -class SurfaceImpl; -class SurfaceSDL; -class SurfaceOpenGL; -class DrawingContext; +namespace SuperTux + { + + SDL_Surface* sdl_surface_from_sdl_surface(SDL_Surface* sdl_surf, bool use_alpha); + SDL_Surface* sdl_surface_from_nothing(); -/// bitset for drawing effects -enum { - /** Don't apply anything */ - NONE_EFFECT = 0x0000, - /** Draw the Surface upside down */ - VERTICAL_FLIP = 0x0001, - /** Draw the Surface with alpha equal to 128 */ - SEMI_TRANSPARENT = 0x0002 + class SurfaceImpl; + class SurfaceSDL; + class SurfaceOpenGL; + class DrawingContext; + + /// bitset for drawing effects + enum { + /** Don't apply anything */ + NONE_EFFECT = 0x0000, + /** Draw the Surface upside down */ + VERTICAL_FLIP = 0x0001, + /** Draw the Surface with alpha equal to 128 */ + SEMI_TRANSPARENT = 0x0002 }; -/** This class holds all the data necessary to construct a surface */ -class SurfaceData -{ -public: - enum ConstructorType { LOAD, LOAD_PART, SURFACE, GRADIENT }; - ConstructorType type; - SDL_Surface* surface; - std::string file; - bool use_alpha; - int x; - int y; - int w; - int h; - Color top_gradient; - Color bottom_gradient; + /** This class holds all the data necessary to construct a surface */ + class SurfaceData + { + public: + enum ConstructorType { LOAD, LOAD_PART, SURFACE, GRADIENT }; + ConstructorType type; + SDL_Surface* surface; + std::string file; + bool use_alpha; + int x; + int y; + int w; + int h; + Color top_gradient; + Color bottom_gradient; - SurfaceData(SDL_Surface* surf, bool use_alpha_); - SurfaceData(const std::string& file_, bool use_alpha_); - SurfaceData(const std::string& file_, int x_, int y_, int w_, int h_, bool use_alpha_); - SurfaceData(Color top_gradient_, Color bottom_gradient_, int w_, int h_); - ~SurfaceData(); + SurfaceData(SDL_Surface* surf, bool use_alpha_); + SurfaceData(const std::string& file_, bool use_alpha_); + SurfaceData(const std::string& file_, int x_, int y_, int w_, int h_, bool use_alpha_); + SurfaceData(Color top_gradient_, Color bottom_gradient_, int w_, int h_); + ~SurfaceData(); - SurfaceSDL* create_SurfaceSDL(); - SurfaceOpenGL* create_SurfaceOpenGL(); - SurfaceImpl* create(); -}; + SurfaceSDL* create_SurfaceSDL(); + SurfaceOpenGL* create_SurfaceOpenGL(); + SurfaceImpl* create(); + }; -/** Container class that holds a surface, necessary so that we can - switch Surface implementations (OpenGL, SDL) on the fly */ -class Surface -{ -public: - SurfaceData data; - SurfaceImpl* impl; - int w; - int h; - - typedef std::list<Surface*> Surfaces; - static Surfaces surfaces; -public: - static void reload_all(); - static void debug_check(); - Surface(SDL_Surface* surf, bool use_alpha); - Surface(const std::string& file, bool use_alpha); - Surface(const std::string& file, int x, int y, int w, int h, bool use_alpha); - Surface(Color top_gradient, Color bottom_gradient, int w_, int h_); - ~Surface(); - - /** Reload the surface, which is necesarry in case of a mode swich */ - void reload(); + /// Surface + /** Container class that holds a surface, necessary so that we can + switch Surface implementations (OpenGL, SDL) on the fly */ + class Surface + { + public: + SurfaceData data; + SurfaceImpl* impl; + int w; + int h; - void resize(int widht, int height); -}; + typedef std::list<Surface*> Surfaces; + static Surfaces surfaces; + public: + static void reload_all(); + static void debug_check(); -/** Surface implementation, all implementation have to inherit from - this class */ -class SurfaceImpl -{ -protected: - SDL_Surface* sdl_surface; + Surface(SDL_Surface* surf, bool use_alpha); + Surface(const std::string& file, bool use_alpha); + Surface(const std::string& file, int x, int y, int w, int h, bool use_alpha); + Surface(Color top_gradient, Color bottom_gradient, int w_, int h_); + ~Surface(); -public: - int w; - int h; + /** Reload the surface, which is necesarry in case of a mode swich */ + void reload(); -public: - SurfaceImpl(); - virtual ~SurfaceImpl(); - - /** Return 0 on success, -2 if surface needs to be reloaded */ - virtual int draw(float x, float y, Uint8 alpha, Uint32 effect = NONE_EFFECT) = 0; - virtual int draw_part(float sx, float sy, float x, float y, float w, float h, Uint8 alpha, Uint32 effect = NONE_EFFECT) = 0; + void resize(int widht, int height); + }; + + /** Surface implementation, all implementation have to inherit from + this class */ + class SurfaceImpl + { + protected: + SDL_Surface* sdl_surface; + + public: + int w; + int h; + + public: + SurfaceImpl(); + virtual ~SurfaceImpl(); + + /** Return 0 on success, -2 if surface needs to be reloaded */ + virtual int draw(float x, float y, Uint8 alpha, Uint32 effect = NONE_EFFECT) = 0; + virtual int draw_part(float sx, float sy, float x, float y, float w, float h, Uint8 alpha, Uint32 effect = NONE_EFFECT) = 0; #if 0 - virtual int draw_stretched(float x, float y, int w, int h, Uint8 alpha, bool update) = 0; + + virtual int draw_stretched(float x, float y, int w, int h, Uint8 alpha, bool update) = 0; #endif - int resize(int w_, int h_); - SDL_Surface* get_sdl_surface() const; // @evil@ try to avoid this function -}; + int resize(int w_, int h_); -class SurfaceSDL : public SurfaceImpl -{ -public: - SurfaceSDL(SDL_Surface* surf, bool use_alpha); - SurfaceSDL(const std::string& file, bool use_alpha); - SurfaceSDL(const std::string& file, int x, int y, int w, int h, bool use_alpha); - SurfaceSDL(Color top_gradient, Color bottom_gradient, int w, int h); - virtual ~SurfaceSDL(); + SDL_Surface* get_sdl_surface() const; // @evil@ try to avoid this function + }; - int draw(float x, float y, Uint8 alpha, Uint32 effect = NONE_EFFECT); - int draw_part(float sx, float sy, float x, float y, float w, float h, Uint8 alpha, Uint32 effect = NONE_EFFECT); + class SurfaceSDL : public SurfaceImpl + { + public: + SurfaceSDL(SDL_Surface* surf, bool use_alpha); + SurfaceSDL(const std::string& file, bool use_alpha); + SurfaceSDL(const std::string& file, int x, int y, int w, int h, bool use_alpha); + SurfaceSDL(Color top_gradient, Color bottom_gradient, int w, int h); + virtual ~SurfaceSDL(); + + int draw(float x, float y, Uint8 alpha, Uint32 effect = NONE_EFFECT); + int draw_part(float sx, float sy, float x, float y, float w, float h, Uint8 alpha, Uint32 effect = NONE_EFFECT); #if 0 - int draw_stretched(float x, float y, int w, int h, Uint8 alpha); + + int draw_stretched(float x, float y, int w, int h, Uint8 alpha); #endif -}; + }; #ifndef NOOPENGL -class SurfaceOpenGL : public SurfaceImpl -{ -public: - GLuint gl_texture; + class SurfaceOpenGL : public SurfaceImpl + { + public: + GLuint gl_texture; -public: - SurfaceOpenGL(SDL_Surface* surf, bool use_alpha); - SurfaceOpenGL(const std::string& file, bool use_alpha); - SurfaceOpenGL(const std::string& file, int x, int y, int w, int h, bool use_alpha); - SurfaceOpenGL(Color top_gradient, Color bottom_gradient, int w, int h); + public: + SurfaceOpenGL(SDL_Surface* surf, bool use_alpha); + SurfaceOpenGL(const std::string& file, bool use_alpha); + SurfaceOpenGL(const std::string& file, int x, int y, int w, int h, bool use_alpha); + SurfaceOpenGL(Color top_gradient, Color bottom_gradient, int w, int h); - virtual ~SurfaceOpenGL(); + virtual ~SurfaceOpenGL(); - int draw(float x, float y, Uint8 alpha, Uint32 effect = NONE_EFFECT); - int draw_part(float sx, float sy, float x, float y, float w, float h, Uint8 alpha, Uint32 effect = NONE_EFFECT); + int draw(float x, float y, Uint8 alpha, Uint32 effect = NONE_EFFECT); + int draw_part(float sx, float sy, float x, float y, float w, float h, Uint8 alpha, Uint32 effect = NONE_EFFECT); #if 0 - int draw_stretched(float x, float y, int w, int h, Uint8 alpha); + + int draw_stretched(float x, float y, int w, int h, Uint8 alpha); #endif -private: - void create_gl(SDL_Surface * surf, GLuint * tex); -}; -#endif + private: + void create_gl(SDL_Surface * surf, GLuint * tex); + }; +#endif + +} //namespace SuperTux #endif /*SUPERTUX_TEXTURE_H*/ Index: font.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/font.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- font.h 20 Jul 2004 17:51:39 -0000 1.1 +++ font.h 21 Jul 2004 16:51:53 -0000 1.2 @@ -26,51 +26,56 @@ #include "video/surface.h" #include "math/vector.h" -/** Reads a text file (using LispReader, so it as to be in its formatting) - and displays it in a StarTrek fashion */ -void display_text_file(const std::string& file, float scroll_speed); +namespace SuperTux + { -/* Text type */ -class Font -{ -public: - /* Kinds of texts. */ - enum FontType { - TEXT, // images for all characters - NUM // only images for numbers - }; - - Font(const std::string& file, FontType type, int w, int h, int shadowsize=2); - ~Font(); + /** Reads a text file (using LispReader, so it as to be in its formatting) + and displays it in a StarTrek fashion */ + void display_text_file(const std::string& file, float scroll_speed); - /** returns the height of the font */ - float get_height() const; - /** returns the width of a given text. (Note that I won't add a normal - * get_width function here, as we might switch to variable width fonts in the - * future. - */ - float get_text_width(const std::string& text) const; + /* Text type */ + class Font + { + public: + /* Kinds of texts. */ + enum FontType { + TEXT, // images for all characters + NUM // only images for numbers + }; -private: - friend class DrawingContext; - - void draw(const std::string& text, const Vector& pos, - Uint32 drawing_effect = NONE_EFFECT); - void draw_chars(Surface* pchars, const std::string& text, - const Vector& position, Uint32 drawing_effect); + Font(const std::string& file, FontType type, int w, int h, int shadowsize=2); + ~Font(); - Surface* chars; - Surface* shadow_chars; - FontType type; - int w; - int h; - int shadowsize; + /** returns the height of the font */ + float get_height() const; + /** returns the width of a given text. (Note that I won't add a normal + * get_width function here, as we might switch to variable width fonts in the + * future. + */ + float get_text_width(const std::string& text) const; - /// the number of the first character that is represented in the font - int first_char; - /// the number of the last character that is represented in the font - int last_char; -}; + private: + friend class DrawingContext; + + void draw(const std::string& text, const Vector& pos, + Uint32 drawing_effect = NONE_EFFECT); + void draw_chars(Surface* pchars, const std::string& text, + const Vector& position, Uint32 drawing_effect); + + Surface* chars; + Surface* shadow_chars; + FontType type; + int w; + int h; + int shadowsize; + + /// the number of the first character that is represented in the font + int first_char; + /// the number of the last character that is represented in the font + int last_char; + }; + +} //namespace SuperTux #endif /*SUPERTUX_FONT_H*/ Index: surface.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/surface.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- surface.cpp 20 Jul 2004 17:51:39 -0000 1.1 +++ surface.cpp 21 Jul 2004 16:51:53 -0000 1.2 @@ -29,6 +29,8 @@ #include "app/globals.h" #include "app/setup.h" +using namespace SuperTux; + Surface::Surfaces Surface::surfaces; SurfaceData::SurfaceData(SDL_Surface* temp, bool use_alpha_) @@ -328,7 +330,7 @@ } SDL_Surface* -sdl_surface_from_sdl_surface(SDL_Surface* sdl_surf, bool use_alpha) +SuperTux::sdl_surface_from_sdl_surface(SDL_Surface* sdl_surf, bool use_alpha) { SDL_Surface* sdl_surface; Uint32 saved_flags; Index: drawing_context.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/drawing_context.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- drawing_context.h 20 Jul 2004 17:51:39 -0000 1.1 +++ drawing_context.h 21 Jul 2004 16:51:53 -0000 1.2 @@ -26,138 +26,148 @@ #include "math/vector.h" #include "video/screen.h" +#include "video/surface.h" -class Surface; -class Font; +namespace SuperTux + { -// some constants for predefined layer values -enum { - LAYER_BACKGROUND0 = -300, - LAYER_BACKGROUND1 = -200, - LAYER_BACKGROUNDTILES = -100, - LAYER_TILES = 0, - LAYER_OBJECTS = 100, - LAYER_FOREGROUNDTILES = 200, - LAYER_FOREGROUND0 = 300, - LAYER_FOREGROUND1 = 400, - LAYER_GUI = 500 -}; + class Surface; + class Font; -/** - * This class provides functions for drawing things on screen. It also - * maintains a stack of transforms that are applied to graphics. - */ -class DrawingContext -{ -public: - DrawingContext(); - ~DrawingContext(); + // some constants for predefined layer values + enum { + LAYER_BACKGROUND0 = -300, + LAYER_BACKGROUND1 = -200, + LAYER_BACKGROUNDTILES = -100, + LAYER_TILES = 0, + LAYER_OBJECTS = 100, + LAYER_FOREGROUNDTILES = 200, + LAYER_FOREGROUND0 = 300, + LAYER_FOREGROUND1 = 400, + LAYER_GUI = 500 + }; - /** Adds a drawing request for a surface into the request list */ - void draw_surface(const Surface* surface, const Vector& position, int layer, - Uint32 drawing_effect = NONE_EFFECT); - /** Adds a drawing request for part of a surface */ - void draw_surface_part(const Surface* surface, const Vector& source, - const Vector& size, const Vector& dest, int layer, - Uint32 drawing_effect = NONE_EFFECT); - /** draws a text */ - void draw_text(Font* font, const std::string& text, const Vector& position, - int layer, Uint32 drawing_effect = NONE_EFFECT); - /** draws aligned text */ - void draw_text_center(Font* font, const std::string& text, - const Vector& position, int layer, Uint32 drawing_effect = NONE_EFFECT); - /** draws a color gradient onto the whole screen */ - void draw_gradient(Color from, Color to, int layer); - /** fills a rectangle */ - void draw_filled_rect(const Vector& topleft, const Vector& size, - Color color, int layer); - - /** Processes all pending drawing requests and flushes the list */ - void do_drawing(); + /** + * This class provides functions for drawing things on screen. It also + * maintains a stack of transforms that are applied to graphics. + */ + class DrawingContext + { + public: + DrawingContext(); + ~DrawingContext(); - const Vector& get_translation() const - { return transform.translation; } - void set_translation(const Vector& newtranslation) - { transform.translation = newtranslation; } + /** Adds a drawing request for a surface into the request list */ + void draw_surface(const Surface* surface, const Vector& position, int layer, + Uint32 drawing_effect = NONE_EFFECT); + /** Adds a drawing request for part of a surface */ + void draw_surface_part(const Surface* surface, const Vector& source, + const Vector& size, const Vector& dest, int layer, + Uint32 drawing_effect = NONE_EFFECT); + /** draws a text */ + void draw_text(Font* font, const std::string& text, const Vector& position, + int layer, Uint32 drawing_effect = NONE_EFFECT); + /** draws aligned text */ + void draw_text_center(Font* font, const std::string& text, + const Vector& position, int layer, Uint32 drawing_effect = NONE_EFFECT); + /** draws a color gradient onto the whole screen */ + void draw_gradient(Color from, Color to, int layer); + /** fills a rectangle */ + void draw_filled_rect(const Vector& topleft, const Vector& size, + Color color, int layer); - void push_transform(); - void pop_transform(); + /** Processes all pending drawing requests and flushes the list */ + void do_drawing(); - /** apply that effect in the next draws (effects are listed on surface.h) */ - void set_drawing_effect(int effect); + const Vector& get_translation() const + { + return transform.translation; + } + void set_translation(const Vector& newtranslation) + { + transform.translation = newtranslation; + } -private: - class Transform - { - public: - Vector translation; // only translation for now... + void push_transform(); + void pop_transform(); - Vector apply(const Vector& v) const - { - return v - translation; - } + /** apply that effect in the next draws (effects are listed on surface.h) */ + void set_drawing_effect(int effect); - int draw_effect; - }; + private: + class Transform + { + public: + Vector translation; // only translation for now... - /// the transform stack - std::vector<Transform> transformstack; - /// the currently active transform - Transform transform; + Vector apply(const Vector& v) const + { + return v - translation; + } - enum RequestType - { - SURFACE, SURFACE_PART, TEXT, GRADIENT, FILLRECT - }; + int draw_effect; + }; - struct SurfacePartRequest - { - const Surface* surface; - Vector source, size; - }; + /// the transform stack + std::vector<Transform> transformstack; + /// the currently active transform + Transform transform; - struct TextRequest - { - Font* font; - std::string text; - }; + enum RequestType + { + SURFACE, SURFACE_PART, TEXT, GRADIENT, FILLRECT + }; - struct GradientRequest - { - Color top, bottom; - Vector size; - }; + struct SurfacePartRequest + { + const Surface* surface; + Vector source, size; + }; - struct FillRectRequest - { - Color color; - Vector size; - }; + struct TextRequest + { + Font* font; + std::string text; + }; - struct DrawingRequest - { - int layer; - Uint32 drawing_effect; + struct GradientRequest + { + Color top, bottom; + Vector size; + }; - RequestType type; - Vector pos; + struct FillRectRequest + { + Color color; + Vector size; + }; - void* request_data; + struct DrawingRequest + { + int layer; + Uint32 drawing_effect; - bool operator<(const DrawingRequest& other) const - { - return layer < other.layer; - } - }; + RequestType type; + Vector pos; - void draw_surface_part(DrawingRequest& request); - void draw_text(DrawingRequest& request); - void draw_gradient(DrawingRequest& request); - void draw_filled_rect(DrawingRequest& request); - - typedef std::vector<DrawingRequest> DrawingRequests; - DrawingRequests drawingrequests; -}; + void* request_data; + + bool operator<(const DrawingRequest& other) const + { + return layer < other.layer; + } + }; + + void draw_surface_part(DrawingRequest& request); + void draw_text(DrawingRequest& request); + void draw_gradient(DrawingRequest& request); + void draw_filled_rect(DrawingRequest& request); + + typedef std::vector<DrawingRequest> DrawingRequests; + DrawingRequests drawingrequests; + }; + +} //namespace SuperTux #endif /*SUPERTUX_DRAWINGCONTEXT_H*/ Index: screen.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/screen.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- screen.h 20 Jul 2004 17:51:39 -0000 1.1 +++ screen.h 21 Jul 2004 16:51:53 -0000 1.2 @@ -25,40 +25,49 @@ #include <SDL_opengl.h> #endif #include <iostream> -class Color -{ -public: - Color() - : red(0), green(0), blue(0), alpha(255) - {} - - Color(Uint8 red_, Uint8 green_, Uint8 blue_, Uint8 alpha_ = 255) - : red(red_), green(green_), blue(blue_), alpha(alpha_) - {} - Color(const Color& o) - : red(o.red), green(o.green), blue(o.blue), alpha(o.alpha) - { } +namespace SuperTux + { + + /// Color RGBA + /** Stores 8bit RGBA values. */ + class Color + { + public: + Color() + : red(0), green(0), blue(0), alpha(255) + {} - bool operator==(const Color& o) - { if(red == o.red && green == o.green && - blue == o.blue && alpha == o.alpha) - return true; - return false; } + Color(Uint8 red_, Uint8 green_, Uint8 blue_, Uint8 alpha_ = 255) + : red(red_), green(green_), blue(blue_), alpha(alpha_) + {} - Uint8 red, green, blue, alpha; -}; + Color(const Color& o) + : red(o.red), green(o.green), blue(o.blue), alpha(o.alpha) + { } -#include "video/surface.h" + bool operator==(const Color& o) + { + if(red == o.red && green == o.green && + blue == o.blue && alpha == o.alpha) + return true; + return false; + } -class Vector; + Uint8 red, green, blue, alpha; + }; -void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel); -void drawpixel(int x, int y, Uint32 pixel); -void fillrect(float x, float y, float w, float h, int r, int g, int b, int a = 255); -void draw_line(float x1, float y1, float x2, int r, int g, int b, int a = 255); -void fadeout(int fade_time); -void shrink_fade(const Vector& point, int fade_time); + class Vector; + + void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel); + void drawpixel(int x, int y, Uint32 pixel); + void fillrect(float x, float y, float w, float h, int r, int g, int b, int a = 255); + void draw_line(float x1, float y1, float x2, float y2, int r, int g, int b, int a = 255); + + void fadeout(int fade_time); + void shrink_fade(const Vector& point, int fade_time); + +} //namespace SuperTux #endif /*SUPERTUX_SCREEN_H*/ Index: screen.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/screen.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- screen.cpp 20 Jul 2004 17:51:39 -0000 1.1 +++ screen.cpp 21 Jul 2004 16:51:53 -0000 1.2 @@ -33,16 +33,19 @@ #include <ctype.h> #endif -#include "app/globals.h" #include "video/screen.h" +#include "app/globals.h" #include "video/drawing_context.h" #include "special/base.h" +#include "math/vector.h" + +using namespace SuperTux; /* 'Stolen' from the SDL documentation. * Set the pixel at (x, y) to the given value * NOTE: The surface must be locked before calling this! */ -void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel) +void SuperTux::putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel) { int bpp = surface->format->BytesPerPixel; /* Here p is the address to the pixel we want to set */ @@ -80,7 +83,7 @@ } /* Draw a single pixel on the screen. */ -void drawpixel(int x, int y, Uint32 pixel) +void SuperTux::drawpixel(int x, int y, Uint32 pixel) { /* Lock the screen for direct access to the pixels */ if ( SDL_MUSTLOCK(screen) ) @@ -105,7 +108,7 @@ /* --- FILL A RECT --- */ -void fillrect(float x, float y, float w, float h, int r, int g, int b, int a) +void SuperTux::fillrect(float x, float y, float w, float h, int r, int g, int b, int a) { if(w < 0) { @@ -179,8 +182,7 @@ #define SGN(x) ((x)>0 ? 1 : ((x)==0 ? 0:(-1))) #define ABS(x) ((x)>0 ? (x) : (-x)) -void -draw_line(float x1, float y1, float x2, float y2, int r, int g, int b, int a) +void SuperTux::draw_line(float x1, float y1, float x2, float y2, int r, int g, int b, int a) { #ifndef NOOPENGL if(use_gl) @@ -245,7 +247,7 @@ #define LOOP_DELAY 20.0 -void fadeout(int fade_time) +void SuperTux::fadeout(int fade_time) { float alpha_inc = 256 / (fade_time / LOOP_DELAY); float alpha = 256; @@ -269,7 +271,7 @@ context.do_drawing(); } -void shrink_fade(const Vector& point, int fade_time) +void SuperTux::shrink_fade(const Vector& point, int fade_time) { float left_inc = point.x / ((float)fade_time / LOOP_DELAY); float right_inc = (screen->w - point.x) / ((float)fade_time / LOOP_DELAY); |