LibreOffice Module vcl (master)  1
OpenGLContext.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #ifndef INCLUDED_VCL_OPENGL_OPENGLCONTEXT_HXX
11 #define INCLUDED_VCL_OPENGL_OPENGLCONTEXT_HXX
12 
13 #include <vcl/dllapi.h>
14 #include <vcl/syschild.hxx>
15 #include <rtl/ref.hxx>
16 
19 {
20  unsigned int Width;
21  unsigned int Height;
23 
25  : Width(0)
26  , Height(0)
27  , bMultiSampleSupported(false)
28  {
29  }
30 
31  virtual bool Synchronize(bool bOnoff) const;
32 
33  virtual ~GLWindow();
34 };
35 
37 {
38  friend class OpenGLTests;
39 protected:
40  OpenGLContext();
41 public:
43  virtual ~OpenGLContext();
44  void acquire() { mnRefCount++; }
45  void release() { if ( --mnRefCount == 0 ) delete this; }
46  void dispose();
47 
48  void requestLegacyContext();
49 
50  bool init(vcl::Window* pParent);
51 
52  void reset();
53 
55  virtual bool isCurrent();
57  virtual bool isAnyCurrent();
59  static void clearCurrent();
61  static void prepareForYield();
63  static bool hasCurrent();
64 
66  virtual void makeCurrent();
68  void registerAsCurrent();
70  virtual void resetCurrent();
72  virtual void restoreDefaultFramebuffer();
73  virtual void swapBuffers();
74  virtual void sync();
75  void show();
76 
77  void setWinPosAndSize(const Point &rPos, const Size& rSize);
78  virtual const GLWindow& getOpenGLWindow() const = 0;
79 
80  SystemChildWindow* getChildWindow();
81  const SystemChildWindow* getChildWindow() const;
82 
83  bool isInitialized() const
84  {
85  return mbInitialized;
86  }
87 
88  virtual SystemWindowData generateWinData(vcl::Window* pParent, bool bRequestLegacyContext);
89 
90 private:
91  virtual void initWindow();
92  virtual void destroyCurrentContext();
93  virtual void adjustToNewSize();
94 
95 protected:
96  bool InitGL();
97  static void InitGLDebugging();
98  static void InitChildWindow(SystemChildWindow *pChildWindow);
99  static void BuffersSwapped();
100  virtual GLWindow& getModifiableOpenGLWindow() = 0;
101  virtual bool ImplInit();
102 
104  VclPtr<vcl::Window> mpWindow; //points to m_pWindow or the parent window, don't delete it
109 
110 public:
111 
112  // Don't hold references to ourselves:
115 };
116 
117 #endif
118 
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool bMultiSampleSupported
OpenGLContext * mpNextContext
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
unsigned int Height
bool mbInitialized
bool mbRequestLegacyContext
bool isInitialized() const
Holds the information of our new child window.
OpenGLContext * mpPrevContext
unsigned int Width
VclPtr< vcl::Window > m_xWindow
FILE * init(int, char **)
VclPtr< SystemChildWindow > m_pChildWindow
void dispose()
VclPtr< vcl::Window > mpWindow