OGLplus (0.52.0) a C++ wrapper for OpenGL

glfunc.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 #ifndef OGLPLUS_GLFUNC_1201020903_HPP
14 #define OGLPLUS_GLFUNC_1201020903_HPP
15 
16 #include <oglplus/config/compiler.hpp>
17 #include <oglplus/config/gl.hpp>
18 
19 #if !OGLPLUS_NO_GLFUNC_CHECKS
20 #include <oglplus/error/glfunc.hpp>
21 #endif
22 
23 namespace oglplus {
24 
25 #if !OGLPLUS_NO_VARIADIC_TEMPLATES && !OGLPLUS_NO_GLFUNC_CHECKS
26 template <typename RV, typename ... Params>
27 inline auto _checked_glfunc(
28  RV (GLAPIENTRY *pfn)(Params...),
29  const char*
30 ) -> decltype(pfn)
31 {
32  return pfn;
33 }
34 
35 template <typename RV, typename ... Params>
36 inline auto _checked_glfunc(
37  RV (* GLAPIENTRY *ppfn)(Params...),
38  const char* func_name
39 ) -> decltype(*ppfn)
40 {
41  OGLPLUS_HANDLE_ERROR_IF(
42  (!ppfn || !*ppfn),
43  GL_INVALID_OPERATION,
44  MissingFunction::Message(),
45  MissingFunction,
46  GLFunc(func_name)
47  );
48  return *ppfn;
49 }
50 
51 #ifndef OGLPLUS_GLFUNC
52 #define OGLPLUS_GLFUNC(FUNCNAME) \
53  ::oglplus::_checked_glfunc(&::gl##FUNCNAME, #FUNCNAME)
54 #endif
55 #ifndef OGLPLUS_GLXFUNC
56 #define OGLPLUS_GLXFUNC(FUNCNAME) \
57  ::oglplus::_checked_glfunc(&::glX##FUNCNAME, #FUNCNAME)
58 #endif
59 #ifndef OGLPLUS_WGLFUNC
60 #define OGLPLUS_WGLFUNC(FUNCNAME) \
61  ::oglplus::_checked_glfunc(&::wgl##FUNCNAME, #FUNCNAME)
62 #endif
63 
64 #else
65 
66 #ifndef OGLPLUS_GLFUNC
67 #define OGLPLUS_GLFUNC(FUNCNAME) ::gl##FUNCNAME
68 #endif
69 #ifndef OGLPLUS_GLXFUNC
70 #define OGLPLUS_GLXFUNC(FUNCNAME) ::glX##FUNCNAME
71 #endif
72 #ifndef OGLPLUS_WGLFUNC
73 #define OGLPLUS_WGLFUNC(FUNCNAME) ::wgl##FUNCNAME
74 #endif
75 
76 #endif
77 
78 
79 } // namespace oglplus
80 
81 #endif // include guard
Declaration of MissingFunction exception.

Copyright © 2010-2014 Matúš Chochlík, University of Žilina, Žilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Mon Sep 22 2014 by Doxygen (version 1.8.6).