opengl.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2013 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Magnus Norddahl
27 */
28 
29 
30 #pragma once
31 
32 #include "api_gl.h"
33 #include "opengl_defines.h"
34 #include <utility>
35 #include "../Display/Render/texture.h"
36 #include "../Core/System/thread_local_storage.h"
37 
38 namespace clan
39 {
42 
43 class GLFunctions;
44 class GraphicContext;
45 class OpenGLGraphicContextProvider;
46 class GL1GraphicContextProvider;
47 class GL3GraphicContextProvider;
48 
49 enum TextureFormat;
50 
52 typedef void (ProcAddress)();
53 
54 typedef struct
55 {
57  bool valid;
62 
64 class CL_API_GL OpenGL
65 {
68 
69 public:
71  static ProcAddress *get_proc_address(const std::string &function_name);
72 
75 
77  static TextureFormat_GL get_textureformat(TextureFormat format);
78 
80  static void set_active(GraphicContext &gc);
81 
83  static void set_active(const OpenGLGraphicContextProvider * const gc_provider);
84 
90  static bool set_active();
91 
95  static void check_error();
96 
98  static GLuint get_texture_handle(Texture &texture);
99 
103  static Texture from_texture_handle(GLuint type, GLuint handle);
104 
105  static GLenum to_enum(DrawBuffer buf);
106  static GLenum to_enum(CompareFunction func);
107  static GLenum to_enum(StencilOp op);
108  static GLenum to_enum(CullMode mode);
109  static GLenum to_enum(FillMode mode);
110  static GLenum to_enum(BlendFunc func);
111  static GLenum to_enum(BlendEquation eq);
112  static GLenum to_enum(VertexAttributeDataType value);
113  static GLenum to_enum(PrimitivesType value);
114  static GLenum to_enum(LogicOp op);
115  static GLenum to_enum(TextureFilter filter);
116  static GLenum to_enum(TextureWrapMode mode);
117  static GLenum to_enum(TextureCompareMode mode);
118  static GLenum to_cube_target(int index);
119  static GLenum to_enum(BufferUsage usage);
120  static GLenum to_enum(BufferAccess access);
121 
123 
124 private:
128  static void remove_active(const OpenGLGraphicContextProvider * const gc_provider);
129 
130  friend class GL1GraphicContextProvider;
131  friend class GL3GraphicContextProvider;
132  friend class PBuffer_GL1_Impl;
133 
134 };
135 
136 }
137 
TextureFilter
Texture filters.
Definition: texture.h:74
GLenum pixel_format
Definition: opengl.h:59
TextureWrapMode
Texture coordinate wrapping modes.
Definition: texture.h:66
Texture object class.
Definition: texture.h:104
BlendEquation
Blending equations.
Definition: graphic_context.h:204
OpenGL utility class.
Definition: opengl.h:64
#define cl_tls_variable
Definition: thread_local_storage.h:46
DrawBuffer
Drawing buffers.
Definition: graphic_context.h:119
CullMode
Polygon culling modes.
Definition: graphic_context.h:70
unsigned int GLenum
Definition: opengl_defines.h:53
void( ProcAddress)()
Extension procedure address typedef for OpenGL.
Definition: opengl.h:52
TextureCompareMode
Texture compare modes.
Definition: texture.h:85
StencilOp
Stencil operations.
Definition: graphic_context.h:106
int GLint
Definition: opengl_defines.h:58
BufferUsage
Array Buffer usage enum.
Definition: buffer_usage.h:41
FillMode
Polygon filling modes.
Definition: graphic_context.h:78
GLint internal_format
Definition: opengl.h:58
TextureFormat
Texture format.
Definition: texture_format.h:41
static cl_tls_variable GLFunctions * functions
Function table for OpenGL 2.0.
Definition: opengl.h:74
BlendFunc
Blending functions.
Definition: graphic_context.h:155
Interface to drawing graphics.
Definition: graphic_context.h:257
VertexAttributeDataType
Primitives array description.
Definition: primitives_array.h:57
bool valid
True when this is a valid opengl format.
Definition: opengl.h:57
TextureFormat texture_format
Definition: opengl.h:56
CompareFunction
Compare functions.
Definition: graphic_context.h:93
unsigned int GLuint
Definition: opengl_defines.h:62
GLenum pixel_datatype
Definition: opengl.h:60
BufferAccess
Array Buffer access enum.
Definition: buffer_usage.h:55
GLFunctions.
Definition: opengl_wrap.h:51
LogicOp
Logic Op.
Definition: graphic_context.h:134
PrimitivesType
Primitive types.
Definition: graphic_context.h:221
Definition: opengl.h:54