blob: 8d9d25bb1cbfd97bf031ca9fc3e46fd1211c2b4b [file] [log] [blame]
Brian Paul50f20ec2003-12-13 01:26:14 +00001/*******************************************************************************
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 Houdoin4b3be4d2004-08-14 09:43:07 +000012#include <GL/gl.h>
13
Brian Paul50f20ec2003-12-13 01:26:14 +000014#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 Houdoin4b3be4d2004-08-14 09:43:07 +000019#define BGL_INDIRECT 4
Brian Paul50f20ec2003-12-13 01:26:14 +000020#define BGL_ACCUM 8
21#define BGL_ALPHA 16
22#define BGL_DEPTH 32
23#define BGL_OVERLAY 64
Philippe Houdoin4b3be4d2004-08-14 09:43:07 +000024#define BGL_UNDERLAY 128
Brian Paul50f20ec2003-12-13 01:26:14 +000025#define BGL_STENCIL 512
Philippe Houdoin4b3be4d2004-08-14 09:43:07 +000026
27#ifdef __cplusplus
Brian Paul50f20ec2003-12-13 01:26:14 +000028
29
Brian Paul50f20ec2003-12-13 01:26:14 +000030#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
37class BGLView : public BView {
38public:
39
Philippe Houdoin4b3be4d2004-08-14 09:43:07 +000040 BGLView(BRect rect, char *name,
41 ulong resizingMode, ulong mode,
42 ulong options);
43virtual ~BGLView();
Brian Paul50f20ec2003-12-13 01:26:14 +000044
Philippe Houdoin4b3be4d2004-08-14 09:43:07 +000045 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);
52virtual void ErrorCallback(unsigned long errorCode); // Mesa's GLenum is uint where Be's ones was ulong!
Brian Paul50f20ec2003-12-13 01:26:14 +000053
Philippe Houdoin4b3be4d2004-08-14 09:43:07 +000054virtual void Draw(BRect updateRect);
Brian Paul50f20ec2003-12-13 01:26:14 +000055
Philippe Houdoin4b3be4d2004-08-14 09:43:07 +000056virtual void AttachedToWindow();
57virtual void AllAttached();
58virtual void DetachedFromWindow();
59virtual void AllDetached();
Brian Paul50f20ec2003-12-13 01:26:14 +000060
Philippe Houdoin4b3be4d2004-08-14 09:43:07 +000061virtual void FrameResized(float width, float height);
62virtual status_t Perform(perform_code d, void *arg);
Brian Paul50f20ec2003-12-13 01:26:14 +000063
64 /* The public methods below, for the moment,
65 are just pass-throughs to BView */
66
Philippe Houdoin4b3be4d2004-08-14 09:43:07 +000067virtual status_t Archive(BMessage *data, bool deep = true) const;
Brian Paul50f20ec2003-12-13 01:26:14 +000068
Philippe Houdoin4b3be4d2004-08-14 09:43:07 +000069virtual void MessageReceived(BMessage *msg);
70virtual void SetResizingMode(uint32 mode);
Brian Paul50f20ec2003-12-13 01:26:14 +000071
Philippe Houdoin4b3be4d2004-08-14 09:43:07 +000072virtual void Show();
73virtual void Hide();
Brian Paul50f20ec2003-12-13 01:26:14 +000074
Philippe Houdoin4b3be4d2004-08-14 09:43:07 +000075virtual BHandler *ResolveSpecifier(BMessage *msg, int32 index,
Brian Paul50f20ec2003-12-13 01:26:14 +000076 BMessage *specifier, int32 form,
77 const char *property);
Philippe Houdoin4b3be4d2004-08-14 09:43:07 +000078virtual status_t GetSupportedSuites(BMessage *data);
Brian Paul50f20ec2003-12-13 01:26:14 +000079
Philippe Houdoin4b3be4d2004-08-14 09:43:07 +000080/* New public functions */
81 void DirectConnected( direct_buffer_info *info );
82 void EnableDirectMode( bool enabled );
Brian Paul50f20ec2003-12-13 01:26:14 +000083
Philippe Houdoin4b3be4d2004-08-14 09:43:07 +000084 void * getGC() { return m_gc; }
85
Brian Paul50f20ec2003-12-13 01:26:14 +000086private:
87
Philippe Houdoin4b3be4d2004-08-14 09:43:07 +000088virtual void _ReservedGLView1();
89virtual void _ReservedGLView2();
90virtual void _ReservedGLView3();
91virtual void _ReservedGLView4();
92virtual void _ReservedGLView5();
93virtual void _ReservedGLView6();
94virtual void _ReservedGLView7();
95virtual void _ReservedGLView8();
Brian Paul50f20ec2003-12-13 01:26:14 +000096
Philippe Houdoin4b3be4d2004-08-14 09:43:07 +000097 BGLView(const BGLView &);
98 BGLView &operator=(const BGLView &);
Brian Paul50f20ec2003-12-13 01:26:14 +000099
Philippe Houdoin4b3be4d2004-08-14 09:43:07 +0000100 void dither_front();
101 bool confirm_dither();
102 void draw(BRect r);
Brian Paul50f20ec2003-12-13 01:26:14 +0000103
Philippe Houdoin4b3be4d2004-08-14 09:43:07 +0000104 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 Paul50f20ec2003-12-13 01:26:14 +0000116
117 /* Direct Window stuff */
118private:
Philippe Houdoin4b3be4d2004-08-14 09:43:07 +0000119 void drawScanline( int x1, int x2, int y, void *data );
120static void scanlineHandler(struct rasStateRec *state, GLint x1, GLint x2);
121
122 void lock_draw();
123 void unlock_draw();
124 bool validateView();
Brian Paul50f20ec2003-12-13 01:26:14 +0000125};
126
127
128
129class BGLScreen : public BWindowScreen {
130public:
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
161private:
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 Houdoin4b3be4d2004-08-14 09:43:07 +0000185#endif // __cplusplus
Brian Paul50f20ec2003-12-13 01:26:14 +0000186
Philippe Houdoin4b3be4d2004-08-14 09:43:07 +0000187#endif // BGLVIEW_H
Brian Paul50f20ec2003-12-13 01:26:14 +0000188
189
190
191
192