Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
glResources.inl
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef DVD_GL_RESOURCES_INL_
34#define DVD_GL_RESOURCES_INL_
35
36namespace Divide {
37namespace GLUtil {
38
39template<typename T>
40void getGLValue(const gl46core::GLenum param, T& value, const gl46core::GLint index)
41{
42 gl46core::GLint valueTemp = 0;
43 if (index < 0)
44 {
45 gl46core::glGetIntegerv(param, &valueTemp);
46 }
47 else
48 {
49 gl46core::glGetIntegeri_v(param, static_cast<gl46core::GLuint>(index), &valueTemp);
50 }
51
52 value = static_cast<T>(valueTemp);
53}
54
55template<typename T>
56void getGLValue(const gl46core::GLenum param, T* value)
57{
58 gl46core::glGetIntegerv(param, value);
59}
60
61template<>
62inline void getGLValue(const gl46core::GLenum param, U32& value, const gl46core::GLint index)
63{
64 value = static_cast<U32>(getGLValueIndexed<gl46core::GLint>(param, index));
65}
66
67template<>
68inline void getGLValue(const gl46core::GLenum param, F32& value, const gl46core::GLint index)
69{
70 if (index < 0)
71 {
72 gl46core::glGetFloatv(param, &value);
73 }
74 else
75 {
76 gl46core::glGetFloati_v(param, static_cast<gl46core::GLuint>(index), &value);
77 }
78}
79
80template<>
81inline void getGLValue(const gl46core::GLenum param, gl46core::GLboolean& value, const gl46core::GLint index)
82{
83 if (index < 0)
84 {
85 gl46core::glGetBooleanv(param, &value);
86 }
87 else
88 {
89 gl46core::glGetBooleani_v(param, static_cast<gl46core::GLuint>(index), &value);
90 }
91}
92
93template<>
94inline void getGLValue(const gl46core::GLenum param, D64& value, const gl46core::GLint index)
95{
96 if (index < 0)
97 {
98 gl46core::glGetDoublev(param, &value);
99 }
100 else
101 {
102 gl46core::glGetDoublei_v(param, static_cast<gl46core::GLuint>(index), &value);
103 }
104}
105
106template<>
107inline void getGLValue(const gl46core::GLenum param, gl46core::GLint64& value, const gl46core::GLint index)
108{
109 if (index < 0)
110 {
111 gl46core::glGetInteger64v(param, &value);
112 }
113 else
114 {
115 gl46core::glGetInteger64i_v(param, static_cast<gl46core::GLuint>(index), &value);
116 }
117}
118
119template<typename T>
120T getGLValue( gl46core::GLenum param)
121{
122 T ret = {};
123 getGLValue(param, ret, -1);
124 return ret;
125}
126
127template<typename T>
128T getGLValueIndexed( gl46core::GLenum param, gl46core::GLint index)
129{
130 T ret = {};
131 getGLValue(param, ret, index);
132 return ret;
133}
134
135}; // namespace GLUtil
136}; // namespace Divide
137
138#endif //DVD_GL_RESOURCES_INL_
void getGLValue(gl46core::GLenum param, T &value, gl46core::GLint index=-1)
Wrapper for glGetIntegerv.
Definition: glResources.inl:40
T getGLValueIndexed(gl46core::GLenum param, gl46core::GLint index=-1)
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
double D64
uint32_t U32