21 int contextProfileMask,
22 int contextMajorVersion,
23 int contextMinorVersion,
25 int contextResetNotificationStrategy)
29 context_profile_mask_(contextProfileMask),
30 context_major_version_(contextMajorVersion),
31 context_minor_version_(contextMinorVersion),
32 context_flags_(contextFlags),
33 context_reset_notification_strategy_(contextResetNotificationStrategy),
41 if (context_ ==
nullptr) {
45 if (window_ !=
nullptr && context_ == SDL_GL_GetCurrentContext()) {
46 SDL_GL_MakeCurrent(window_,
nullptr);
48 if (context_ != s_sharedContext || s_sharedCount == 1) {
53 if (s_sharedCount == 0) {
54 s_sharedContext =
nullptr;
56 SDL_GL_DeleteContext(context_);
59 if (hidden_window_ !=
nullptr) {
60 SDL_DestroyWindow(hidden_window_);
92 const bool needAlpha =
false;
94 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, context_profile_mask_);
95 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, context_major_version_);
96 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, context_minor_version_);
97 SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, context_flags_);
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 (window_ ==
nullptr) {
114 hidden_window_ = SDL_CreateWindow(
"Offscreen Context Windows",
115 SDL_WINDOWPOS_UNDEFINED,
116 SDL_WINDOWPOS_UNDEFINED,
119 SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS |
122 window_ = hidden_window_;
125 context_ = SDL_GL_CreateContext(window_);
129 if (context_ !=
nullptr) {
130 if (!s_sharedContext) {
131 s_sharedContext = context_;
145 SDL_GL_SwapWindow(window_);
~GHOST_ContextSDL() override
GHOST_TSuccess swapBufferRelease() override
GHOST_TSuccess releaseDrawingContext() override
GHOST_ContextSDL(const GHOST_ContextParams &context_params, SDL_Window *window, int contextProfileMask, int contextMajorVersion, int contextMinorVersion, int contextFlags, int contextResetNotificationStrategy)
GHOST_TSuccess initializeDrawingContext() override
GHOST_TSuccess activateDrawingContext() override
GHOST_TSuccess releaseNativeHandles() override
GHOST_TSuccess setSwapInterval(int interval) override
GHOST_TSuccess getSwapInterval(int &interval_out) override
GHOST_Context(const GHOST_ContextParams &context_params)
static GHOST_Context * active_context_
virtual GHOST_TVSyncModes getVSync()
GHOST_ContextParams context_params_