-
Notifications
You must be signed in to change notification settings - Fork 28
/
internalFormatTarget.cpp
170 lines (144 loc) · 7.27 KB
/
internalFormatTarget.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
/*
*
* OpenGL hardware capability viewer and database
*
* OpenGL internal format description
*
* 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 "internalFormatTarget.h"
#include <GL/glew.h>
namespace capsViewer {
using namespace std;
internalFormatTarget::internalFormatTarget(GLenum target, vector<GLint> compressedFormats)
{
this->target = target;
// Base formats
GLint baseFormats[] = { GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL, GL_STENCIL_INDEX, GL_RED, GL_RG, GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT32F };
for (auto& baseFormat : baseFormats) {
this->textureFormats.push_back(internalFormatInfo(baseFormat));
}
// Add detected compressed texture formats
for (auto& compressedFormat : compressedFormats) {
this->textureFormats.push_back(internalFormatInfo(compressedFormat));
}
}
void internalFormatTarget::getInternalFormatInfo(bool internalformatquery2)
{
// TODO : List of internalFormats from xml
// TODO : Additional formats
//internalFormats[GL_RGBA8] = "GL_RGBA8";
//internalFormats[GL_RGBA16] = "GL_RGBA16";
//internalFormats[GL_DEPTH_COMPONENT16] = "GL_DEPTH_COMPONENT16";
for (auto& textureFormat : textureFormats) {
// Check if internal format is supported
GLint formatSupported;
glGetInternalformativ(target, textureFormat.textureFormat, GL_INTERNALFORMAT_SUPPORTED, 1, &formatSupported);
textureFormat.supported = (formatSupported == GL_TRUE);
if (!textureFormat.supported) {
continue;
}
// Add value info description
// TODO : from xml? Easier to maitain and expand
// GL_ARB_internalformat_query
textureFormat.addValueInfo(infoTypeValue, GL_INTERNALFORMAT_PREFERRED, "GL_INTERNALFORMAT_PREFERRED");
textureFormat.addValueInfo(infoTypeValue, GL_READ_PIXELS_FORMAT, "GL_READ_PIXELS_FORMAT");
textureFormat.addValueInfo(infoTypeValue, GL_READ_PIXELS_TYPE, "GL_READ_PIXELS_TYPE");
textureFormat.addValueInfo(infoTypeValue, GL_TEXTURE_IMAGE_FORMAT, "GL_TEXTURE_IMAGE_FORMAT");
textureFormat.addValueInfo(infoTypeValue, GL_TEXTURE_IMAGE_TYPE, "GL_TEXTURE_IMAGE_TYPE");
textureFormat.addValueInfo(infoTypeValue, GL_GET_TEXTURE_IMAGE_FORMAT, "GL_GET_TEXTURE_IMAGE_FORMAT");
textureFormat.addValueInfo(infoTypeValue, GL_GET_TEXTURE_IMAGE_TYPE, "GL_GET_TEXTURE_IMAGE_TYPE");
// Compressed format block sizes
GLint compressedFormat;
glGetInternalformativ(target, textureFormat.textureFormat, GL_TEXTURE_COMPRESSED, 1, &compressedFormat);
if (compressedFormat == GL_TRUE) {
textureFormat.addValueInfo(infoTypeValue, GL_TEXTURE_COMPRESSED_BLOCK_WIDTH, "GL_TEXTURE_COMPRESSED_BLOCK_WIDTH");
textureFormat.addValueInfo(infoTypeValue, GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT, "GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT");
textureFormat.addValueInfo(infoTypeValue, GL_TEXTURE_COMPRESSED_BLOCK_SIZE, "GL_TEXTURE_COMPRESSED_BLOCK_SIZE");
}
if (internalformatquery2) {
textureFormat.addValueInfo(infoTypeValue, GL_INTERNALFORMAT_SUPPORTED, "GL_INTERNALFORMAT_SUPPORTED");
textureFormat.addValueInfo(infoTypeValue, GL_TEXTURE_COMPRESSED, "GL_TEXTURE_COMPRESSED");
textureFormat.addValueInfo(infoTypeValue, GL_MAX_WIDTH, "GL_MAX_WIDTH");
textureFormat.addValueInfo(infoTypeValue, GL_MAX_HEIGHT, "GL_MAX_HEIGHT");
textureFormat.addValueInfo(infoTypeValue, GL_MAX_DEPTH, "GL_MAX_DEPTH");
textureFormat.addValueInfo(infoTypeValue, GL_FRAMEBUFFER_BLEND, "GL_FRAMEBUFFER_BLEND");
textureFormat.addValueInfo(infoTypeValue, GL_READ_PIXELS, "GL_READ_PIXELS");
textureFormat.addValueInfo(infoTypeValue, GL_MANUAL_GENERATE_MIPMAP, "GL_MANUAL_GENERATE_MIPMAP");
textureFormat.addValueInfo(infoTypeValue, GL_AUTO_GENERATE_MIPMAP, "GL_AUTO_GENERATE_MIPMAP");
textureFormat.addValueInfo(infoTypeValue, GL_FILTER, "GL_FILTER");
}
// Support
textureFormat.addValueInfo(infoTypeSupport, GL_VERTEX_TEXTURE, "GL_VERTEX_TEXTURE");
textureFormat.addValueInfo(infoTypeSupport, GL_TESS_CONTROL_TEXTURE, "GL_TESS_CONTROL_TEXTURE");
textureFormat.addValueInfo(infoTypeSupport, GL_TESS_EVALUATION_TEXTURE, "GL_TESS_EVALUATION_TEXTURE");
textureFormat.addValueInfo(infoTypeSupport, GL_GEOMETRY_TEXTURE, "GL_GEOMETRY_TEXTURE");
textureFormat.addValueInfo(infoTypeSupport, GL_FRAGMENT_TEXTURE, "GL_FRAGMENT_TEXTURE");
textureFormat.addValueInfo(infoTypeSupport, GL_COMPUTE_TEXTURE, "GL_COMPUTE_TEXTURE");
textureFormat.addValueInfo(infoTypeSupport, GL_TEXTURE_SHADOW, "GL_TEXTURE_SHADOW");
textureFormat.addValueInfo(infoTypeSupport, GL_TEXTURE_GATHER, "GL_TEXTURE_GATHER");
textureFormat.addValueInfo(infoTypeSupport, GL_TEXTURE_GATHER_SHADOW, "GL_TEXTURE_GATHER_SHADOW");
textureFormat.addValueInfo(infoTypeSupport, GL_SHADER_IMAGE_LOAD, "GL_SHADER_IMAGE_LOAD");
textureFormat.addValueInfo(infoTypeSupport, GL_SHADER_IMAGE_STORE, "GL_SHADER_IMAGE_STORE");
textureFormat.addValueInfo(infoTypeSupport, GL_SHADER_IMAGE_ATOMIC, "GL_SHADER_IMAGE_ATOMIC");
// Fetch values
for (auto& formatInfoValue : textureFormat.formatInfoValues) {
glGetInternalformativ(target, textureFormat.textureFormat, formatInfoValue.infoEnum, 1, &formatInfoValue.infoValue);
// TODO : Check glerror
}
}
/*
for (auto& internalFormat : internalFormats) {
for (auto& pname : pnames) {
GLint param;
glGetInternalformativ(target, internalFormat.first, pname.first, 1, ¶m);
if ((pname.second == "GL_MAX_WIDTH") || (pname.second == "GL_MAX_HEIGHT") || (pname.second == "GL_MAX_DEPTH")) {
if (param == 0) {
continue;
}
}
QTreeWidgetItem *paramItem = new QTreeWidgetItem(formatItem);
paramItem->setText(0, QString::fromStdString(pname.second));
string enumString;
enumString = core.getEnumName(param);
// Switch some values
if ((pname.first == GL_INTERNALFORMAT_SUPPORTED) || (pname.first == GL_TEXTURE_COMPRESSED)) {
enumString = (param == 0) ? "GL_FALSE" : "GL_TRUE";
}
paramItem->setText(1, QString::fromStdString(enumString));
paramItem->addChild(formatItem);
colorInternalFormatItem(paramItem, 1);
}
QTreeWidgetItem *subItem;
// Different supports
subItem = new QTreeWidgetItem(formatItem);
subItem->setText(0, "Shader support");
for (auto& supportType : supportList) {
GLint param;
glGetInternalformativ(target, internalFormat.first, supportType.first, 1, ¶m);
string enumString;
enumString = core.getEnumName(param);
QTreeWidgetItem *paramItem = new QTreeWidgetItem(subItem);
paramItem->setText(0, QString::fromStdString(supportType.second));
paramItem->setText(1, QString::fromStdString(enumString));
paramItem->addChild(subItem);
colorInternalFormatItem(paramItem, 1);
}
targetItem->sortChildren(0, Qt::AscendingOrder);
}
*/
}
}