Blender  V3.3
GHOST_Context.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2013 Blender Foundation. All rights reserved. */
3 
9 #pragma once
10 
11 #include "GHOST_IContext.h"
12 #include "GHOST_Types.h"
13 
14 #include "glew-mx.h"
15 
16 #include <cstdlib> // for NULL
17 
18 class GHOST_Context : public GHOST_IContext {
19  public:
24  GHOST_Context(bool stereoVisual) : m_stereoVisual(stereoVisual)
25  {
26  }
27 
31  virtual ~GHOST_Context()
32  {
33  }
34 
39  virtual GHOST_TSuccess swapBuffers() = 0;
40 
46 
52 
58 
65  {
66  return GHOST_kFailure;
67  }
68 
74 
80  virtual GHOST_TSuccess setSwapInterval(int /*interval*/)
81  {
82  return GHOST_kFailure;
83  }
84 
91  {
92  return GHOST_kFailure;
93  }
94 
98  void *getUserData()
99  {
100  return m_user_data;
101  }
102 
106  void setUserData(void *user_data)
107  {
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 
144  void *m_user_data = nullptr;
145 
146  static void initClearGL();
147 
148 #ifdef WITH_CXX_GUARDEDALLOC
149  MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_Context")
150 #endif
151 };
152 
153 #ifdef _WIN32
154 bool win32_chk(bool result, const char *file = NULL, int line = 0, const char *text = NULL);
155 bool win32_silent_chk(bool result);
156 
157 # ifndef NDEBUG
158 # define WIN32_CHK(x) win32_chk((x), __FILE__, __LINE__, # x)
159 # else
160 # define WIN32_CHK(x) win32_chk(x)
161 # endif
162 
163 # define WIN32_CHK_SILENT(x, silent) ((silent) ? win32_silent_chk(x) : WIN32_CHK(x))
164 #endif /* _WIN32 */
GHOST_TSuccess
Definition: GHOST_Types.h:74
@ GHOST_kFailure
Definition: GHOST_Types.h:74
virtual GHOST_TSuccess activateDrawingContext()=0
virtual GHOST_TSuccess releaseNativeHandles()=0
virtual GHOST_TSuccess setSwapInterval(int)
Definition: GHOST_Context.h:80
void * m_user_data
virtual GHOST_TSuccess releaseDrawingContext()=0
virtual GHOST_TSuccess swapBuffers()=0
virtual GHOST_TSuccess updateDrawingContext()
Definition: GHOST_Context.h:64
virtual bool isUpsideDown() const
void initContextGLEW()
virtual GHOST_TSuccess initializeDrawingContext()=0
static void initClearGL()
void * getUserData()
Definition: GHOST_Context.h:98
void setUserData(void *user_data)
virtual GHOST_TSuccess getSwapInterval(int &)
Definition: GHOST_Context.h:90
bool isStereoVisual() const
GHOST_Context(bool stereoVisual)
Definition: GHOST_Context.h:24
virtual unsigned int getDefaultFramebuffer()
virtual ~GHOST_Context()
Definition: GHOST_Context.h:31
FILE * file
void * user_data