opengl.h Source File - ClanLib SDK
Description: opengl.h Source File

opengl.h
1/*
2** ClanLib SDK
3** Copyright (c) 1997-2020 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 "opengl_defines.h"
33#include <utility>
34#include "../Display/Render/texture.h"
35#include "../Core/System/thread_local_storage.h"
36
37namespace clan
38{
41
42 class GLFunctions;
43 class GraphicContext;
44 class OpenGLGraphicContextProvider;
45 class GL1GraphicContextProvider;
46 class GL3GraphicContextProvider;
47
48 enum class TextureFormat;
49
51 typedef void (ProcAddress)();
52
53 typedef struct
54 {
55 TextureFormat texture_format;
56 bool valid;
57 GLint internal_format;
58 GLenum pixel_format;
59 GLenum pixel_datatype;
60 } TextureFormat_GL;
61
62 typedef struct
63 {
64 GLenum source;
65 GLenum type;
66 GLenum severity;
67 GLuint id;
68 std::string message;
69
70 } MessageLog_GL;
71
73 class OpenGL
74 {
75 public:
77 static ProcAddress *get_proc_address(const std::string &function_name);
78
80 static cl_tls_variable GLFunctions *functions;
81
83 static TextureFormat_GL get_textureformat(TextureFormat format);
84
86 static void set_active(GraphicContext &gc);
87
89 static void set_active(const OpenGLGraphicContextProvider * const gc_provider);
90
96 static bool set_active();
97
101 static void check_error();
102
109 static std::vector<MessageLog_GL> get_message_log(GLuint numMsgs);
110
112 static GLuint get_texture_handle(Texture &texture);
113
117 static Texture from_texture_handle(GLuint type, GLuint handle);
118
119 static GLenum to_enum(DrawBuffer buf);
120 static GLenum to_enum(CompareFunction func);
121 static GLenum to_enum(StencilOp op);
122 static GLenum to_enum(CullMode mode);
123 static GLenum to_enum(FillMode mode);
124 static GLenum to_enum(BlendFunc func);
125 static GLenum to_enum(BlendEquation eq);
126 static GLenum to_enum(VertexAttributeDataType value);
127 static GLenum to_enum(PrimitivesType value);
128 static GLenum to_enum(LogicOp op);
129 static GLenum to_enum(TextureFilter filter);
130 static GLenum to_enum(TextureWrapMode mode);
131 static GLenum to_enum(TextureCompareMode mode);
132 static GLenum to_cube_target(int index);
133 static GLenum to_enum(BufferUsage usage);
134 static GLenum to_enum(BufferAccess access);
135
136 private:
140 static void remove_active(const OpenGLGraphicContextProvider * const gc_provider);
141
142 friend class GL1GraphicContextProvider;
143 friend class GL3GraphicContextProvider;
144 friend class PBuffer_GL1_Impl;
145 };
146
148}
clan::GLFunctions
GLFunctions.
Definition opengl_wrap.h:52
clan::GraphicContext
Interface to drawing graphics.
Definition graphic_context.h:257
clan::OpenGL
OpenGL utility class.
Definition opengl.h:74
clan::OpenGL::to_enum
static GLenum to_enum(TextureFilter filter)
clan::OpenGL::get_proc_address
static ProcAddress * get_proc_address(const std::string &function_name)
Get OpenGL extension specific function address.
clan::OpenGL::to_enum
static GLenum to_enum(BufferAccess access)
clan::OpenGL::set_active
static void set_active(GraphicContext &gc)
Sets the thread's OpenGL context to the one used by the graphic context.
clan::OpenGL::to_enum
static GLenum to_enum(BlendFunc func)
clan::OpenGL::to_cube_target
static GLenum to_cube_target(int index)
clan::OpenGL::set_active
static bool set_active()
Sets the thread's OpenGL context to the first valid allocated one.
clan::OpenGL::to_enum
static GLenum to_enum(PrimitivesType value)
clan::OpenGL::to_enum
static GLenum to_enum(CompareFunction func)
clan::OpenGL::set_active
static void set_active(const OpenGLGraphicContextProvider *const gc_provider)
Sets the thread's OpenGL context to the one used by the graphic context.
clan::OpenGL::GL1GraphicContextProvider
friend class GL1GraphicContextProvider
Definition opengl.h:142
clan::OpenGL::to_enum
static GLenum to_enum(LogicOp op)
clan::OpenGL::to_enum
static GLenum to_enum(BlendEquation eq)
clan::OpenGL::to_enum
static GLenum to_enum(TextureWrapMode mode)
clan::OpenGL::to_enum
static GLenum to_enum(DrawBuffer buf)
clan::OpenGL::functions
static cl_tls_variable GLFunctions * functions
Function table for OpenGL 2.0.
Definition opengl.h:80
clan::OpenGL::to_enum
static GLenum to_enum(BufferUsage usage)
clan::OpenGL::get_texture_handle
static GLuint get_texture_handle(Texture &texture)
Returns the OpenGL texture handle.
clan::OpenGL::GL3GraphicContextProvider
friend class GL3GraphicContextProvider
Definition opengl.h:143
clan::OpenGL::to_enum
static GLenum to_enum(TextureCompareMode mode)
clan::OpenGL::PBuffer_GL1_Impl
friend class PBuffer_GL1_Impl
Definition opengl.h:144
clan::OpenGL::to_enum
static GLenum to_enum(FillMode mode)
clan::OpenGL::to_enum
static GLenum to_enum(CullMode mode)
clan::OpenGL::from_texture_handle
static Texture from_texture_handle(GLuint type, GLuint handle)
Creates a texture object from an OpenGL texture handle.
clan::OpenGL::to_enum
static GLenum to_enum(StencilOp op)
clan::OpenGL::check_error
static void check_error()
Throw an exception if an OpenGL error was detected ( Using glGetError() ).
clan::OpenGL::get_message_log
static std::vector< MessageLog_GL > get_message_log(GLuint numMsgs)
Get the OpenGL message log.
clan::OpenGL::to_enum
static GLenum to_enum(VertexAttributeDataType value)
clan::OpenGL::get_textureformat
static TextureFormat_GL get_textureformat(TextureFormat format)
Returns the opengl texture format.
clan::Texture
Texture object class.
Definition texture.h:103
clan::BlendFunc
BlendFunc
Blending functions.
Definition graphic_context.h:154
clan::CompareFunction
CompareFunction
Compare functions.
Definition graphic_context.h:92
clan::TextureFormat
TextureFormat
Texture format.
Definition texture_format.h:39
clan::PrimitivesType
PrimitivesType
Primitive types.
Definition graphic_context.h:220
clan::BufferAccess
BufferAccess
Array Buffer access enum.
Definition buffer_usage.h:53
clan::FillMode
FillMode
Polygon filling modes.
Definition graphic_context.h:77
clan::LogicOp
LogicOp
Logic Op.
Definition graphic_context.h:133
clan::TextureCompareMode
TextureCompareMode
Texture compare modes.
Definition texture.h:84
clan::StencilOp
StencilOp
Stencil operations.
Definition graphic_context.h:105
clan::DrawBuffer
DrawBuffer
Drawing buffers.
Definition graphic_context.h:118
clan::TextureFilter
TextureFilter
Texture filters.
Definition texture.h:73
clan::TextureWrapMode
TextureWrapMode
Texture coordinate wrapping modes.
Definition texture.h:65
clan::VertexAttributeDataType
VertexAttributeDataType
Primitives array description.
Definition primitives_array.h:56
clan::CullMode
CullMode
Polygon culling modes.
Definition graphic_context.h:69
clan::BufferUsage
BufferUsage
Array Buffer usage enum.
Definition buffer_usage.h:39
clan::BlendEquation
BlendEquation
Blending equations.
Definition graphic_context.h:203
clan::GLint
int GLint
Definition opengl_defines.h:59
clan::GLenum
unsigned int GLenum
Definition opengl_defines.h:54
clan::GLuint
unsigned int GLuint
Definition opengl_defines.h:63
clan::ProcAddress
void ProcAddress()
Extension procedure address typedef for OpenGL.
Definition opengl.h:51
clan
Definition clanapp.h:36
clan::MessageLog_GL
Definition opengl.h:63
clan::MessageLog_GL::id
GLuint id
Definition opengl.h:67
clan::MessageLog_GL::source
GLenum source
Definition opengl.h:64
clan::MessageLog_GL::severity
GLenum severity
Definition opengl.h:66
clan::MessageLog_GL::type
GLenum type
Definition opengl.h:65
clan::MessageLog_GL::message
std::string message
Definition opengl.h:68
clan::TextureFormat_GL
Definition opengl.h:54
clan::TextureFormat_GL::texture_format
TextureFormat texture_format
Definition opengl.h:55
clan::TextureFormat_GL::pixel_datatype
GLenum pixel_datatype
Definition opengl.h:59
clan::TextureFormat_GL::pixel_format
GLenum pixel_format
Definition opengl.h:58
clan::TextureFormat_GL::internal_format
GLint internal_format
Definition opengl.h:57
clan::TextureFormat_GL::valid
bool valid
True when this is a valid opengl format.
Definition opengl.h:56