Brian Paul | 50f20ec | 2003-12-13 01:26:14 +0000 | [diff] [blame] | 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 | |
Philippe Houdoin | 4b3be4d | 2004-08-14 09:43:07 +0000 | [diff] [blame] | 12 | #include <GL/gl.h> |
| 13 | |
Brian Paul | 50f20ec | 2003-12-13 01:26:14 +0000 | [diff] [blame] | 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 |
Philippe Houdoin | 4b3be4d | 2004-08-14 09:43:07 +0000 | [diff] [blame] | 19 | #define BGL_INDIRECT 4 |
Brian Paul | 50f20ec | 2003-12-13 01:26:14 +0000 | [diff] [blame] | 20 | #define BGL_ACCUM 8 |
| 21 | #define BGL_ALPHA 16 |
| 22 | #define BGL_DEPTH 32 |
| 23 | #define BGL_OVERLAY 64 |
Philippe Houdoin | 4b3be4d | 2004-08-14 09:43:07 +0000 | [diff] [blame] | 24 | #define BGL_UNDERLAY 128 |
Brian Paul | 50f20ec | 2003-12-13 01:26:14 +0000 | [diff] [blame] | 25 | #define BGL_STENCIL 512 |
Philippe Houdoin | 4b3be4d | 2004-08-14 09:43:07 +0000 | [diff] [blame] | 26 | |
| 27 | #ifdef __cplusplus |
Brian Paul | 50f20ec | 2003-12-13 01:26:14 +0000 | [diff] [blame] | 28 | |
| 29 | |
Brian Paul | 50f20ec | 2003-12-13 01:26:14 +0000 | [diff] [blame] | 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 | |
Philippe Houdoin | 4b3be4d | 2004-08-14 09:43:07 +0000 | [diff] [blame] | 40 | BGLView(BRect rect, char *name, |
| 41 | ulong resizingMode, ulong mode, |
| 42 | ulong options); |
| 43 | virtual ~BGLView(); |
Brian Paul | 50f20ec | 2003-12-13 01:26:14 +0000 | [diff] [blame] | 44 | |
Philippe Houdoin | 4b3be4d | 2004-08-14 09:43:07 +0000 | [diff] [blame] | 45 | void LockGL(); |
| 46 | void UnlockGL(); |
| 47 | void SwapBuffers(); |
| 48 | void SwapBuffers( bool vSync ); |
| 49 | BView * EmbeddedView(); |
| 50 | status_t CopyPixelsOut(BPoint source, BBitmap *dest); |
| 51 | status_t CopyPixelsIn(BBitmap *source, BPoint dest); |
| 52 | virtual void ErrorCallback(unsigned long errorCode); // Mesa's GLenum is uint where Be's ones was ulong! |
Brian Paul | 50f20ec | 2003-12-13 01:26:14 +0000 | [diff] [blame] | 53 | |
Philippe Houdoin | 4b3be4d | 2004-08-14 09:43:07 +0000 | [diff] [blame] | 54 | virtual void Draw(BRect updateRect); |
Brian Paul | 50f20ec | 2003-12-13 01:26:14 +0000 | [diff] [blame] | 55 | |
Philippe Houdoin | 4b3be4d | 2004-08-14 09:43:07 +0000 | [diff] [blame] | 56 | virtual void AttachedToWindow(); |
| 57 | virtual void AllAttached(); |
| 58 | virtual void DetachedFromWindow(); |
| 59 | virtual void AllDetached(); |
Brian Paul | 50f20ec | 2003-12-13 01:26:14 +0000 | [diff] [blame] | 60 | |
Philippe Houdoin | 4b3be4d | 2004-08-14 09:43:07 +0000 | [diff] [blame] | 61 | virtual void FrameResized(float width, float height); |
| 62 | virtual status_t Perform(perform_code d, void *arg); |
Brian Paul | 50f20ec | 2003-12-13 01:26:14 +0000 | [diff] [blame] | 63 | |
| 64 | /* The public methods below, for the moment, |
| 65 | are just pass-throughs to BView */ |
| 66 | |
Philippe Houdoin | 4b3be4d | 2004-08-14 09:43:07 +0000 | [diff] [blame] | 67 | virtual status_t Archive(BMessage *data, bool deep = true) const; |
Brian Paul | 50f20ec | 2003-12-13 01:26:14 +0000 | [diff] [blame] | 68 | |
Philippe Houdoin | 4b3be4d | 2004-08-14 09:43:07 +0000 | [diff] [blame] | 69 | virtual void MessageReceived(BMessage *msg); |
| 70 | virtual void SetResizingMode(uint32 mode); |
Brian Paul | 50f20ec | 2003-12-13 01:26:14 +0000 | [diff] [blame] | 71 | |
Philippe Houdoin | 4b3be4d | 2004-08-14 09:43:07 +0000 | [diff] [blame] | 72 | virtual void Show(); |
| 73 | virtual void Hide(); |
Brian Paul | 50f20ec | 2003-12-13 01:26:14 +0000 | [diff] [blame] | 74 | |
Philippe Houdoin | 4b3be4d | 2004-08-14 09:43:07 +0000 | [diff] [blame] | 75 | virtual BHandler *ResolveSpecifier(BMessage *msg, int32 index, |
Brian Paul | 50f20ec | 2003-12-13 01:26:14 +0000 | [diff] [blame] | 76 | BMessage *specifier, int32 form, |
| 77 | const char *property); |
Philippe Houdoin | 4b3be4d | 2004-08-14 09:43:07 +0000 | [diff] [blame] | 78 | virtual status_t GetSupportedSuites(BMessage *data); |
Brian Paul | 50f20ec | 2003-12-13 01:26:14 +0000 | [diff] [blame] | 79 | |
Philippe Houdoin | 4b3be4d | 2004-08-14 09:43:07 +0000 | [diff] [blame] | 80 | /* New public functions */ |
| 81 | void DirectConnected( direct_buffer_info *info ); |
| 82 | void EnableDirectMode( bool enabled ); |
Brian Paul | 50f20ec | 2003-12-13 01:26:14 +0000 | [diff] [blame] | 83 | |
Philippe Houdoin | 4b3be4d | 2004-08-14 09:43:07 +0000 | [diff] [blame] | 84 | void * getGC() { return m_gc; } |
| 85 | |
Brian Paul | 50f20ec | 2003-12-13 01:26:14 +0000 | [diff] [blame] | 86 | private: |
| 87 | |
Philippe Houdoin | 4b3be4d | 2004-08-14 09:43:07 +0000 | [diff] [blame] | 88 | virtual void _ReservedGLView1(); |
| 89 | virtual void _ReservedGLView2(); |
| 90 | virtual void _ReservedGLView3(); |
| 91 | virtual void _ReservedGLView4(); |
| 92 | virtual void _ReservedGLView5(); |
| 93 | virtual void _ReservedGLView6(); |
| 94 | virtual void _ReservedGLView7(); |
| 95 | virtual void _ReservedGLView8(); |
Brian Paul | 50f20ec | 2003-12-13 01:26:14 +0000 | [diff] [blame] | 96 | |
Philippe Houdoin | 4b3be4d | 2004-08-14 09:43:07 +0000 | [diff] [blame] | 97 | BGLView(const BGLView &); |
| 98 | BGLView &operator=(const BGLView &); |
Brian Paul | 50f20ec | 2003-12-13 01:26:14 +0000 | [diff] [blame] | 99 | |
Philippe Houdoin | 4b3be4d | 2004-08-14 09:43:07 +0000 | [diff] [blame] | 100 | void dither_front(); |
| 101 | bool confirm_dither(); |
| 102 | void draw(BRect r); |
Brian Paul | 50f20ec | 2003-12-13 01:26:14 +0000 | [diff] [blame] | 103 | |
Philippe Houdoin | 4b3be4d | 2004-08-14 09:43:07 +0000 | [diff] [blame] | 104 | void * m_gc; |
| 105 | uint32 m_options; |
| 106 | uint32 m_ditherCount; |
| 107 | BLocker m_drawLock; |
| 108 | BLocker m_displayLock; |
| 109 | void * m_clip_info; |
| 110 | void * _Unused1; |
| 111 | |
| 112 | BBitmap * m_ditherMap; |
| 113 | BRect m_bounds; |
| 114 | int16 * m_errorBuffer[2]; |
| 115 | uint64 _reserved[8]; |
Brian Paul | 50f20ec | 2003-12-13 01:26:14 +0000 | [diff] [blame] | 116 | |
| 117 | /* Direct Window stuff */ |
| 118 | private: |
Philippe Houdoin | 4b3be4d | 2004-08-14 09:43:07 +0000 | [diff] [blame] | 119 | void drawScanline( int x1, int x2, int y, void *data ); |
| 120 | static void scanlineHandler(struct rasStateRec *state, GLint x1, GLint x2); |
| 121 | |
| 122 | void lock_draw(); |
| 123 | void unlock_draw(); |
| 124 | bool validateView(); |
Brian Paul | 50f20ec | 2003-12-13 01:26:14 +0000 | [diff] [blame] | 125 | }; |
| 126 | |
| 127 | |
| 128 | |
| 129 | class BGLScreen : public BWindowScreen { |
| 130 | public: |
| 131 | BGLScreen(char *name, |
| 132 | ulong screenMode, ulong options, |
| 133 | status_t *error, bool debug=false); |
| 134 | ~BGLScreen(); |
| 135 | |
| 136 | void LockGL(); |
| 137 | void UnlockGL(); |
| 138 | void SwapBuffers(); |
| 139 | virtual void ErrorCallback(GLenum errorCode); |
| 140 | |
| 141 | virtual void ScreenConnected(bool connected); |
| 142 | virtual void FrameResized(float width, float height); |
| 143 | virtual status_t Perform(perform_code d, void *arg); |
| 144 | |
| 145 | /* The public methods below, for the moment, |
| 146 | are just pass-throughs to BWindowScreen */ |
| 147 | |
| 148 | virtual status_t Archive(BMessage *data, bool deep = true) const; |
| 149 | virtual void MessageReceived(BMessage *msg); |
| 150 | |
| 151 | virtual void Show(); |
| 152 | virtual void Hide(); |
| 153 | |
| 154 | virtual BHandler *ResolveSpecifier(BMessage *msg, |
| 155 | int32 index, |
| 156 | BMessage *specifier, |
| 157 | int32 form, |
| 158 | const char *property); |
| 159 | virtual status_t GetSupportedSuites(BMessage *data); |
| 160 | |
| 161 | private: |
| 162 | |
| 163 | virtual void _ReservedGLScreen1(); |
| 164 | virtual void _ReservedGLScreen2(); |
| 165 | virtual void _ReservedGLScreen3(); |
| 166 | virtual void _ReservedGLScreen4(); |
| 167 | virtual void _ReservedGLScreen5(); |
| 168 | virtual void _ReservedGLScreen6(); |
| 169 | virtual void _ReservedGLScreen7(); |
| 170 | virtual void _ReservedGLScreen8(); |
| 171 | |
| 172 | BGLScreen(const BGLScreen &); |
| 173 | BGLScreen &operator=(const BGLScreen &); |
| 174 | |
| 175 | void * m_gc; |
| 176 | long m_options; |
| 177 | BLocker m_drawLock; |
| 178 | |
| 179 | int32 m_colorSpace; |
| 180 | uint32 m_screen_mode; |
| 181 | |
| 182 | uint64 _reserved[7]; |
| 183 | }; |
| 184 | |
Philippe Houdoin | 4b3be4d | 2004-08-14 09:43:07 +0000 | [diff] [blame] | 185 | #endif // __cplusplus |
Brian Paul | 50f20ec | 2003-12-13 01:26:14 +0000 | [diff] [blame] | 186 | |
Philippe Houdoin | 4b3be4d | 2004-08-14 09:43:07 +0000 | [diff] [blame] | 187 | #endif // BGLVIEW_H |
Brian Paul | 50f20ec | 2003-12-13 01:26:14 +0000 | [diff] [blame] | 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | |