Blender  V2.93
GHOST_Context.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2013 Blender Foundation.
17  * All rights reserved.
18  */
19 
25 #pragma once
26 
27 #include "GHOST_IContext.h"
28 #include "GHOST_Types.h"
29 
30 #include "glew-mx.h"
31 
32 #include <cstdlib> // for NULL
33 
34 class GHOST_Context : public GHOST_IContext {
35  public:
40  GHOST_Context(bool stereoVisual) : m_stereoVisual(stereoVisual)
41  {
42  }
43 
47  virtual ~GHOST_Context()
48  {
49  }
50 
55  virtual GHOST_TSuccess swapBuffers() = 0;
56 
62 
68 
74 
81  {
82  return GHOST_kFailure;
83  }
84 
90 
96  virtual GHOST_TSuccess setSwapInterval(int /*interval*/)
97  {
98  return GHOST_kFailure;
99  }
100 
107  {
108  return GHOST_kFailure;
109  }
110 
116  inline bool isStereoVisual() const
117  {
118  return m_stereoVisual;
119  }
120 
124  virtual inline bool isUpsideDown() const
125  {
126  return false;
127  }
128 
133  virtual unsigned int getDefaultFramebuffer()
134  {
135  return 0;
136  }
137 
138  protected:
139  void initContextGLEW();
140 
142 
143  static void initClearGL();
144 
145 #ifdef WITH_CXX_GUARDEDALLOC
146  MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_Context")
147 #endif
148 };
149 
150 #ifdef _WIN32
151 bool win32_chk(bool result, const char *file = NULL, int line = 0, const char *text = NULL);
152 bool win32_silent_chk(bool result);
153 
154 # ifndef NDEBUG
155 # define WIN32_CHK(x) win32_chk((x), __FILE__, __LINE__, # x)
156 # else
157 # define WIN32_CHK(x) win32_chk(x)
158 # endif
159 
160 # define WIN32_CHK_SILENT(x, silent) ((silent) ? win32_silent_chk(x) : WIN32_CHK(x))
161 #endif /* _WIN32 */
GHOST_TSuccess
Definition: GHOST_Types.h:91
@ GHOST_kFailure
Definition: GHOST_Types.h:91
virtual GHOST_TSuccess activateDrawingContext()=0
virtual GHOST_TSuccess releaseNativeHandles()=0
virtual GHOST_TSuccess setSwapInterval(int)
Definition: GHOST_Context.h:96
virtual GHOST_TSuccess releaseDrawingContext()=0
virtual GHOST_TSuccess swapBuffers()=0
virtual GHOST_TSuccess updateDrawingContext()
Definition: GHOST_Context.h:80
virtual bool isUpsideDown() const
void initContextGLEW()
virtual GHOST_TSuccess initializeDrawingContext()=0
static void initClearGL()
virtual GHOST_TSuccess getSwapInterval(int &)
bool isStereoVisual() const
GHOST_Context(bool stereoVisual)
Definition: GHOST_Context.h:40
virtual unsigned int getDefaultFramebuffer()
virtual ~GHOST_Context()
Definition: GHOST_Context.h:47
FILE * file