00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
00048
00049
00050
00051 class RenderSurface
00052 {
00053 public:
00054
00055
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
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
00081 virtual ~RenderSurface();
00082
00083
00084
00085
00086
00087
00089
00090
00091 virtual ECode BeginPainting() = 0;
00092
00094
00095
00096 virtual ECode EndPainting() = 0;
00097
00099
00100
00101
00102 virtual Texture *GetSurfaceAsTexture() = 0;
00103
00104
00105
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
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 virtual void CreateNativePalette(Pentagram::Palette* palette) = 0;
00149
00150
00151
00152
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
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00177
00178 virtual void Paint(Shape*s, uint32 frame, sint32 x, sint32 y, bool untformed_pal = false) = 0;
00179
00181
00182 virtual void PaintNoClip(Shape*s, uint32 frame, sint32 x, sint32 y, bool untformed_pal = false) = 0;
00183
00185
00186 virtual void PaintTranslucent(Shape* s, uint32 frame, sint32 x, sint32 y, bool untformed_pal = false) = 0;
00187
00189
00190 virtual void PaintMirrored(Shape* s, uint32 frame, sint32 x, sint32 y, bool trans = false, bool untformed_pal = false) = 0;
00191
00193
00194 virtual void PaintInvisible(Shape* s, uint32 frame, sint32 x, sint32 y, bool trans, bool mirrored, bool untformed_pal = false) = 0;
00195
00197
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
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
00209
00210
00211
00212
00213
00214
00215 virtual void DrawLine32(uint32 rgb, sint32 sx, sint32 sy, sint32 ex, sint32 ey) = 0;
00216
00217
00218
00219
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
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
00251 };
00252
00253 #endif