-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathcapsGroup.cpp
173 lines (161 loc) · 4.24 KB
/
capsGroup.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*
*
* OpenGL hardware capability viewer and database
*
* OpenGL capability group implementation
*
* Copyright (C) 2011-2015 by Sascha Willems (www.saschawillems.de)
*
* This code is free software, you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 3 as published by the Free Software Foundation.
*
* Please review the following information to ensure the GNU Lesser
* General Public License version 3 requirements will be met:
* http://opensource.org/licenses/lgpl-3.0.html
*
* The code is distributed WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU LGPL 3.0 for more details.
*
*/
#include "capsGroup.h"
namespace capsViewer {
/// <summary>
/// Execute http get request
/// </summary>
/// <param name="idstr">OpenGL enum as string</param>
/// <param name="id">OpenGL enum to query</param>
/// <param name="type">Internal OpenGL enum type (glint, glstring)</param>
/// <param name="dim">No of dimensions to query</param>
void capsGroup::addCapability(string idstr, GLenum id, string type, int dim)
{
string errorValue = "n/a";
// Flush OpenGL error state
glGetError();
if (type == "glint")
{
GLint* intVal;
intVal = new GLint[dim];
glGetIntegerv(id, intVal);
GLint glerr = glGetError();
if (dim == 1)
{
capabilities[idstr] = to_string(intVal[0]);
}
else
{
for (int i = 0; i < dim; i++)
capabilities[idstr + "[" + to_string(i) + "]"] = to_string(intVal[i]);
}
if (glerr != GL_NO_ERROR)
capabilities[idstr] = errorValue;
delete[] intVal;
}
if (type == "glint64")
{
GLint64* intVal;
intVal = new GLint64[dim];
glGetInteger64v(id, intVal);
string valString = "";
for (int i = 0; i < dim; i++) {
if (i > 0) {
valString += " ,";
}
valString += to_string(intVal[i]);
}
GLint glerr = glGetError();
capabilities[idstr] = valString;
if (glerr != GL_NO_ERROR) {
capabilities[idstr] = errorValue;
}
delete[] intVal;
}
if (type == "glintindex")
{
GLint *intVal;
intVal = new GLint[dim];
for (int i = 0; i < dim; i++)
glGetIntegeri_v(id, i, &intVal[i]);
GLint glerr = glGetError();
if (dim == 1)
{
capabilities[idstr] = to_string(intVal[0]);
}
else
{
for (int i = 0; i < dim; i++)
capabilities[idstr+"["+to_string(i)+"]"] = to_string(intVal[i]);
}
if (glerr != GL_NO_ERROR)
capabilities[idstr] = errorValue;
delete[] intVal;
}
if (type == "glintfragmentprogram")
{
GLint* intVal;
intVal = new GLint[dim];
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, id, intVal);
string valString = "";
for (int i = 0; i < dim; i++) {
if (i > 0) {
valString += " ,";
}
valString += to_string(intVal[i]);
}
GLint glerr = glGetError();
capabilities[idstr] = valString;
if (glerr != GL_NO_ERROR) {
capabilities[idstr] = errorValue;
}
delete[] intVal;
}
if (type == "glintvertexprogram")
{
GLint* intVal;
intVal = new GLint[dim];
glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, id, intVal);
string valString = "";
for (int i = 0; i < dim; i++) {
if (i > 0) {
valString += " ,";
}
valString += to_string(intVal[i]);
}
GLint glerr = glGetError();
capabilities[idstr] = valString;
if (glerr != GL_NO_ERROR) {
capabilities[idstr] = errorValue;
}
delete[] intVal;
}
if (type == "glfloat")
{
GLfloat* floatVal;
floatVal = new GLfloat[dim];
glGetFloatv(id, floatVal);
string valString = "";
for (int i = 0; i < dim; i++) {
if (i > 0) {
valString += " ,";
}
valString += to_string(floatVal[i]);
}
GLint glerr = glGetError();
capabilities[idstr] = valString;
if (glerr != GL_NO_ERROR) {
capabilities[idstr] = errorValue;
}
delete[] floatVal;
}
if (type == "glstring")
{
string valString = reinterpret_cast<const char*>(glGetString(id));
GLint glerr = glGetError();
capabilities[idstr] = valString;
if (glerr != GL_NO_ERROR) {
capabilities[idstr] = "";
}
}
}
}