From fafc6e4b776ba7c9eff20696976d9fdb85113682 Mon Sep 17 00:00:00 2001 From: Philippe Houdoin Date: Wed, 8 Sep 2010 10:01:37 +0000 Subject: [PATCH] Added a GetGLProcAddress() method to BGLView. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38578 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/opengl/GLView.h | 60 ++++++++++++++++++++------------------ src/kits/opengl/GLView.cpp | 46 +++++++++++++---------------- 2 files changed, 52 insertions(+), 54 deletions(-) diff --git a/headers/os/opengl/GLView.h b/headers/os/opengl/GLView.h index b58a24a3e9..16c7703dfb 100644 --- a/headers/os/opengl/GLView.h +++ b/headers/os/opengl/GLView.h @@ -39,37 +39,38 @@ public: ulong resizingMode, ulong mode, ulong options); virtual ~BGLView(); - + void LockGL(); void UnlockGL(); void SwapBuffers(); void SwapBuffers(bool vSync); - + BView* EmbeddedView(); // deprecated, returns NULL - + void* GetGLProcAddress(const char* procName); + status_t CopyPixelsOut(BPoint source, BBitmap *dest); status_t CopyPixelsIn(BBitmap *source, BPoint dest); - + // Mesa's GLenum is uint where Be's ones was ulong! virtual void ErrorCallback(unsigned long errorCode); - + virtual void Draw(BRect updateRect); virtual void AttachedToWindow(); virtual void AllAttached(); virtual void DetachedFromWindow(); virtual void AllDetached(); - + virtual void FrameResized(float newWidth, float newHeight); virtual status_t Perform(perform_code d, void *arg); - + virtual status_t Archive(BMessage *data, bool deep = true) const; virtual void MessageReceived(BMessage *message); virtual void SetResizingMode(uint32 mode); - + virtual void Show(); virtual void Hide(); - + virtual BHandler* ResolveSpecifier(BMessage *msg, int32 index, BMessage *specifier, int32 form, const char *property); @@ -79,20 +80,21 @@ virtual status_t GetSupportedSuites(BMessage *data); void EnableDirectMode(bool enabled); void* getGC() { return fGc; } // ??? - + virtual void GetPreferredSize(float* width, float* height); - + + private: virtual void _ReservedGLView1(); - virtual void _ReservedGLView2(); - virtual void _ReservedGLView3(); - virtual void _ReservedGLView4(); - virtual void _ReservedGLView5(); - virtual void _ReservedGLView6(); - virtual void _ReservedGLView7(); - virtual void _ReservedGLView8(); - + virtual void _ReservedGLView2(); + virtual void _ReservedGLView3(); + virtual void _ReservedGLView4(); + virtual void _ReservedGLView5(); + virtual void _ReservedGLView6(); + virtual void _ReservedGLView7(); + virtual void _ReservedGLView8(); + BGLView(const BGLView &); BGLView &operator=(const BGLView &); @@ -100,14 +102,14 @@ private: bool _ConfirmDither(); void _Draw(BRect rect); void _CallDirectConnected(); - + void * fGc; uint32 fOptions; uint32 fDitherCount; BLocker fDrawLock; BLocker fDisplayLock; glview_direct_info * fClipInfo; - + BGLRenderer *fRenderer; GLRendererRoster *fRoster; @@ -115,10 +117,10 @@ private: BRect fBounds; int16 * fErrorBuffer[2]; uint64 _reserved[8]; - + void _LockDraw(); void _UnlockDraw(); - + // BeOS compatibility private: BGLView(BRect rect, char* name, @@ -139,14 +141,14 @@ public: void SwapBuffers(); // Mesa's GLenum is uint where Be's ones was ulong! virtual void ErrorCallback(unsigned long errorCode); - + virtual void ScreenConnected(bool connected); virtual void FrameResized(float width, float height); virtual status_t Perform(perform_code code, void *arg); virtual status_t Archive(BMessage *data, bool deep = true) const; virtual void MessageReceived(BMessage *message); - + virtual void Show(); virtual void Hide(); @@ -166,7 +168,7 @@ private: virtual void _ReservedGLScreen5(); virtual void _ReservedGLScreen6(); virtual void _ReservedGLScreen7(); - virtual void _ReservedGLScreen8(); + virtual void _ReservedGLScreen8(); BGLScreen(const BGLScreen &); BGLScreen &operator=(const BGLScreen &); @@ -174,13 +176,13 @@ private: void * fGc; long fOptions; BLocker fDrawLock; - + int32 fColorSpace; uint32 fScreenMode; - + uint64 _reserved[7]; }; #endif // __cplusplus - + #endif // BGLVIEW_H diff --git a/src/kits/opengl/GLView.cpp b/src/kits/opengl/GLView.cpp index 08e1ee3bcf..78dc4a619d 100644 --- a/src/kits/opengl/GLView.cpp +++ b/src/kits/opengl/GLView.cpp @@ -8,30 +8,6 @@ * Stefano Ceccherini, burton666@libero.it */ -/* - * Mesa 3-D graphics library - * Version: 6.1 - * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - #include @@ -43,6 +19,7 @@ #include #include "DirectWindowPrivate.h" +#include "GLDispatcher.h" #include "GLRendererRoster.h" struct glview_direct_info { @@ -129,6 +106,21 @@ BGLView::EmbeddedView() } +void* +BGLView::GetGLProcAddress(const char* procName) +{ + BGLDispatcher* glDispatcher = NULL; + + if (fRenderer) + glDispatcher = fRenderer->GLDispatcher(); + + if (glDispatcher) + return (void*)glDispatcher->AddressOf(procName); + + return NULL; +} + + status_t BGLView::CopyPixelsOut(BPoint source, BBitmap *dest) { @@ -207,8 +199,11 @@ BGLView::AttachedToWindow() #else SetViewColor(0, 0, 0); #endif + // Set default OpenGL viewport: + LockGL(); glViewport(0, 0, Bounds().IntegerWidth(), Bounds().IntegerHeight()); + UnlockGL(); fRenderer->FrameResized(Bounds().IntegerWidth(), Bounds().IntegerHeight()); @@ -461,7 +456,8 @@ void BGLView::_ReservedGLView8() {} // #pragma mark - -// BeOS compatibility +// BeOS compatibility: contrary to others BView's contructors, +// BGLView one wants a non-const name argument. BGLView::BGLView(BRect rect, char* name, ulong resizingMode, ulong mode, ulong options) :