Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /*******************************************************************************
  2. /
  3. /       File:           GLView.h
  4. /
  5. /       Copyright 1993-98, Be Incorporated, All Rights Reserved.
  6. /
  7. *******************************************************************************/
  8.  
  9. #ifndef BGLVIEW_H
  10. #define BGLVIEW_H
  11.  
  12. // added by Brian Paul:
  13. #ifndef BGL_RGB
  14. #define BGL_RGB                 0
  15. #define BGL_INDEX               1
  16. #define BGL_SINGLE              0
  17. #define BGL_DOUBLE              2
  18. #define BGL_DIRECT              0
  19. #define BGL_INDIRECT            4
  20. #define BGL_ACCUM               8
  21. #define BGL_ALPHA               16
  22. #define BGL_DEPTH               32
  23. #define BGL_OVERLAY             64
  24. #define BGL_UNDERLAY            128
  25. #define BGL_STENCIL             512
  26. #endif
  27.  
  28.  
  29. #include <GL/gl.h>
  30. #include <AppKit.h>
  31. #include <interface/Window.h>
  32. #include <interface/View.h>
  33. #include <interface/Bitmap.h>
  34. #include <game/WindowScreen.h>
  35. #include <game/DirectWindow.h>
  36.  
  37. class BGLView : public BView {
  38. public:
  39.  
  40.         BGLView(BRect rect, char *name,
  41.                         ulong resizingMode, ulong mode,
  42.                         ulong options);
  43.         virtual ~BGLView();
  44.  
  45.         void            LockGL();
  46.         void            UnlockGL();
  47.         void            SwapBuffers();
  48.  
  49.         // Added for Mesa (can't be virtual!)
  50.         void CopySubBufferMESA(GLint x, GLint y, GLuint width, GLuint height);
  51.  
  52.         BView *     EmbeddedView();
  53.         status_t    CopyPixelsOut(BPoint source, BBitmap *dest);
  54.         status_t    CopyPixelsIn(BBitmap *source, BPoint dest);
  55.  
  56.         virtual void        ErrorCallback(GLenum errorCode);
  57.                
  58.         virtual void            Draw(BRect updateRect);
  59.  
  60.         virtual void            AttachedToWindow();
  61.         virtual void        AllAttached();
  62.         virtual void        DetachedFromWindow();
  63.         virtual void        AllDetached();
  64.  
  65.         virtual void            FrameResized(float width, float height);
  66.         virtual status_t    Perform(perform_code d, void *arg);
  67.  
  68.         /* The public methods below, for the moment,
  69.            are just pass-throughs to BView */
  70.  
  71.         virtual status_t    Archive(BMessage *data, bool deep = true) const;
  72.  
  73.         virtual void        MessageReceived(BMessage *msg);
  74.         virtual void        SetResizingMode(uint32 mode);
  75.  
  76.         virtual void        Show();
  77.         virtual void        Hide();
  78.  
  79.         virtual BHandler   *ResolveSpecifier(BMessage *msg, int32 index,
  80.                                                         BMessage *specifier, int32 form,
  81.                                                         const char *property);
  82.         virtual status_t    GetSupportedSuites(BMessage *data);
  83.  
  84.         /* New public functions */
  85.         void            DirectConnected( direct_buffer_info *info );
  86.         void            EnableDirectMode( bool enabled );
  87.  
  88. private:
  89.  
  90.         virtual void        _ReservedGLView1();
  91.         virtual void        _ReservedGLView2();
  92.         virtual void        _ReservedGLView3();
  93.         virtual void        _ReservedGLView4();
  94.         virtual void        _ReservedGLView5();
  95.         virtual void        _ReservedGLView6();
  96.         virtual void        _ReservedGLView7();
  97.         virtual void        _ReservedGLView8();
  98.  
  99.     BGLView(const BGLView &);
  100.     BGLView     &operator=(const BGLView &);
  101.  
  102.         void        dither_front();
  103.         bool        confirm_dither();
  104.         void        draw(BRect r);
  105.                
  106.         void *          m_gc;
  107.         uint32          m_options;
  108.         uint32      m_ditherCount;
  109.         BLocker         m_drawLock;
  110.         BLocker     m_displayLock;
  111. #if OLD_GLVIEW
  112.         BView *         m_embeddedFront;
  113.         BView *     m_embeddedBack;
  114. #else
  115.         void *          m_clip_info;
  116.         void *          _reserved1;
  117. #endif
  118.         BBitmap *   m_ditherMap;
  119.         BRect       m_bounds;
  120.         int16 *     m_errorBuffer[2];
  121.         uint64      _reserved[8];
  122.  
  123.         /* Direct Window stuff */
  124. private:       
  125.         void drawScanline( int x1, int x2, int y, void *data );
  126.         static void scanlineHandler(struct rasStateRec *state, GLint x1, GLint x2);
  127.         void            lock_draw();
  128.         void            unlock_draw();
  129.         bool            validateView();
  130. };
  131.  
  132.  
  133.  
  134. class BGLScreen : public BWindowScreen {
  135. public:
  136.         BGLScreen(char *name,
  137.                         ulong screenMode, ulong options,
  138.                         status_t *error, bool debug=false);
  139.         ~BGLScreen();
  140.  
  141.         void            LockGL();
  142.         void            UnlockGL();
  143.         void            SwapBuffers();
  144.         virtual void        ErrorCallback(GLenum errorCode);
  145.  
  146.         virtual void            ScreenConnected(bool connected);
  147.         virtual void            FrameResized(float width, float height);
  148.         virtual status_t    Perform(perform_code d, void *arg);
  149.  
  150.         /* The public methods below, for the moment,
  151.            are just pass-throughs to BWindowScreen */
  152.  
  153.         virtual status_t    Archive(BMessage *data, bool deep = true) const;
  154.         virtual void        MessageReceived(BMessage *msg);
  155.  
  156.         virtual void        Show();
  157.         virtual void        Hide();
  158.  
  159.         virtual BHandler   *ResolveSpecifier(BMessage *msg,
  160.                         int32 index,
  161.                                                 BMessage *specifier,
  162.                                                 int32 form,
  163.                                                 const char *property);
  164.         virtual status_t    GetSupportedSuites(BMessage *data);
  165.  
  166. private:
  167.  
  168.         virtual void        _ReservedGLScreen1();
  169.         virtual void        _ReservedGLScreen2();
  170.         virtual void        _ReservedGLScreen3();
  171.         virtual void        _ReservedGLScreen4();
  172.         virtual void        _ReservedGLScreen5();
  173.         virtual void        _ReservedGLScreen6();
  174.         virtual void        _ReservedGLScreen7();
  175.         virtual void        _ReservedGLScreen8();
  176.  
  177.         BGLScreen(const BGLScreen &);
  178.         BGLScreen   &operator=(const BGLScreen &);
  179.  
  180.         void *          m_gc;
  181.         long            m_options;
  182.         BLocker         m_drawLock;
  183.                
  184.         int32           m_colorSpace;
  185.         uint32          m_screen_mode;
  186.                
  187.         uint64      _reserved[7];
  188. };
  189.  
  190.  
  191. #endif
  192.  
  193.  
  194.  
  195.  
  196.  
  197.