home *** CD-ROM | disk | FTP | other *** search
/ Computer Panoráma / computer_panorama_1997-12-hibas.iso / SHARE / GRAPH / PTC051.ZIP / SRC / IFACE.H < prev    next >
C/C++ Source or Header  |  1997-09-22  |  8KB  |  208 lines

  1. //////////////////////
  2. // device interface //
  3. //////////////////////
  4.  
  5. #ifndef __INTERFACE_H
  6. #define __INTERFACE_H
  7.  
  8. #include "lang.h"
  9. #include "misc.h"
  10. #include "list.h"
  11. #include "rect.h"
  12. #include "color.h"
  13. #include "config.h"
  14. #include "format.h"
  15. #include "native.h"
  16. #include "convert.h"
  17. #include "effects.h"
  18. #include "globals.h"
  19. #include "palette.h"
  20. #include "classes.h"
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28. // surface "handle"
  29. typedef void* HSURFACE;
  30.  
  31. // surface information struct
  32. struct SURFACEINFO
  33. {
  34.     int type;                      // type of surface
  35.     int height;                    // height of surface
  36.     int width;                     // width of surface
  37.     int layout;                    // memory layout
  38.     int advance;                   // surface line advance
  39.     int area;                      // area of surface (pixels)
  40.     int size;                      // size of surface (bytes)
  41.     FORMAT format;                 // surface format
  42. };
  43.  
  44.  
  45. // interface info
  46. struct INFO
  47. {  
  48.     // name
  49.     char name[8];                  // interface name
  50.     
  51.     // surfaces
  52.     uint system     : 1;           // interface allows system surfaces
  53.     uint video      : 1;           // interface allows video surfaces
  54.     uint primary    : 1;           // interface allows primary surface manipulation
  55.     
  56.     // layouts
  57.     uint linear     : 1;           // interface is capable of setting modes with linear layout
  58.     uint banked     : 1;           // interface is capable of setting modes with banked layout
  59.     uint planar     : 1;           // interface is capable of setting modes with planar layout
  60.     uint fakemode   : 1;           // interface is capable of setting modes with fakemode layout
  61.  
  62.     // output
  63.     uint fullscreen : 1;           // interface is capable of fullscreen output
  64.     uint windowed   : 1;           // interface is capable of windowed output
  65.  
  66.     // modeset
  67.     uint frequency  : 1;           // interface is able to work with mode refresh frequency
  68.     
  69.     // acceleration
  70.     uint clear      : 1;           // interface is capable of hardware accelerated clears
  71.     uint bitblt     : 1;           // interface is capable of hardware accelerated bitblt
  72.     uint stretchblt : 1;           // interface is capable of hardware accelerated stretchblt
  73. };  
  74.  
  75.  
  76. // mode info
  77. struct MODE
  78. {
  79.     char i[8];                     // interface name
  80.     int x;                         // x resolution
  81.     int y;                         // y resolution
  82.     FORMAT format;                 // pixel format
  83.     int layout;                    // memory layout
  84.     int output;                    // output method
  85.     int frequency;                 // video refresh frequency
  86. };
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95. class Interface
  96. {
  97.     // friend classes
  98.     friend class Surface;
  99.  
  100.     public:
  101.  
  102.         //  virtual destructor
  103.         virtual ~Interface() {};
  104.  
  105.         // interface information
  106.         virtual INFO GetInfo()                        = 0;
  107.         virtual int GetModeList(List<MODE> &modelist) = 0;
  108.  
  109.         // display mode routines
  110.         virtual int SetMode(MODE const &info)                                                       = 0;
  111.         virtual int SetMode(int x,int y,int id,int layout,int output,int frequency)                 = 0;
  112.         virtual int SetMode(int x,int y,FORMAT const &format,int layout,int output,int frequency)   = 0;
  113.         virtual int QueryMode(MODE const &info)                                                     = 0;
  114.         virtual int QueryMode(int x,int y,int id,int layout,int output,int frequency)               = 0;
  115.         virtual int QueryMode(int x,int y,FORMAT const &format,int layout,int output,int frequency) = 0;
  116.         virtual MODE GetMode()                                                                      = 0;
  117.  
  118.         // palette routines
  119.         virtual int SetPalette(Palette &palette) = 0;
  120.         virtual int GetPalette(Palette &palette) = 0;
  121.         
  122.         // hardware functions
  123.         virtual int WaitForRetrace() = 0;
  124.         virtual int SaveState()      = 0;
  125.         virtual int RestoreState()   = 0;
  126.         
  127.         // primary surface operations
  128.         virtual int SetPrimary(Surface &surface) = 0;
  129.         virtual Surface* GetPrimary()            = 0;
  130.         virtual int SetOrigin(int x,int y)       = 0;
  131.         virtual int GetOrigin(int &x,int &y)     = 0;
  132.  
  133.         // video memory management
  134.         virtual int GetTotalVideoMemory() = 0;
  135.         virtual int GetFreeVideoMemory()  = 0;
  136.         virtual int CompactVideoMemory()  = 0;
  137.  
  138.         // console routines
  139.         virtual int getch()          = 0;
  140.         virtual int kbhit()          = 0;
  141.         virtual int keydown(int key) = 0;
  142.  
  143.         // native access
  144.         virtual void* GetNative() = 0;
  145.         virtual int NativeType()  = 0;
  146.  
  147.         // data access
  148.         virtual void GetName(char name[]) const = 0;
  149.         virtual int GetXResolution() const      = 0;
  150.         virtual int GetYResolution() const      = 0;
  151.         virtual int GetBitsPerPixel() const     = 0;
  152.         virtual int GetBytesPerPixel() const    = 0;
  153.         virtual int GetLayout() const           = 0;
  154.         virtual int GetOutput() const           = 0;
  155.         virtual int GetFrequency() const        = 0;
  156.         virtual FORMAT GetFormat() const        = 0;
  157.         virtual HWINDOW GetWindow() const       = 0;
  158.  
  159.         // object state 
  160.         virtual int ok() const = 0;       
  161.  
  162.     protected:
  163.         
  164.         // surface management
  165.         virtual HSURFACE RequestSurface(Surface &owner,int x,int y,FORMAT const &format,int type,int layout,int advance) = 0;
  166.         virtual void FreeSurface(HSURFACE handle)                   = 0;
  167.         virtual void* LockSurface(HSURFACE handle,int wait)         = 0;
  168.         virtual void UnlockSurface(HSURFACE handle)                 = 0;
  169.         virtual int GetSurfaceLockCount(HSURFACE handle)            = 0;
  170.         virtual int RestoreSurface(HSURFACE handle)                 = 0;    
  171.         virtual SURFACEINFO GetSurfaceInfo(HSURFACE handle)         = 0;
  172.         virtual void* GetNativeSurface(HSURFACE handle)             = 0;
  173.         virtual int GetNativeSurfaceType(HSURFACE handle)           = 0;
  174.         virtual void SetOwnerSurface(HSURFACE handle,Surface *owner) = 0;
  175.  
  176.         // surface clear
  177.         virtual int Clear(Surface &surface,COLOR const &color)                       = 0;
  178.         virtual int Clear(Surface &surface,RECTANGLE const &rect,COLOR const &color) = 0;
  179.  
  180.         // surface update
  181.         virtual int Update(Surface &src,void *extra)                                                      = 0;
  182.         virtual int Update(Surface &src,RECTANGLE const &rect,void *extra)                                = 0;
  183.         virtual int Update(Surface &src,RECTANGLE const &dest_rect,RECTANGLE const &src_rect,void *extra) = 0;
  184.         
  185.         // surface bitblt
  186.         virtual int BitBlt(Surface &src,Surface &dest,EFFECTS const *effects,void *extra)                       = 0;
  187.         virtual int BitBlt(Surface &src,Surface &dest,RECTANGLE const &rect,EFFECTS const *effects,void *extra) = 0;
  188.         virtual int BitBlt(Surface &src,RECTANGLE const &src_rect,
  189.                            Surface &dest,RECTANGLE const &dest_rect,EFFECTS const *effects,void *extra)         = 0;
  190.  
  191.         // surface stretchblt
  192.         virtual int StretchBlt(Surface &src,Surface &dest,EFFECTS const *effects,void *extra)                       = 0;
  193.         virtual int StretchBlt(Surface &src,Surface &dest,RECTANGLE const &rect,EFFECTS const *effects,void *extra) = 0;
  194.         virtual int StretchBlt(Surface &src,RECTANGLE const &src_rect,
  195.                                Surface &dest,RECTANGLE const &dest_rect,EFFECTS const *effects,void *extra)         = 0;
  196. };
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208. #endif