21 int contextProfileMask,
22 int contextMajorVersion,
23 int contextMinorVersion,
25 int contextResetNotificationStrategy)
29 m_contextProfileMask(contextProfileMask),
30 m_contextMajorVersion(contextMajorVersion),
31 m_contextMinorVersion(contextMinorVersion),
32 m_contextFlags(contextFlags),
33 m_contextResetNotificationStrategy(contextResetNotificationStrategy),
41 if (m_context ==
nullptr) {
45 if (m_window !=
nullptr && m_context == SDL_GL_GetCurrentContext()) {
46 SDL_GL_MakeCurrent(m_window,
nullptr);
48 if (m_context != s_sharedContext || s_sharedCount == 1) {
53 if (s_sharedCount == 0) {
54 s_sharedContext =
nullptr;
56 SDL_GL_DeleteContext(m_context);
59 if (m_hidden_window !=
nullptr) {
60 SDL_DestroyWindow(m_hidden_window);
92 const bool needAlpha =
false;
94 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, m_contextProfileMask);
95 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, m_contextMajorVersion);
96 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, m_contextMinorVersion);
97 SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, m_contextFlags);
99 SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
100 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
101 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
102 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
103 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
106 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
110 SDL_GL_SetAttribute(SDL_GL_STEREO, 1);
113 if (m_window ==
nullptr) {
114 m_hidden_window = SDL_CreateWindow(
"Offscreen Context Windows",
115 SDL_WINDOWPOS_UNDEFINED,
116 SDL_WINDOWPOS_UNDEFINED,
119 SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS |
122 m_window = m_hidden_window;
125 m_context = SDL_GL_CreateContext(m_window);
129 if (m_context !=
nullptr) {
130 if (!s_sharedContext) {
131 s_sharedContext = m_context;
138 SDL_GL_SwapWindow(m_window);
GHOST_TSuccess swapBuffers() override
~GHOST_ContextSDL() override
GHOST_TSuccess releaseDrawingContext() override
GHOST_TSuccess getSwapInterval(int &intervalOut) override
GHOST_TSuccess initializeDrawingContext() override
GHOST_TSuccess activateDrawingContext() override
GHOST_TSuccess releaseNativeHandles() override
GHOST_ContextSDL(bool stereoVisual, SDL_Window *window, int contextProfileMask, int contextMajorVersion, int contextMinorVersion, int contextFlags, int contextResetNotificationStrategy)
GHOST_TSuccess setSwapInterval(int interval) override
static GHOST_Context * active_context_
GHOST_Context(bool stereoVisual)