1 /* -*- Mode: C++; c-basic-offset: 2; tab-width: 2; indent-tabs-mode: nil -*- 2 * 3 * Quadra, an action puzzle game 4 * Copyright (C) 1998-2000 Ludus Design 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 */ 20 21 #ifndef _HEADER_VIDEO 22 #define _HEADER_VIDEO 23 24 #include "SDL.h" 25 #include "clipable.h" 26 #include "palette.h" 27 #include "bitmap.h" 28 29 class Bitmap; 30 31 class Video_bitmap: public Clipable { 32 public: 33 Video_bitmap(int px, int py, int w, int h); 34 ~Video_bitmap(); 35 36 /* fills a rectangle at position 'x','y' of width 'w', height 'h' 37 and color 'color'. */ 38 void rect(const int x,const int y,const int w,const int h, 39 const int color) const; 40 41 /* empty rectangle at position 'x','y' of width 'w', height 'h' and 42 color 'color'. */ 43 void box(const int x,const int y,const int w,const int h, 44 const int color) const; 45 46 /* puts a pixel at position 'x','y' with color 'c' */ 47 void put_pel(const int x, const int y, const Byte c) const; 48 49 /* horizontal line starting from 'x','y', width 'w' and color 'c' */ 50 void hline(const int y, const int x, 51 const int w, const Byte c) const; 52 53 /* vertical line starting from 'x','y', height 'h' and color 'c' */ 54 void vline(const int x, const int y, 55 const int h, const Byte c) const; 56 57 void put_surface(SDL_Surface* surface, int dx, int dy) const; 58 void put_surface(SDL_Surface* surface, const SDL_Rect& _srcrect, int dx, int dy) const; 59 60 /* blits a Bitmap to position 'dx','dy' */ 61 void put_bitmap(const Bitmap& d, int dx, int dy) const; 62 63 private: 64 friend class Video; 65 66 void clip_dirty(int x, int y, int w, int h) const; 67 68 const int pos_x; 69 const int pos_y; 70 }; 71 72 class Video { 73 friend class Video_bitmap; 74 75 public: 76 Video(); 77 ~Video(); 78 79 void end_frame(); 80 void setpal(const Palette& p); 81 void snap_shot(int x, int y, int w, int h); 82 void toggle_fullscreen(); 83 void resize_event(int w, int h); surface()84 SDL_Surface* surface() const { 85 return offscreen; 86 } 87 void clone_palette(SDL_Surface* surface); 88 void transform_to_local(Uint16& x, Uint16& y); 89 90 Video_bitmap vb; 91 int need_paint; 92 Dword framecount; 93 94 private: 95 void SetVideoMode(); 96 void set_dirty(int x1, int y1, int x2, int y2); 97 void create_display(int w, int h); 98 void update_dirty_display(); 99 void update_sdl_display(); 100 101 bool newpal; 102 Palette pal; 103 int needsleep; 104 int lastticks; 105 bool fullscreen; 106 bool mDirtyEmpty; 107 int mDirtyX1; 108 int mDirtyY1; 109 int mDirtyX2; 110 int mDirtyY2; 111 SDL_Surface* display; // real SDL video surface 112 SDL_Surface* offscreen; // internal surface always in 640x480 113 Uint32* mHScaleDst2Src; // horizontal scaling conversion table (destination to source) 114 Uint32* mVScaleDst2Src; // vertical scaling conversion table (destination to source) 115 Uint32 mHScaleSrc2Dst[641]; // horizontal scaling conversion table (source to destination) 116 Uint32 mVScaleSrc2Dst[481]; // vertical scaling conversion table (source to destination) 117 }; 118 119 extern Video* video; 120 121 #endif 122