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