Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages
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 <bit@eltech.ru> 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 00103 int PixelBytes; 00104 00109 void complete () 00110 { 00111 #define COMPUTE(comp) \ 00112 { \ 00113 unsigned long i, tmp = comp##Mask; \ 00114 for (i = 0; tmp && !(tmp & 1); tmp >>= 1, i++) {} \ 00115 comp##Shift = i; \ 00116 for (i = 0; tmp & 1; tmp >>= 1, i++) {} \ 00117 comp##Bits = i; \ 00118 } 00119 COMPUTE (Red); 00120 COMPUTE (Green); 00121 COMPUTE (Blue); 00122 COMPUTE (Alpha); 00123 #undef COMPUTE 00124 } 00125 }; 00126 00128 struct csImageArea 00129 { 00130 int x, y, w, h; 00131 char *data; 00132 00133 inline csImageArea (int sx, int sy, int sw, int sh) 00134 { x = sx; y = sy; w = sw; h = sh; data = 0; } 00135 }; 00136 00137 SCF_VERSION (iOffscreenCanvasCallback, 1, 0, 0); 00138 00144 struct iOffscreenCanvasCallback : public iBase 00145 { 00147 virtual void FinishDraw (iGraphics2D* canvas) = 0; 00149 virtual void SetRGB (iGraphics2D* canvas, int idx, int r, int g, int b) = 0; 00150 }; 00151 00179 struct iGraphics2D : public virtual iBase 00180 { 00181 SCF_INTERFACE (iGraphics2D, 3, 0, 0); 00182 00184 virtual bool Open () = 0; 00185 00187 virtual void Close () = 0; 00188 00190 virtual int GetWidth () = 0; 00191 00193 virtual int GetHeight () = 0; 00194 00196 virtual int GetPage () = 0; 00197 00199 virtual bool DoubleBuffer (bool Enable) = 0; 00200 00202 virtual bool GetDoubleBufferState () = 0; 00203 00205 virtual csPixelFormat const* GetPixelFormat () = 0; 00206 00212 virtual int GetPixelBytes () = 0; 00213 00221 virtual int GetPalEntryCount () = 0; 00222 00224 virtual csRGBpixel *GetPalette () = 0; 00225 00230 virtual void SetRGB (int i, int r, int g, int b) = 0; 00239 virtual int FindRGB (int r, int g, int b, int a = 255) = 0; 00240 00244 virtual void GetRGB (int color, int& r, int& g, int& b) = 0; 00248 virtual void GetRGB (int color, int& r, int& g, int& b, int& a) = 0; 00249 00255 virtual void SetClipRect (int nMinX, int nMinY, int nMaxX, int nMaxY) = 0; 00256 00258 virtual void GetClipRect(int& nMinX, int& nMinY, int& nMaxX, int& nMaxY) = 0; 00259 00264 virtual bool BeginDraw () = 0; 00265 00267 virtual void FinishDraw () = 0; 00268 00274 virtual void Print (csRect const* pArea) = 0; 00275 00277 virtual void Clear (int color) = 0; 00278 00280 virtual void ClearAll (int color) = 0; 00281 00283 virtual void DrawLine(float x1, float y1, float x2, float y2, int color) = 0; 00284 00286 virtual void DrawBox (int x, int y, int w, int h, int color) = 0; 00287 00292 virtual bool ClipLine (float& x1, float& y1, float& x2, float& y2, 00293 int xmin, int ymin, int xmax, int ymax) = 0; 00294 00296 virtual void DrawPixel (int x, int y, int color) = 0; 00297 00299 virtual void DrawPixels(csPixelCoord const* pixels, int num_pixels, 00300 int color) = 0; 00301 00303 virtual void Blit (int x, int y, int width, int height, 00304 unsigned char const* data) = 0; 00305 00307 virtual unsigned char *GetPixelAt (int x, int y) = 0; 00308 00310 virtual void GetPixel (int x, int y, uint8 &oR, uint8 &oG, uint8 &oB) = 0; 00312 virtual void GetPixel (int x, int y, uint8 &oR, uint8 &oG, uint8 &oB, uint8 &oA) = 0; 00313 00319 virtual csImageArea *SaveArea (int x, int y, int w, int h) = 0; 00320 00322 virtual void RestoreArea (csImageArea *Area, bool Free) = 0; 00323 00325 virtual void FreeArea (csImageArea *Area) = 0; 00326 00335 virtual void Write (iFont *font, int x, int y, int fg, int bg, 00336 const char *str, uint flags = 0) = 0; 00337 00345 CS_DEPRECATED_METHOD virtual void WriteBaseline (iFont *font, 00346 int x, int y, int fg, int bg, const char *str) = 0; 00347 00349 virtual void AllowResize (bool iAllow) = 0; 00350 00352 virtual bool Resize (int w, int h) = 0; 00353 00355 virtual iFontServer *GetFontServer () = 0; 00356 00364 virtual bool PerformExtension (char const* command, ...) = 0; 00365 00371 virtual bool PerformExtensionV (char const* command, va_list) = 0; 00372 00374 virtual csPtr<iImage> ScreenShot () = 0; 00375 00380 virtual iNativeWindow* GetNativeWindow () = 0; 00381 00383 virtual bool GetFullScreen () = 0; 00384 00388 virtual void SetFullScreen (bool b) = 0; 00389 00391 virtual bool SetMousePosition (int x, int y) = 0; 00392 00401 virtual bool SetMouseCursor (csMouseCursorID iShape) = 0; 00402 00410 virtual bool SetMouseCursor (iImage *image, const csRGBcolor* keycolor = 0, 00411 int hotspot_x = 0, int hotspot_y = 0, 00412 csRGBcolor fg = csRGBcolor(255,255,255), 00413 csRGBcolor bg = csRGBcolor(0,0,0)) = 0; 00414 00420 virtual bool SetGamma (float gamma) = 0; 00421 00425 virtual float GetGamma () const = 0; 00426 00435 virtual csPtr<iGraphics2D> CreateOffscreenCanvas ( 00436 void* memory, int width, int height, int depth, 00437 iOffscreenCanvasCallback* ofscb) = 0; 00438 }; 00439 00442 #endif // __CS_IVIDEO_GRAPH2D_H__ 00443
Generated for Crystal Space by doxygen 1.4.4