Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GLView.h 4.7KB

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