2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2014 Blender Foundation.
19 * All rights reserved.
21 * The Original Code is: all of this file.
23 * Contributor(s): Jason Wilkins
25 * ***** END GPL LICENSE BLOCK *****
28 /** \file ghost/intern/GHOST_ContextSDL.h
32 #ifndef __GHOST_CONTEXTSDL_H__
33 #define __GHOST_CONTEXTSDL_H__
35 #include "GHOST_Context.h"
42 #ifndef GHOST_OPENGL_SDL_CONTEXT_FLAGS
43 #define GHOST_OPENGL_SDL_CONTEXT_FLAGS 0
46 #ifndef GHOST_OPENGL_SDL_RESET_NOTIFICATION_STRATEGY
47 #define GHOST_OPENGL_SDL_RESET_NOTIFICATION_STRATEGY 0
51 class GHOST_ContextSDL : public GHOST_Context
59 GHOST_TUns16 numOfAASamples,
61 int contextProfileMask,
62 int contextMajorVersion,
63 int contextMinorVersion,
65 int contextResetNotificationStrategy);
70 virtual ~GHOST_ContextSDL();
73 * Swaps front and back buffers of a window.
74 * \return A boolean success indicator.
76 virtual GHOST_TSuccess swapBuffers();
79 * Activates the drawing context of this window.
80 * \return A boolean success indicator.
82 virtual GHOST_TSuccess activateDrawingContext();
85 * Call immediately after new to initialize. If this fails then immediately delete the object.
86 * \return Indication as to whether initialization has succeeded.
88 virtual GHOST_TSuccess initializeDrawingContext();
91 * Removes references to native handles from this context and then returns
92 * \return GHOST_kSuccess if it is OK for the parent to release the handles and
93 * GHOST_kFailure if releasing the handles will interfere with sharing
95 virtual GHOST_TSuccess releaseNativeHandles();
98 * Sets the swap interval for swapBuffers.
99 * \param interval The swap interval to use.
100 * \return A boolean success indicator.
102 virtual GHOST_TSuccess setSwapInterval(int interval);
105 * Gets the current swap interval for swapBuffers.
106 * \param intervalOut Variable to store the swap interval if it can be read.
107 * \return Whether the swap interval can be read.
109 virtual GHOST_TSuccess getSwapInterval(int &intervalOut);
112 SDL_Window *m_window;
114 const int m_contextProfileMask;
115 const int m_contextMajorVersion;
116 const int m_contextMinorVersion;
117 const int m_contextFlags;
118 const int m_contextResetNotificationStrategy;
120 SDL_GLContext m_context; /* m_sdl_glcontext */
122 /** The first created OpenGL context (for sharing display lists) */
123 static SDL_GLContext s_sharedContext;
124 static int s_sharedCount;
127 #endif // __GHOST_CONTEXTSDL_H__