RenderSurface.h

Go to the documentation of this file.
00001 /*
00002 RenderSurface.h : RenderSurface Interface header
00003 
00004 Copyright (C) 2002-2004 The Pentagram Team
00005 
00006 This program is free software; you can redistribute it and/or
00007 modify it under the terms of the GNU General Public License
00008 as published by the Free Software Foundation; either version 2
00009 of the License, or (at your option) any later version.
00010 
00011 This program is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 GNU General Public License for more details.
00015 
00016 You should have received a copy of the GNU General Public License
00017 along with this program; if not, write to the Free Software
00018 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 */
00020 
00021 #ifndef RENDERSURFACE_H
00022 #define RENDERSURFACE_H
00023 
00024 #include "GraphicsErrors.h"
00025 
00026 struct Texture;
00027 class Shape;
00028 class ShapeFont;
00029 struct FixedWidthFont;
00030 
00031 namespace Pentagram
00032 {
00033         struct Palette;
00034         struct Rect;
00035         class Scaler;
00036 }
00037 
00038 #define UNPACK_RGB8(pix,r,g,b) { r = (((pix)&RenderSurface::format.r_mask)>>RenderSurface::format.r_shift)<<RenderSurface::format.r_loss; g = (((pix)&RenderSurface::format.g_mask)>>RenderSurface::format.g_shift)<<RenderSurface::format.g_loss; b = (((pix)&RenderSurface::format.b_mask)>>RenderSurface::format.b_shift)<<RenderSurface::format.b_loss; }
00039 #define PACK_RGB8(r,g,b) ((((r)>>RenderSurface::format.r_loss)<<RenderSurface::format.r_shift) | (((g)>>RenderSurface::format.g_loss)<<RenderSurface::format.g_shift) | (((b)>>RenderSurface::format.b_loss)<<RenderSurface::format.b_shift))
00040 #define PACK_RGB16(r,g,b) ((((r)>>RenderSurface::format.r_loss16)<<RenderSurface::format.r_shift) | (((g)>>RenderSurface::format.g_loss16)<<RenderSurface::format.g_shift) | (((b)>>RenderSurface::format.b_loss16)<<RenderSurface::format.b_shift))
00041 
00042 #define UNPACK_RGBA8(pix,r,g,b,a) { r = (((pix)&RenderSurface::format.r_mask)>>RenderSurface::format.r_shift)<<RenderSurface::format.r_loss; g = (((pix)&RenderSurface::format.g_mask)>>RenderSurface::format.g_shift)<<RenderSurface::format.g_loss; b = (((pix)&RenderSurface::format.b_mask)>>RenderSurface::format.b_shift)<<RenderSurface::format.b_loss; ; a = (((pix)&RenderSurface::format.a_mask)>>RenderSurface::format.a_shift)<<RenderSurface::format.a_loss; }
00043 #define PACK_RGBA8(r,g,b,a) ((((r)>>RenderSurface::format.r_loss)<<RenderSurface::format.r_shift) | (((g)>>RenderSurface::format.g_loss)<<RenderSurface::format.g_shift) | (((b)>>RenderSurface::format.b_loss)<<RenderSurface::format.b_shift) | (((a)>>RenderSurface::format.a_loss)<<RenderSurface::format.a_shift))
00044 #define PACK_RGBA16(r,g,b,a) ((((r)>>RenderSurface::format.r_loss16)<<RenderSurface::format.r_shift) | (((g)>>RenderSurface::format.g_loss16)<<RenderSurface::format.g_shift) | (((b)>>RenderSurface::format.b_loss16)<<RenderSurface::format.b_shift) | (((a)>>RenderSurface::format.a_loss16)<<RenderSurface::format.a_shift))
00045 
00046 //
00047 // RenderSurface
00048 //
00049 // Desc: The base abstact class for rendering in Pentagram
00050 //
00051 class RenderSurface
00052 {
00053 public:
00054 
00055         // Colour shifting values (should these all be uint32???)
00056         struct Format
00057         {
00058                 uint32  s_bpp,    s_bytes_per_pixel;
00059                 uint32  r_loss,   g_loss,   b_loss,   a_loss;
00060                 uint32  r_loss16, g_loss16, b_loss16, a_loss16;
00061                 uint32  r_shift,  g_shift,  b_shift,  a_shift;
00062                 uint32  r_mask,   g_mask,   b_mask,   a_mask;
00063         };
00064 
00065         static Format format;
00066 
00067         static uint8 Gamma10toGamma22[256];
00068         static uint8 Gamma22toGamma10[256];
00069 
00070         //
00071         // TODO: Improve the way SDL Surfaces are created. Should be more versatile.
00072         //
00073 
00075         static RenderSurface *SetVideoMode(uint32 width, uint32 height, uint32 bpp, bool fullscreen, bool use_opengl);
00076 
00078         static RenderSurface *CreateSecondaryRenderSurface(uint32 width, uint32 height);
00079 
00080         // Virtual Destructor
00081         virtual ~RenderSurface();
00082 
00083 
00084         //
00085         // Being/End Painting
00086         //
00087 
00089         // \note Can be called multiple times
00090         // \return Error Code on error. Check return code.....
00091         virtual ECode BeginPainting() = 0;
00092 
00094         // \note MUST BE CALLED FOR EACH CALL TO BeginPainting()
00095         // \return Error Code on error. Check return code.....
00096         virtual ECode EndPainting() = 0;
00097 
00099         // \note Do not delete the texture. 
00100         // \note Do not assume anything about the contents of the Texture object.
00101         // \note It should only be used with Painting and Blitting methods.
00102         virtual Texture *GetSurfaceAsTexture() = 0;
00103 
00104         //
00105         // Surface Properties
00106         //
00107 
00109         virtual void SetOrigin(sint32 x, sint32 y) = 0;
00110 
00112         virtual void GetOrigin(sint32 &x, sint32 &y) const = 0;
00113 
00115         virtual void GetSurfaceDims(Pentagram::Rect &) const = 0;
00116 
00118         virtual void GetClippingRect(Pentagram::Rect &) const = 0;
00119 
00121         virtual void SetClippingRect(const Pentagram::Rect &) = 0;
00122 
00124         virtual sint16 CheckClipped(const Pentagram::Rect &) const = 0;
00125 
00127         virtual void SetFlipped(bool flipped) = 0;
00128 
00130         virtual bool IsFlipped() const = 0;
00131 
00132 
00133         //
00134         // Surface Palettes
00135         //
00136         // TODO: Handle Ultima8 and Crusader Xforms
00137         //
00138 
00139         // Set The Surface Palette
00140         // virtual void SetPalette(uint8 palette[768]) = 0;
00141 
00142         // Set The Surface Palette to be the one used by another surface
00143         // TODO: virtual void SetPalette(RenderSurface &) = 0;
00144 
00145         // Get The Surface Palette
00146         // TODO: virtual void GetPalette(uint8 palette[768]) = 0;
00147 
00148         virtual void CreateNativePalette(Pentagram::Palette* palette) = 0;
00149 
00150 
00151         //
00152         // Surface Filling
00153         //
00154 
00156         virtual void Fill8(uint8 index, sint32 sx, sint32 sy, sint32 w, sint32 h) = 0;
00157 
00159         virtual void Fill32(uint32 rgb, sint32 sx, sint32 sy, sint32 w, sint32 h) = 0;
00160 
00162         virtual void FillAlpha(uint8 alpha, sint32 sx, sint32 sy, sint32 w, sint32 h) = 0;
00163 
00164         //
00165         // The rule for painting methods:
00166         //
00167         // First arg are the source object to 'draw' with
00168         // Next args are any other required data to define the 'source'
00169         // Next args are the destination position
00170         //
00171 
00172         //
00173         // Basic Shape Painting
00174         //
00175 
00177         // TODO: virtual void Paint(CachedShape* s, uint32 frame, sint32 x, sint32 y) = 0;
00178         virtual void Paint(Shape*s, uint32 frame, sint32 x, sint32 y, bool untformed_pal = false) = 0;
00179 
00181         // TODO: virtual void PaintNoClip(CachedShape*s, uint32 frame, sint32 x, sint32 y) = 0;
00182         virtual void PaintNoClip(Shape*s, uint32 frame, sint32 x, sint32 y, bool untformed_pal = false) = 0;
00183 
00185         // TODO: virtual void PaintTranslucent(CachedShape* s, uint32 frame, sint32 x, sint32 y) = 0;
00186         virtual void PaintTranslucent(Shape* s, uint32 frame, sint32 x, sint32 y, bool untformed_pal = false) = 0;
00187 
00189         // TODO: virtual void PaintMirrored(CachedShape* s, uint32 frame, sint32 x, sint32 y, bool trans = false) = 0;
00190         virtual void PaintMirrored(Shape* s, uint32 frame, sint32 x, sint32 y, bool trans = false, bool untformed_pal = false) = 0;
00191 
00193         // TODO: virtual void PaintInvisible(CachedShape* s, uint32 frame, sint32 x, sint32 y, bool trans, bool mirrored) = 0;
00194         virtual void PaintInvisible(Shape* s, uint32 frame, sint32 x, sint32 y, bool trans, bool mirrored, bool untformed_pal = false) = 0;
00195 
00197         // TODO: virtual void PaintHighlight(CachedShape* s, uint32 frame, sint32 x, sint32 y, bool trans, bool mirrored, uint32 col32);
00198         virtual void PaintHighlight(Shape* s, uint32 frame, sint32 x, sint32 y, bool trans, bool mirrored, uint32 col32, bool untformed_pal = false) = 0;
00199 
00201         // TODO: virtual void PaintHighlightInvis(CachedShape* s, uint32 frame, sint32 x, sint32 y, bool trans, bool mirrored, uint32 col32);
00202         virtual void PaintHighlightInvis(Shape* s, uint32 frame, sint32 x, sint32 y, bool trans, bool mirrored, uint32 col32, bool untformed_pal = false) = 0;
00203 
00205         virtual void PaintMasked(Shape* s, uint32 framenum, sint32 x, sint32 y, bool trans = false, bool mirrored = false, uint32 col32=0, bool untformed_pal = false) = 0;
00206 
00207         //
00208         // Basic Line Drawing
00209         //
00210         
00211         // Draw a Line (using a palette index)
00212         // TODO: virtual void DrawLine8(uint8 index, sint32 sx, sint32 sy, sint32 ex, sint32 ey) = 0;
00213 
00214         // Draw a RGB Line
00215         virtual void DrawLine32(uint32 rgb, sint32 sx, sint32 sy, sint32 ex, sint32 ey) = 0;
00216 
00217 
00218         //
00219         // Basic Font Drawing
00220         //
00222         virtual void PrintTextFixed(FixedWidthFont *, const char *text, int x, int y) = 0;
00223 
00225         virtual void PrintCharFixed(FixedWidthFont *, int character, int x, int y) = 0;
00226 
00227 
00228         //
00229         // Basic Texture Blitting
00230         //
00231 
00233         virtual void Blit(Texture *, sint32 sx, sint32 sy, sint32 w, sint32 h, sint32 dx, sint32 dy, bool alpha_blend=false) = 0;
00234 
00236         virtual void FadedBlit(Texture *, sint32 sx, sint32 sy, sint32 w, sint32 h, sint32 dx, sint32 dy, uint32 col32, bool alpha_blend=false) = 0;
00237 
00239         virtual void MaskedBlit(Texture *, sint32 sx, sint32 sy, sint32 w, sint32 h, sint32 dx, sint32 dy, uint32 col32, bool alpha_blend=false) = 0;
00240 
00242         virtual void StretchBlit(Texture *, sint32 sx, sint32 sy, sint32 sw, sint32 sh, sint32 dx, sint32 dy, sint32 dw, sint32 dh, bool bilinear = false, bool clampedges = false) = 0;
00243 
00245         virtual bool ScalerBlit(Texture *, sint32 sx, sint32 sy, sint32 sw, sint32 sh, sint32 dx, sint32 dy, sint32 dw, sint32 dh, const Pentagram::Scaler *, bool clampedges = false) = 0;
00246 
00247 
00249         // TODO: Add in Abstract 3d code Here //
00251 };
00252 
00253 #endif

Generated on Fri Jul 27 22:27:32 2007 for pentagram by  doxygen 1.4.7