ivideo/graph2d.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 2001 by Jorrit Tyberghein 00003 Copyright (C) 1998-2000 by Andrew Zabolotny <[email protected]> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 */ 00019 00020 #ifndef __CS_IVIDEO_GRAPH2D_H__ 00021 #define __CS_IVIDEO_GRAPH2D_H__ 00022 00031 #include "csutil/scf.h" 00032 #include "csgfx/rgbpixel.h" 00033 #include "ivideo/cursor.h" 00034 00035 00036 struct iImage; 00037 struct iFontServer; 00038 struct iFont; 00039 struct iNativeWindow; 00040 struct iGraphics2D; 00041 00042 class csRect; 00043 00045 enum 00046 { 00051 CS_WRITE_BASELINE = (1 << 0), 00055 CS_WRITE_NOANTIALIAS = (1 << 1) 00056 }; 00057 00059 struct csPixelCoord 00060 { 00062 int x; 00064 int y; 00065 }; 00066 00070 struct csPixelFormat 00071 { 00077 uint32 RedMask, GreenMask, BlueMask, AlphaMask; 00082 int RedShift, GreenShift, BlueShift, AlphaShift; 00084 int RedBits, GreenBits, BlueBits, AlphaBits; 00085 00092 int PalEntries; 00093 00101 int PixelBytes; 00102 00107 void complete () 00108 { 00109 #define COMPUTE(comp) \ 00110 { \ 00111 unsigned long i, tmp = comp##Mask; \ 00112 for (i = 0; tmp && !(tmp & 1); tmp >>= 1, i++) {} \ 00113 comp##Shift = i; \ 00114 for (i = 0; tmp & 1; tmp >>= 1, i++) {} \ 00115 comp##Bits = i; \ 00116 } 00117 COMPUTE (Red); 00118 COMPUTE (Green); 00119 COMPUTE (Blue); 00120 COMPUTE (Alpha); 00121 #undef COMPUTE 00122 } 00123 }; 00124 00126 struct csImageArea 00127 { 00128 int x, y, w, h; 00129 char *data; 00130 00131 inline csImageArea (int sx, int sy, int sw, int sh) 00132 { x = sx; y = sy; w = sw; h = sh; data = 0; } 00133 }; 00134 00135 SCF_VERSION (iOffscreenCanvasCallback, 1, 0, 0); 00136 00142 struct iOffscreenCanvasCallback : public iBase 00143 { 00145 virtual void FinishDraw (iGraphics2D* canvas) = 0; 00147 virtual void SetRGB (iGraphics2D* canvas, int idx, int r, int g, int b) = 0; 00148 }; 00149 00173 struct iGraphics2D : public virtual iBase 00174 { 00175 SCF_INTERFACE (iGraphics2D, 3, 0, 1); 00176 00178 virtual bool Open () = 0; 00179 00181 virtual void Close () = 0; 00182 00184 virtual int GetWidth () = 0; 00185 00187 virtual int GetHeight () = 0; 00188 00190 virtual int GetPage () = 0; 00191 00193 virtual bool DoubleBuffer (bool Enable) = 0; 00194 00196 virtual bool GetDoubleBufferState () = 0; 00197 00199 virtual csPixelFormat const* GetPixelFormat () = 0; 00200 00206 virtual int GetPixelBytes () = 0; 00207 00215 virtual int GetPalEntryCount () = 0; 00216 00218 virtual csRGBpixel *GetPalette () = 0; 00219 00224 virtual void SetRGB (int i, int r, int g, int b) = 0; 00233 virtual int FindRGB (int r, int g, int b, int a = 255) = 0; 00234 00238 virtual void GetRGB (int color, int& r, int& g, int& b) = 0; 00242 virtual void GetRGB (int color, int& r, int& g, int& b, int& a) = 0; 00243 00249 virtual void SetClipRect (int nMinX, int nMinY, int nMaxX, int nMaxY) = 0; 00250 00252 virtual void GetClipRect(int& nMinX, int& nMinY, int& nMaxX, int& nMaxY) = 0; 00253 00258 virtual bool BeginDraw () = 0; 00259 00261 virtual void FinishDraw () = 0; 00262 00268 virtual void Print (csRect const* pArea) = 0; 00269 00271 virtual void Clear (int color) = 0; 00272 00274 virtual void ClearAll (int color) = 0; 00275 00277 virtual void DrawLine(float x1, float y1, float x2, float y2, int color) = 0; 00278 00280 virtual void DrawBox (int x, int y, int w, int h, int color) = 0; 00281 00286 virtual bool ClipLine (float& x1, float& y1, float& x2, float& y2, 00287 int xmin, int ymin, int xmax, int ymax) = 0; 00288 00290 virtual void DrawPixel (int x, int y, int color) = 0; 00291 00293 virtual void DrawPixels(csPixelCoord const* pixels, int num_pixels, 00294 int color) = 0; 00295 00297 virtual void Blit (int x, int y, int width, int height, 00298 unsigned char const* data) = 0; 00299 00301 virtual unsigned char *GetPixelAt (int x, int y) = 0; 00302 00304 virtual void GetPixel (int x, int y, uint8 &oR, uint8 &oG, uint8 &oB) = 0; 00306 virtual void GetPixel (int x, int y, uint8 &oR, uint8 &oG, uint8 &oB, 00307 uint8 &oA) = 0; 00308 00314 virtual csImageArea *SaveArea (int x, int y, int w, int h) = 0; 00315 00317 virtual void RestoreArea (csImageArea *Area, bool Free) = 0; 00318 00320 virtual void FreeArea (csImageArea *Area) = 0; 00321 00330 virtual void Write (iFont *font, int x, int y, int fg, int bg, 00331 const char *str, uint flags = 0) = 0; 00332 00340 CS_DEPRECATED_METHOD_MSG("Use Write() with CS_WRITE_BASELINE flag instead") 00341 virtual void WriteBaseline (iFont *font, 00342 int x, int y, int fg, int bg, const char *str) = 0; 00343 00345 virtual void AllowResize (bool iAllow) = 0; 00346 00348 virtual bool Resize (int w, int h) = 0; 00349 00351 virtual iFontServer *GetFontServer () = 0; 00352 00360 virtual bool PerformExtension (char const* command, ...) = 0; 00361 00367 virtual bool PerformExtensionV (char const* command, va_list) = 0; 00368 00370 virtual csPtr<iImage> ScreenShot () = 0; 00371 00376 virtual iNativeWindow* GetNativeWindow () = 0; 00377 00379 virtual bool GetFullScreen () = 0; 00380 00384 virtual void SetFullScreen (bool b) = 0; 00385 00387 virtual bool SetMousePosition (int x, int y) = 0; 00388 00397 virtual bool SetMouseCursor (csMouseCursorID iShape) = 0; 00398 00406 virtual bool SetMouseCursor (iImage *image, const csRGBcolor* keycolor = 0, 00407 int hotspot_x = 0, int hotspot_y = 0, 00408 csRGBcolor fg = csRGBcolor(255,255,255), 00409 csRGBcolor bg = csRGBcolor(0,0,0)) = 0; 00410 00416 virtual bool SetGamma (float gamma) = 0; 00417 00421 virtual float GetGamma () const = 0; 00422 00426 virtual const char* GetName () const = 0; 00427 00436 virtual csPtr<iGraphics2D> CreateOffscreenCanvas ( 00437 void* memory, int width, int height, int depth, 00438 iOffscreenCanvasCallback* ofscb) = 0; 00439 00447 virtual void Write (iFont *font, int x, int y, int fg, int bg, 00448 const wchar_t* str, uint flags = 0) = 0; 00449 00450 }; 00451 00454 #endif // __CS_IVIDEO_GRAPH2D_H__ 00455
Generated for Crystal Space by doxygen 1.4.7