00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __IVIDEO_GRAPH2D_H__
00021 #define __IVIDEO_GRAPH2D_H__
00022
00023 #include <stdarg.h>
00024 #include "csutil/scf.h"
00025 #include "csgfx/rgbpixel.h"
00026 #include "ivideo/texture.h"
00027 #include "iengine/texture.h"
00028 #include "ivideo/cursor.h"
00029
00030 class csRect;
00031 struct iImage;
00032 struct iFontServer;
00033 struct iFont;
00034 struct iNativeWindow;
00035
00039 struct csPixelFormat
00040 {
00046 uint32 RedMask, GreenMask, BlueMask;
00051 int RedShift, GreenShift, BlueShift;
00053 int RedBits, GreenBits, BlueBits;
00054
00061 int PalEntries;
00062
00072 int PixelBytes;
00073
00078 void complete ()
00079 {
00080 #define COMPUTE(comp) \
00081 { \
00082 unsigned long i, tmp = comp##Mask; \
00083 for (i = 0; tmp && !(tmp & 1); tmp >>= 1, i++) {} \
00084 comp##Shift = i; \
00085 for (i = 0; tmp & 1; tmp >>= 1, i++) {} \
00086 comp##Bits = i; \
00087 }
00088 COMPUTE (Red);
00089 COMPUTE (Green);
00090 COMPUTE (Blue);
00091 #undef COMPUTE
00092 }
00093 };
00094
00096 struct csImageArea
00097 {
00098 int x, y, w, h;
00099 char *data;
00100
00101 inline csImageArea (int sx, int sy, int sw, int sh)
00102 { x = sx; y = sy; w = sw; h = sh; data = NULL; }
00103 };
00104
00105 SCF_VERSION (iGraphics2D, 2, 0, 2);
00106
00112 struct iGraphics2D : public iBase
00113 {
00115 virtual bool Open () = 0;
00116
00118 virtual void Close () = 0;
00119
00121 virtual int GetWidth () = 0;
00122
00124 virtual int GetHeight () = 0;
00125
00127 virtual int GetPage () = 0;
00128
00130 virtual bool DoubleBuffer (bool Enable) = 0;
00131
00133 virtual bool GetDoubleBufferState () = 0;
00134
00136 virtual csPixelFormat *GetPixelFormat () = 0;
00137
00143 virtual int GetPixelBytes () = 0;
00144
00152 virtual int GetPalEntryCount () = 0;
00153
00155 virtual csRGBpixel *GetPalette () = 0;
00156
00158 virtual void SetRGB (int i, int r, int g, int b) = 0;
00159
00161 virtual void SetClipRect (int nMinX, int nMinY, int nMaxX, int nMaxY) = 0;
00162
00164 virtual void GetClipRect(int& nMinX, int& nMinY, int& nMaxX, int& nMaxY) = 0;
00165
00170 virtual bool BeginDraw () = 0;
00171
00173 virtual void FinishDraw () = 0;
00174
00180 virtual void Print (csRect *pArea) = 0;
00181
00183 virtual void Clear (int color) = 0;
00184
00186 virtual void ClearAll (int color) = 0;
00187
00189 virtual void DrawLine(float x1, float y1, float x2, float y2, int color) = 0;
00190
00192 virtual void DrawBox (int x, int y, int w, int h, int color) = 0;
00193
00198 virtual bool ClipLine (float& x1, float& y1, float& x2, float& y2,
00199 int xmin, int ymin, int xmax, int ymax) = 0;
00200
00202 virtual void DrawPixel (int x, int y, int color) = 0;
00203
00205 virtual unsigned char *GetPixelAt (int x, int y) = 0;
00206
00208 virtual void GetPixel (int x, int y, uint8 &oR, uint8 &oG, uint8 &oB) = 0;
00209
00215 virtual csImageArea *SaveArea (int x, int y, int w, int h) = 0;
00216
00218 virtual void RestoreArea (csImageArea *Area, bool Free) = 0;
00219
00221 virtual void FreeArea (csImageArea *Area) = 0;
00222
00227 virtual void Write (iFont *font, int x, int y, int fg, int bg,
00228 const char *str) = 0;
00229
00234 virtual void WriteBaseline (iFont *font, int x, int y, int fg, int bg,
00235 const char *str) = 0;
00236
00238 virtual void AllowResize (bool iAllow) = 0;
00239
00241 virtual bool Resize (int w, int h) = 0;
00242
00244 virtual iFontServer *GetFontServer () = 0;
00245
00253 virtual bool PerformExtension (char const* command, ...)
00254 CS_GNUC_PRINTF (2, 3) = 0;
00255
00261 virtual bool PerformExtensionV (char const* command, va_list)
00262 CS_GNUC_PRINTF (2, 0) = 0;
00263
00265 virtual iImage *ScreenShot () = 0;
00266
00268 virtual iGraphics2D *CreateOffScreenCanvas (int width, int height,
00269 void *buffer, bool alone_hint, csPixelFormat *ipfmt,
00270 csRGBpixel *palette = NULL, int pal_size = 0) = 0;
00271
00276 virtual iNativeWindow* GetNativeWindow () = 0;
00277
00279 virtual bool GetFullScreen () = 0;
00280
00284 virtual void SetFullScreen (bool b) = 0;
00285
00287 virtual bool SetMousePosition (int x, int y) = 0;
00288
00297 virtual bool SetMouseCursor (csMouseCursorID iShape) = 0;
00298
00299 };
00300
00301 #endif // __IVIDEO_GRAPH2D_H__
00302