1 /* ResidualVM - A 3D game interpreter
2  *
3  * ResidualVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef GRAPHICS_OPENGL_CONTEXT_H
24 #define GRAPHICS_OPENGL_CONTEXT_H
25 
26 #include "common/singleton.h"
27 
28 namespace OpenGL {
29 
30 enum ContextType {
31 	kContextGL,
32 	kContextGLES2
33 };
34 
35 /**
36  * Description structure of the OpenGL (ES) context.
37  *
38  * This class is based on LordHoto's OpenGL backend for ScummVM
39  */
40 class Context : public Common::Singleton<Context> {
41 public:
42 	Context();
43 
44 	/**
45 	 * Initialize the context description from currently active context.
46 	 *
47 	 * The extensions and features are marked as available according
48 	 * to the current context capabilities.
49 	 */
50 	void initialize(ContextType contextType);
51 
52 	/**
53 	 * Reset context.
54 	 *
55 	 * This marks all extensions as unavailable.
56 	 */
57 	void reset();
58 
59 	/** The type of the active context. */
60 	ContextType type;
61 
62 	/** The maximum texture size supported by the context. */
63 	int maxTextureSize;
64 
65 	/** Whether GL_ARB_texture_non_power_of_two is available or not. */
66 	bool NPOTSupported;
67 
68 	/** Whether shader support is available or not. */
69 	bool shadersSupported;
70 
71 	/** Whether FBO support is available or not. */
72 	bool framebufferObjectSupported;
73 
74 	/** Whether multisample FBO support is available or not */
75 	bool framebufferObjectMultisampleSupported;
76 
77 	/**
78 	 * Contains the maximum number of supported multisample samples
79 	 * if multisample FBOs are supported. Contains -1 otherwise.
80 	 */
81 	int multisampleMaxSamples;
82 
83 	/** Whether packing the depth and stencil buffers is possible or not. */
84 	bool packedDepthStencilSupported;
85 
86 	/** Whether specifying a pitch when uploading to textures is available or not */
87 	bool unpackSubImageSupported;
88 
89 	int getGLSLVersion() const;
90 };
91 
92 } // End of namespace OpenGL
93 
94 /** Shortcut for accessing the active OpenGL context. */
95 #define OpenGLContext OpenGL::Context::instance()
96 
97 #endif
98