18 SDL_GLContext GHOST_ContextSDL::s_sharedContext =
nullptr;
19 int GHOST_ContextSDL::s_sharedCount = 0;
23 int contextProfileMask,
24 int contextMajorVersion,
25 int contextMinorVersion,
27 int contextResetNotificationStrategy)
30 m_hidden_window(nullptr),
31 m_contextProfileMask(contextProfileMask),
32 m_contextMajorVersion(contextMajorVersion),
33 m_contextMinorVersion(contextMinorVersion),
34 m_contextFlags(contextFlags),
35 m_contextResetNotificationStrategy(contextResetNotificationStrategy),
43 if (m_context ==
nullptr) {
47 if (m_window !=
nullptr && m_context == SDL_GL_GetCurrentContext()) {
48 SDL_GL_MakeCurrent(m_window,
nullptr);
50 if (m_context != s_sharedContext || s_sharedCount == 1) {
51 assert(s_sharedCount > 0);
55 if (s_sharedCount == 0) {
56 s_sharedContext =
nullptr;
58 SDL_GL_DeleteContext(m_context);
61 if (m_hidden_window !=
nullptr) {
62 SDL_DestroyWindow(m_hidden_window);
68 SDL_GL_SwapWindow(m_window);
75 if (m_context ==
nullptr) {
83 if (m_context ==
nullptr) {
92 #ifdef GHOST_OPENGL_ALPHA
93 const bool needAlpha =
true;
95 const bool needAlpha =
false;
98 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, m_contextProfileMask);
99 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, m_contextMajorVersion);
100 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, m_contextMinorVersion);
101 SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, m_contextFlags);
103 SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
104 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
105 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
106 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
107 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
110 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
114 SDL_GL_SetAttribute(SDL_GL_STEREO, 1);
117 if (m_window ==
nullptr) {
118 m_hidden_window = SDL_CreateWindow(
"Offscreen Context Windows",
119 SDL_WINDOWPOS_UNDEFINED,
120 SDL_WINDOWPOS_UNDEFINED,
123 SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS |
126 m_window = m_hidden_window;
129 m_context = SDL_GL_CreateContext(m_window);
133 if (m_context !=
nullptr) {
134 if (!s_sharedContext) {
135 s_sharedContext = m_context;
144 SDL_GL_SwapWindow(m_window);
164 if (SDL_GL_SetSwapInterval(interval) == -1) {
172 intervalOut = SDL_GL_GetSwapInterval();
GHOST_TSuccess swapBuffers()
GHOST_TSuccess initializeDrawingContext()
GHOST_TSuccess releaseNativeHandles()
GHOST_TSuccess getSwapInterval(int &intervalOut)
GHOST_ContextSDL(bool stereoVisual, SDL_Window *window, int contextProfileMask, int contextMajorVersion, int contextMinorVersion, int contextFlags, int contextResetNotificationStrategy)
GHOST_TSuccess activateDrawingContext()
GHOST_TSuccess releaseDrawingContext()
GHOST_TSuccess setSwapInterval(int interval)
static void initClearGL()