1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright 2008-2013, Haiku, Inc. All Rights Reserved. 3bf215546Sopenharmony_ci * Distributed under the terms of the MIT License. 4bf215546Sopenharmony_ci * 5bf215546Sopenharmony_ci * This header defines BGLView, the base class making up 6bf215546Sopenharmony_ci * the Haiku GL Kit. 7bf215546Sopenharmony_ci * 8bf215546Sopenharmony_ci */ 9bf215546Sopenharmony_ci#ifndef BGLVIEW_H 10bf215546Sopenharmony_ci#define BGLVIEW_H 11bf215546Sopenharmony_ci 12bf215546Sopenharmony_ci 13bf215546Sopenharmony_ci#include <GL/gl.h> 14bf215546Sopenharmony_ci 15bf215546Sopenharmony_ci#define BGL_RGB 0 16bf215546Sopenharmony_ci#define BGL_INDEX 1 17bf215546Sopenharmony_ci#define BGL_SINGLE 0 18bf215546Sopenharmony_ci#define BGL_DOUBLE 2 19bf215546Sopenharmony_ci#define BGL_DIRECT 0 20bf215546Sopenharmony_ci#define BGL_INDIRECT 4 21bf215546Sopenharmony_ci#define BGL_ACCUM 8 22bf215546Sopenharmony_ci#define BGL_ALPHA 16 23bf215546Sopenharmony_ci#define BGL_DEPTH 32 24bf215546Sopenharmony_ci#define BGL_OVERLAY 64 25bf215546Sopenharmony_ci#define BGL_UNDERLAY 128 26bf215546Sopenharmony_ci#define BGL_STENCIL 512 27bf215546Sopenharmony_ci#define BGL_SHARE_CONTEXT 1024 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_ci#ifdef __cplusplus 30bf215546Sopenharmony_ci 31bf215546Sopenharmony_ci#include <AppKit.h> 32bf215546Sopenharmony_ci#include <Bitmap.h> 33bf215546Sopenharmony_ci#include <DirectWindow.h> 34bf215546Sopenharmony_ci#include <View.h> 35bf215546Sopenharmony_ci#include <Window.h> 36bf215546Sopenharmony_ci#include <WindowScreen.h> 37bf215546Sopenharmony_ci 38bf215546Sopenharmony_ci 39bf215546Sopenharmony_cistruct glview_direct_info; 40bf215546Sopenharmony_ciclass BGLRenderer; 41bf215546Sopenharmony_ciclass GLRendererRoster; 42bf215546Sopenharmony_ci 43bf215546Sopenharmony_ciclass _EXPORT BGLView : public BView { 44bf215546Sopenharmony_cipublic: 45bf215546Sopenharmony_ci BGLView(BRect rect, const char* name, 46bf215546Sopenharmony_ci ulong resizingMode, ulong mode, 47bf215546Sopenharmony_ci ulong options); 48bf215546Sopenharmony_ci virtual ~BGLView(); 49bf215546Sopenharmony_ci 50bf215546Sopenharmony_ci void LockGL(); 51bf215546Sopenharmony_ci void UnlockGL(); 52bf215546Sopenharmony_ci void SwapBuffers(); 53bf215546Sopenharmony_ci void SwapBuffers(bool vSync); 54bf215546Sopenharmony_ci 55bf215546Sopenharmony_ci BView* EmbeddedView(); // deprecated, returns NULL 56bf215546Sopenharmony_ci void* GetGLProcAddress(const char* procName); 57bf215546Sopenharmony_ci 58bf215546Sopenharmony_ci status_t CopyPixelsOut(BPoint source, BBitmap *dest); 59bf215546Sopenharmony_ci status_t CopyPixelsIn(BBitmap *source, BPoint dest); 60bf215546Sopenharmony_ci 61bf215546Sopenharmony_ci // Mesa's GLenum is uint where Be's ones was ulong! 62bf215546Sopenharmony_ci virtual void ErrorCallback(unsigned long errorCode); 63bf215546Sopenharmony_ci 64bf215546Sopenharmony_ci virtual void Draw(BRect updateRect); 65bf215546Sopenharmony_ci virtual void AttachedToWindow(); 66bf215546Sopenharmony_ci virtual void AllAttached(); 67bf215546Sopenharmony_ci virtual void DetachedFromWindow(); 68bf215546Sopenharmony_ci virtual void AllDetached(); 69bf215546Sopenharmony_ci 70bf215546Sopenharmony_ci virtual void FrameResized(float newWidth, float newHeight); 71bf215546Sopenharmony_ci virtual status_t Perform(perform_code d, void *arg); 72bf215546Sopenharmony_ci 73bf215546Sopenharmony_ci virtual status_t Archive(BMessage *data, bool deep = true) const; 74bf215546Sopenharmony_ci 75bf215546Sopenharmony_ci virtual void MessageReceived(BMessage *message); 76bf215546Sopenharmony_ci virtual void SetResizingMode(uint32 mode); 77bf215546Sopenharmony_ci 78bf215546Sopenharmony_ci virtual void Show(); 79bf215546Sopenharmony_ci virtual void Hide(); 80bf215546Sopenharmony_ci 81bf215546Sopenharmony_ci virtual BHandler* ResolveSpecifier(BMessage *msg, int32 index, 82bf215546Sopenharmony_ci BMessage *specifier, int32 form, 83bf215546Sopenharmony_ci const char *property); 84bf215546Sopenharmony_ci virtual status_t GetSupportedSuites(BMessage *data); 85bf215546Sopenharmony_ci 86bf215546Sopenharmony_ci void DirectConnected(direct_buffer_info *info); 87bf215546Sopenharmony_ci void EnableDirectMode(bool enabled); 88bf215546Sopenharmony_ci 89bf215546Sopenharmony_ci void* getGC() { return fGc; } // ??? 90bf215546Sopenharmony_ci 91bf215546Sopenharmony_ci virtual void GetPreferredSize(float* width, float* height); 92bf215546Sopenharmony_ci 93bf215546Sopenharmony_ciprivate: 94bf215546Sopenharmony_ci 95bf215546Sopenharmony_ci virtual void _ReservedGLView1(); 96bf215546Sopenharmony_ci virtual void _ReservedGLView2(); 97bf215546Sopenharmony_ci virtual void _ReservedGLView3(); 98bf215546Sopenharmony_ci virtual void _ReservedGLView4(); 99bf215546Sopenharmony_ci virtual void _ReservedGLView5(); 100bf215546Sopenharmony_ci virtual void _ReservedGLView6(); 101bf215546Sopenharmony_ci virtual void _ReservedGLView7(); 102bf215546Sopenharmony_ci virtual void _ReservedGLView8(); 103bf215546Sopenharmony_ci 104bf215546Sopenharmony_ci BGLView(const BGLView &); 105bf215546Sopenharmony_ci BGLView &operator=(const BGLView &); 106bf215546Sopenharmony_ci 107bf215546Sopenharmony_ci void _DitherFront(); 108bf215546Sopenharmony_ci bool _ConfirmDither(); 109bf215546Sopenharmony_ci void _Draw(BRect rect); 110bf215546Sopenharmony_ci void _CallDirectConnected(); 111bf215546Sopenharmony_ci 112bf215546Sopenharmony_ci void* fGc; 113bf215546Sopenharmony_ci uint32 fOptions; 114bf215546Sopenharmony_ci uint32 fDitherCount; 115bf215546Sopenharmony_ci BLocker fDrawLock; 116bf215546Sopenharmony_ci BLocker fDisplayLock; 117bf215546Sopenharmony_ci glview_direct_info* fClipInfo; 118bf215546Sopenharmony_ci 119bf215546Sopenharmony_ci BGLRenderer* fRenderer; 120bf215546Sopenharmony_ci GLRendererRoster* fRoster; 121bf215546Sopenharmony_ci 122bf215546Sopenharmony_ci BBitmap* fDitherMap; 123bf215546Sopenharmony_ci BRect fBounds; 124bf215546Sopenharmony_ci int16* fErrorBuffer[2]; 125bf215546Sopenharmony_ci uint64 _reserved[8]; 126bf215546Sopenharmony_ci 127bf215546Sopenharmony_ci void _LockDraw(); 128bf215546Sopenharmony_ci void _UnlockDraw(); 129bf215546Sopenharmony_ci 130bf215546Sopenharmony_ci// BeOS compatibility 131bf215546Sopenharmony_ciprivate: 132bf215546Sopenharmony_ci BGLView(BRect rect, char* name, 133bf215546Sopenharmony_ci ulong resizingMode, ulong mode, 134bf215546Sopenharmony_ci ulong options); 135bf215546Sopenharmony_ci}; 136bf215546Sopenharmony_ci 137bf215546Sopenharmony_ci 138bf215546Sopenharmony_ciclass BGLScreen : public BWindowScreen { 139bf215546Sopenharmony_cipublic: 140bf215546Sopenharmony_ci BGLScreen(char* name, 141bf215546Sopenharmony_ci ulong screenMode, ulong options, 142bf215546Sopenharmony_ci status_t *error, bool debug=false); 143bf215546Sopenharmony_ci ~BGLScreen(); 144bf215546Sopenharmony_ci 145bf215546Sopenharmony_ci void LockGL(); 146bf215546Sopenharmony_ci void UnlockGL(); 147bf215546Sopenharmony_ci void SwapBuffers(); 148bf215546Sopenharmony_ci // Mesa's GLenum is uint where Be's ones was ulong! 149bf215546Sopenharmony_ci virtual void ErrorCallback(unsigned long errorCode); 150bf215546Sopenharmony_ci 151bf215546Sopenharmony_ci virtual void ScreenConnected(bool connected); 152bf215546Sopenharmony_ci virtual void FrameResized(float width, float height); 153bf215546Sopenharmony_ci virtual status_t Perform(perform_code code, void *arg); 154bf215546Sopenharmony_ci 155bf215546Sopenharmony_ci virtual status_t Archive(BMessage *data, bool deep = true) const; 156bf215546Sopenharmony_ci virtual void MessageReceived(BMessage *message); 157bf215546Sopenharmony_ci 158bf215546Sopenharmony_ci virtual void Show(); 159bf215546Sopenharmony_ci virtual void Hide(); 160bf215546Sopenharmony_ci 161bf215546Sopenharmony_ci virtual BHandler* ResolveSpecifier(BMessage *message, 162bf215546Sopenharmony_ci int32 index, 163bf215546Sopenharmony_ci BMessage *specifier, 164bf215546Sopenharmony_ci int32 form, 165bf215546Sopenharmony_ci const char *property); 166bf215546Sopenharmony_ci virtual status_t GetSupportedSuites(BMessage *data); 167bf215546Sopenharmony_ci 168bf215546Sopenharmony_ciprivate: 169bf215546Sopenharmony_ci 170bf215546Sopenharmony_ci virtual void _ReservedGLScreen1(); 171bf215546Sopenharmony_ci virtual void _ReservedGLScreen2(); 172bf215546Sopenharmony_ci virtual void _ReservedGLScreen3(); 173bf215546Sopenharmony_ci virtual void _ReservedGLScreen4(); 174bf215546Sopenharmony_ci virtual void _ReservedGLScreen5(); 175bf215546Sopenharmony_ci virtual void _ReservedGLScreen6(); 176bf215546Sopenharmony_ci virtual void _ReservedGLScreen7(); 177bf215546Sopenharmony_ci virtual void _ReservedGLScreen8(); 178bf215546Sopenharmony_ci 179bf215546Sopenharmony_ci BGLScreen(const BGLScreen &); 180bf215546Sopenharmony_ci BGLScreen &operator=(const BGLScreen &); 181bf215546Sopenharmony_ci 182bf215546Sopenharmony_ci void* fGc; 183bf215546Sopenharmony_ci long fOptions; 184bf215546Sopenharmony_ci BLocker fDrawLock; 185bf215546Sopenharmony_ci 186bf215546Sopenharmony_ci int32 fColorSpace; 187bf215546Sopenharmony_ci uint32 fScreenMode; 188bf215546Sopenharmony_ci 189bf215546Sopenharmony_ci uint64 _reserved[7]; 190bf215546Sopenharmony_ci}; 191bf215546Sopenharmony_ci 192bf215546Sopenharmony_ci#endif // __cplusplus 193bf215546Sopenharmony_ci 194bf215546Sopenharmony_ci#endif // BGLVIEW_H 195