CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound 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 <stdarg.h>
00032 #include "csutil/scf.h"
00033 #include "csgfx/rgbpixel.h"
00034 #include "ivideo/texture.h"
00035 #include "iengine/texture.h"
00036 #include "ivideo/cursor.h"
00037 
00038 class csRect;
00039 struct iImage;
00040 struct iFontServer;
00041 struct iFont;
00042 struct iNativeWindow;
00043 struct iGraphics2D;
00044 
00046 struct csPixelCoord
00047 {
00049   int x;
00051   int y;
00052 };
00053 
00054 
00058 struct csPixelFormat
00059 {
00065   uint32 RedMask, GreenMask, BlueMask;
00070   int RedShift, GreenShift, BlueShift;
00072   int RedBits, GreenBits, BlueBits;
00073 
00080   int PalEntries;
00081 
00091   int PixelBytes;
00092 
00097   void complete ()
00098   {
00099 #define COMPUTE(comp)                                                   \
00100     {                                                                   \
00101       unsigned long i, tmp = comp##Mask;                                \
00102       for (i = 0; tmp && !(tmp & 1); tmp >>= 1, i++) {}                 \
00103       comp##Shift = i;                                                  \
00104       for (i = 0; tmp & 1; tmp >>= 1, i++) {}                           \
00105       comp##Bits = i;                                                   \
00106     }
00107     COMPUTE (Red);
00108     COMPUTE (Green);
00109     COMPUTE (Blue);
00110 #undef COMPUTE
00111   }
00112 };
00113 
00115 struct csImageArea
00116 {
00117   int x, y, w, h;
00118   char *data;
00119 
00120   inline csImageArea (int sx, int sy, int sw, int sh)
00121   { x = sx; y = sy; w = sw; h = sh; data = 0; }
00122 };
00123 
00124 SCF_VERSION (iOffscreenCanvasCallback, 1, 0, 0);
00125 
00131 struct iOffscreenCanvasCallback : public iBase
00132 {
00134   virtual void FinishDraw (iGraphics2D* canvas) = 0;
00136   virtual void SetRGB (iGraphics2D* canvas, int idx, int r, int g, int b) = 0;
00137 };
00138 
00139 SCF_VERSION (iGraphics2D, 2, 3, 1);
00140 
00146 struct iGraphics2D : public iBase
00147 {
00149   virtual bool Open () = 0;
00150 
00152   virtual void Close () = 0;
00153 
00155   virtual int GetWidth () = 0;
00156 
00158   virtual int GetHeight () = 0;
00159 
00161   virtual int GetPage () = 0;
00162 
00164   virtual bool DoubleBuffer (bool Enable) = 0;
00165 
00167   virtual bool GetDoubleBufferState () = 0;
00168 
00170   virtual csPixelFormat *GetPixelFormat () = 0;
00171 
00177   virtual int GetPixelBytes () = 0;
00178 
00186   virtual int GetPalEntryCount () = 0;
00187 
00189   virtual csRGBpixel *GetPalette () = 0;
00190 
00192   virtual void SetRGB (int i, int r, int g, int b) = 0;
00194   virtual int FindRGB (int r, int g, int b) = 0;
00195 
00201   virtual void SetClipRect (int nMinX, int nMinY, int nMaxX, int nMaxY) = 0;
00202 
00204   virtual void GetClipRect(int& nMinX, int& nMinY, int& nMaxX, int& nMaxY) = 0;
00205 
00210   virtual bool BeginDraw () = 0;
00211 
00213   virtual void FinishDraw () = 0;
00214 
00220   virtual void Print (csRect *pArea) = 0;
00221 
00223   virtual void Clear (int color) = 0;
00224 
00226   virtual void ClearAll (int color) = 0;
00227 
00229   virtual void DrawLine(float x1, float y1, float x2, float y2, int color) = 0;
00230 
00232   virtual void DrawBox (int x, int y, int w, int h, int color) = 0;
00233 
00238   virtual bool ClipLine (float& x1, float& y1, float& x2, float& y2,
00239     int xmin, int ymin, int xmax, int ymax) = 0;
00240 
00242   virtual void DrawPixel (int x, int y, int color) = 0;
00243 
00245   virtual void DrawPixels (csPixelCoord* pixels, int num_pixels, int color) = 0;
00246 
00248   virtual void Blit (int x, int y, int width, int height,
00249         unsigned char* data) = 0;
00250 
00252   virtual unsigned char *GetPixelAt (int x, int y) = 0;
00253 
00255   virtual void GetPixel (int x, int y, uint8 &oR, uint8 &oG, uint8 &oB) = 0;
00256 
00262   virtual csImageArea *SaveArea (int x, int y, int w, int h) = 0;
00263 
00265   virtual void RestoreArea (csImageArea *Area, bool Free) = 0;
00266 
00268   virtual void FreeArea (csImageArea *Area) = 0;
00269 
00274   virtual void Write (iFont *font, int x, int y, int fg, int bg,
00275     const char *str) = 0;
00276 
00282   virtual void WriteBaseline (iFont *font, int x, int y, int fg, int bg,
00283     const char *str) = 0;
00284 
00286   virtual void AllowResize (bool iAllow) = 0;
00287 
00289   virtual bool Resize (int w, int h) = 0;
00290 
00292   virtual iFontServer *GetFontServer () = 0;
00293 
00301   virtual bool PerformExtension (char const* command, ...) = 0;
00302 
00308   virtual bool PerformExtensionV (char const* command, va_list) = 0;
00309 
00311   virtual csPtr<iImage> ScreenShot () = 0;
00312 
00317   virtual iNativeWindow* GetNativeWindow () = 0;
00318 
00320   virtual bool GetFullScreen () = 0;
00321 
00325   virtual void SetFullScreen (bool b) = 0;
00326 
00328   virtual bool SetMousePosition (int x, int y) = 0;
00329 
00338   virtual bool SetMouseCursor (csMouseCursorID iShape) = 0;
00339 
00345   virtual bool SetGamma (float gamma) = 0;
00346 
00350   virtual float GetGamma () const = 0;
00351 
00360   virtual csPtr<iGraphics2D> CreateOffscreenCanvas (
00361         void* memory, int width, int height, int depth,
00362         iOffscreenCanvasCallback* ofscb) = 0;
00363 };
00364 
00367 #endif // __CS_IVIDEO_GRAPH2D_H__
00368 

Generated for Crystal Space by doxygen 1.2.14