24 int contextProfileMask,
25 int contextMajorVersion,
26 int contextMinorVersion,
28 int contextResetNotificationStrategy)
31 m_hidden_window(nullptr),
32 m_contextProfileMask(contextProfileMask),
33 m_contextMajorVersion(contextMajorVersion),
34 m_contextMinorVersion(contextMinorVersion),
35 m_contextFlags(contextFlags),
36 m_contextResetNotificationStrategy(contextResetNotificationStrategy),
44 if (m_context ==
nullptr) {
48 if (m_window !=
nullptr && m_context == SDL_GL_GetCurrentContext()) {
49 SDL_GL_MakeCurrent(m_window,
nullptr);
51 if (m_context != s_sharedContext || s_sharedCount == 1) {
52 assert(s_sharedCount > 0);
56 if (s_sharedCount == 0) {
57 s_sharedContext =
nullptr;
59 SDL_GL_DeleteContext(m_context);
62 if (m_hidden_window !=
nullptr) {
63 SDL_DestroyWindow(m_hidden_window);
93 const bool needAlpha =
false;
95 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, m_contextProfileMask);
96 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, m_contextMajorVersion);
97 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, m_contextMinorVersion);
98 SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, m_contextFlags);
100 SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
101 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
102 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
103 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
104 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
107 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
111 SDL_GL_SetAttribute(SDL_GL_STEREO, 1);
114 if (m_window ==
nullptr) {
115 m_hidden_window = SDL_CreateWindow(
"Offscreen Context Windows",
116 SDL_WINDOWPOS_UNDEFINED,
117 SDL_WINDOWPOS_UNDEFINED,
120 SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS |
123 m_window = m_hidden_window;
126 m_context = SDL_GL_CreateContext(m_window);
130 if (m_context !=
nullptr) {
131 if (!s_sharedContext) {
132 s_sharedContext = m_context;
139 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