Skip to content

Commit 0ad9230

Browse files
christiankerlxlz
authored andcommitted
changed minimal opengl version to 3.1
1 parent 7691a03 commit 0ad9230

File tree

9 files changed

+88
-71
lines changed

9 files changed

+88
-71
lines changed

examples/protonect/src/flextGL.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ int flextInit(GLFWwindow* window, OpenGLBindings *bindings)
2424

2525
/* --- Check for minimal version and profile --- */
2626

27-
if (major * 10 + minor < 33) {
28-
fprintf(stderr, "Error: OpenGL version 3.3 not supported.\n");
27+
if (major * 10 + minor < 31) {
28+
fprintf(stderr, "Error: OpenGL version 3.1 not supported.\n");
2929
fprintf(stderr, " Your version is %d.%d.\n", major, minor);
3030
fprintf(stderr, " Try updating your graphics driver.\n");
3131
return GL_FALSE;
@@ -306,7 +306,7 @@ void flextLoadOpenGLFunctions(OpenGLBindings *bindings)
306306
bindings->glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDING_PROC*)glfwGetProcAddress("glUniformBlockBinding");
307307

308308
/* GL_VERSION_3_2 */
309-
309+
/*
310310
bindings->glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEX_PROC*)glfwGetProcAddress("glDrawElementsBaseVertex");
311311
bindings->glDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEX_PROC*)glfwGetProcAddress("glDrawRangeElementsBaseVertex");
312312
bindings->glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEX_PROC*)glfwGetProcAddress("glDrawElementsInstancedBaseVertex");
@@ -326,9 +326,9 @@ void flextLoadOpenGLFunctions(OpenGLBindings *bindings)
326326
bindings->glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLE_PROC*)glfwGetProcAddress("glTexImage3DMultisample");
327327
bindings->glGetMultisamplefv = (PFNGLGETMULTISAMPLEFV_PROC*)glfwGetProcAddress("glGetMultisamplefv");
328328
bindings->glSampleMaski = (PFNGLSAMPLEMASKI_PROC*)glfwGetProcAddress("glSampleMaski");
329-
329+
*/
330330
/* GL_VERSION_3_3 */
331-
331+
/*
332332
bindings->glBindFragDataLocationIndexed = (PFNGLBINDFRAGDATALOCATIONINDEXED_PROC*)glfwGetProcAddress("glBindFragDataLocationIndexed");
333333
bindings->glGetFragDataIndex = (PFNGLGETFRAGDATAINDEX_PROC*)glfwGetProcAddress("glGetFragDataIndex");
334334
bindings->glGenSamplers = (PFNGLGENSAMPLERS_PROC*)glfwGetProcAddress("glGenSamplers");
@@ -357,7 +357,7 @@ void flextLoadOpenGLFunctions(OpenGLBindings *bindings)
357357
bindings->glVertexAttribP3uiv = (PFNGLVERTEXATTRIBP3UIV_PROC*)glfwGetProcAddress("glVertexAttribP3uiv");
358358
bindings->glVertexAttribP4ui = (PFNGLVERTEXATTRIBP4UI_PROC*)glfwGetProcAddress("glVertexAttribP4ui");
359359
bindings->glVertexAttribP4uiv = (PFNGLVERTEXATTRIBP4UIV_PROC*)glfwGetProcAddress("glVertexAttribP4uiv");
360-
360+
*/
361361
}
362362

363363
/* ----------------------- Extension flag definitions ---------------------- */

examples/protonect/src/flextGL.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ typedef struct __GLsync *GLsync;
841841
#define GL_INVALID_INDEX 0xFFFFFFFFu
842842

843843
/* GL_VERSION_3_2 */
844-
844+
/*
845845
#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001
846846
#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002
847847
#define GL_LINES_ADJACENCY 0x000A
@@ -906,9 +906,9 @@ typedef struct __GLsync *GLsync;
906906
#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E
907907
#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F
908908
#define GL_MAX_INTEGER_SAMPLES 0x9110
909-
909+
*/
910910
/* GL_VERSION_3_3 */
911-
911+
/*
912912
#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE
913913
#define GL_SRC1_COLOR 0x88F9
914914
#define GL_ONE_MINUS_SRC1_COLOR 0x88FA
@@ -925,7 +925,7 @@ typedef struct __GLsync *GLsync;
925925
#define GL_TIME_ELAPSED 0x88BF
926926
#define GL_TIMESTAMP 0x8E28
927927
#define GL_INT_2_10_10_10_REV 0x8D9F
928-
928+
*/
929929
/* --------------------------- FUNCTION PROTOTYPES --------------------------- */
930930

931931

@@ -1258,7 +1258,7 @@ typedef void (APIENTRY PFNGLGETACTIVEUNIFORMBLOCKNAME_PROC (GLuint program, GLui
12581258
typedef void (APIENTRY PFNGLUNIFORMBLOCKBINDING_PROC (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding));
12591259

12601260
/* GL_VERSION_3_2 */
1261-
1261+
/*
12621262
typedef void (APIENTRY PFNGLDRAWELEMENTSBASEVERTEX_PROC (GLenum mode, GLsizei count, GLenum type, const void * indices, GLint basevertex));
12631263
typedef void (APIENTRY PFNGLDRAWRANGEELEMENTSBASEVERTEX_PROC (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices, GLint basevertex));
12641264
typedef void (APIENTRY PFNGLDRAWELEMENTSINSTANCEDBASEVERTEX_PROC (GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLint basevertex));
@@ -1278,9 +1278,9 @@ typedef void (APIENTRY PFNGLTEXIMAGE2DMULTISAMPLE_PROC (GLenum target, GLsizei s
12781278
typedef void (APIENTRY PFNGLTEXIMAGE3DMULTISAMPLE_PROC (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations));
12791279
typedef void (APIENTRY PFNGLGETMULTISAMPLEFV_PROC (GLenum pname, GLuint index, GLfloat * val));
12801280
typedef void (APIENTRY PFNGLSAMPLEMASKI_PROC (GLuint maskNumber, GLbitfield mask));
1281-
1281+
*/
12821282
/* GL_VERSION_3_3 */
1283-
1283+
/*
12841284
typedef void (APIENTRY PFNGLBINDFRAGDATALOCATIONINDEXED_PROC (GLuint program, GLuint colorNumber, GLuint index, const GLchar * name));
12851285
typedef GLint (APIENTRY PFNGLGETFRAGDATAINDEX_PROC (GLuint program, const GLchar * name));
12861286
typedef void (APIENTRY PFNGLGENSAMPLERS_PROC (GLsizei count, GLuint * samplers));
@@ -1309,7 +1309,7 @@ typedef void (APIENTRY PFNGLVERTEXATTRIBP3UI_PROC (GLuint index, GLenum type, GL
13091309
typedef void (APIENTRY PFNGLVERTEXATTRIBP3UIV_PROC (GLuint index, GLenum type, GLboolean normalized, const GLuint * value));
13101310
typedef void (APIENTRY PFNGLVERTEXATTRIBP4UI_PROC (GLuint index, GLenum type, GLboolean normalized, GLuint value));
13111311
typedef void (APIENTRY PFNGLVERTEXATTRIBP4UIV_PROC (GLuint index, GLenum type, GLboolean normalized, const GLuint * value));
1312-
1312+
*/
13131313
struct OpenGLBindings
13141314
{
13151315

@@ -1574,7 +1574,7 @@ struct OpenGLBindings
15741574
PFNGLUNIFORMBLOCKBINDING_PROC* glUniformBlockBinding;
15751575

15761576
/* GL_VERSION_3_2 */
1577-
1577+
/*
15781578
PFNGLDRAWELEMENTSBASEVERTEX_PROC* glDrawElementsBaseVertex;
15791579
PFNGLDRAWRANGEELEMENTSBASEVERTEX_PROC* glDrawRangeElementsBaseVertex;
15801580
PFNGLDRAWELEMENTSINSTANCEDBASEVERTEX_PROC* glDrawElementsInstancedBaseVertex;
@@ -1594,9 +1594,9 @@ struct OpenGLBindings
15941594
PFNGLTEXIMAGE3DMULTISAMPLE_PROC* glTexImage3DMultisample;
15951595
PFNGLGETMULTISAMPLEFV_PROC* glGetMultisamplefv;
15961596
PFNGLSAMPLEMASKI_PROC* glSampleMaski;
1597-
1597+
*/
15981598
/* GL_VERSION_3_3 */
1599-
1599+
/*
16001600
PFNGLBINDFRAGDATALOCATIONINDEXED_PROC* glBindFragDataLocationIndexed;
16011601
PFNGLGETFRAGDATAINDEX_PROC* glGetFragDataIndex;
16021602
PFNGLGENSAMPLERS_PROC* glGenSamplers;
@@ -1625,6 +1625,7 @@ struct OpenGLBindings
16251625
PFNGLVERTEXATTRIBP3UIV_PROC* glVertexAttribP3uiv;
16261626
PFNGLVERTEXATTRIBP4UI_PROC* glVertexAttribP4ui;
16271627
PFNGLVERTEXATTRIBP4UIV_PROC* glVertexAttribP4uiv;
1628+
*/
16281629
};
16291630

16301631
typedef struct OpenGLBindings OpenGLBindings;

examples/protonect/src/opengl_depth_packet_processor.cpp

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
#include <GLFW/glfw3.h>
3333

3434
#include <fstream>
35-
35+
#include <string>
36+
#include <map>
3637

3738
#include <stdint.h>
3839

@@ -117,6 +118,8 @@ bool loadBufferFromFile(const std::string& filename, unsigned char *buffer, size
117118

118119
struct ShaderProgram : public WithOpenGLBindings
119120
{
121+
typedef std::map<std::string, int> FragDataMap;
122+
FragDataMap frag_data_map_;
120123
GLuint program, vertex_shader, fragment_shader;
121124

122125
char error_buffer[2048];
@@ -144,6 +147,11 @@ struct ShaderProgram : public WithOpenGLBindings
144147
gl()->glShaderSource(fragment_shader, 1, &src_, &length_);
145148
}
146149

150+
void bindFragDataLocation(const std::string &name, int output)
151+
{
152+
frag_data_map_[name] = output;
153+
}
154+
147155
void build()
148156
{
149157
GLint status;
@@ -172,6 +180,11 @@ struct ShaderProgram : public WithOpenGLBindings
172180
gl()->glAttachShader(program, vertex_shader);
173181
gl()->glAttachShader(program, fragment_shader);
174182

183+
for(FragDataMap::iterator it = frag_data_map_.begin(); it != frag_data_map_.end(); ++it)
184+
{
185+
gl()->glBindFragDataLocation(program, it->second, it->first.c_str());
186+
}
187+
175188
gl()->glLinkProgram(program);
176189

177190
gl()->glGetProgramiv(program, GL_LINK_STATUS, &status);
@@ -469,24 +482,39 @@ struct OpenGLDepthPacketProcessorImpl : public WithOpenGLBindings, public WithPe
469482

470483
stage1.setVertexShader(loadShaderSource(shader_folder + "default.vs"));
471484
stage1.setFragmentShader(loadShaderSource(shader_folder + "stage1.fs"));
485+
stage1.bindFragDataLocation("Debug", 0);
486+
stage1.bindFragDataLocation("A", 1);
487+
stage1.bindFragDataLocation("B", 2);
488+
stage1.bindFragDataLocation("Norm", 3);
489+
stage1.bindFragDataLocation("Infrared", 4);
472490
stage1.build();
473491

474492
filter1.setVertexShader(loadShaderSource(shader_folder + "default.vs"));
475493
filter1.setFragmentShader(loadShaderSource(shader_folder + "filter1.fs"));
494+
filter1.bindFragDataLocation("Debug", 0);
495+
filter1.bindFragDataLocation("FilterA", 1);
496+
filter1.bindFragDataLocation("FilterB", 2);
497+
filter1.bindFragDataLocation("MaxEdgeTest", 3);
476498
filter1.build();
477499

478500
stage2.setVertexShader(loadShaderSource(shader_folder + "default.vs"));
479501
stage2.setFragmentShader(loadShaderSource(shader_folder + "stage2.fs"));
502+
stage2.bindFragDataLocation("Debug", 0);
503+
stage2.bindFragDataLocation("Depth", 1);
504+
stage2.bindFragDataLocation("DepthAndIrSum", 2);
480505
stage2.build();
481506

482507
filter2.setVertexShader(loadShaderSource(shader_folder + "default.vs"));
483508
filter2.setFragmentShader(loadShaderSource(shader_folder + "filter2.fs"));
509+
filter2.bindFragDataLocation("Debug", 0);
510+
filter2.bindFragDataLocation("FilterDepth", 1);
484511
filter2.build();
485512

486513
if(do_debug)
487514
{
488515
debug.setVertexShader(loadShaderSource(shader_folder + "default.vs"));
489516
debug.setFragmentShader(loadShaderSource(shader_folder + "debug.fs"));
517+
debug.bindFragDataLocation("Debug", 0);
490518
debug.build();
491519
}
492520

@@ -545,11 +573,11 @@ struct OpenGLDepthPacketProcessorImpl : public WithOpenGLBindings, public WithPe
545573
gl()->glBindBuffer(GL_ARRAY_BUFFER, square_vbo);
546574
gl()->glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
547575

548-
GLint position_attr = stage1.getAttributeLocation("Position");
576+
GLint position_attr = stage1.getAttributeLocation("InputPosition");
549577
gl()->glVertexAttribPointer(position_attr, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (GLvoid*)0);
550578
gl()->glEnableVertexAttribArray(position_attr);
551579

552-
GLint texcoord_attr = stage1.getAttributeLocation("TexCoord");
580+
GLint texcoord_attr = stage1.getAttributeLocation("InputTexCoord");
553581
gl()->glVertexAttribPointer(texcoord_attr, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (GLvoid*)(2 * sizeof(float)));
554582
gl()->glEnableVertexAttribArray(texcoord_attr);
555583
}
@@ -751,11 +779,11 @@ OpenGLDepthPacketProcessor::OpenGLDepthPacketProcessor(void *parent_opengl_conte
751779
// setup context
752780
glfwDefaultWindowHints();
753781
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
754-
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
782+
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
755783
#ifdef __APPLE__
756784
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
757785
#endif
758-
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
786+
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_ANY_PROFILE);
759787
glfwWindowHint(GLFW_VISIBLE, debug ? GL_TRUE : GL_FALSE);
760788

761789
GLFWwindow* window = glfwCreateWindow(1024, 848, "OpenGLDepthPacketProcessor", 0, parent_window);
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
#version 330
1+
#version 140
22

33
uniform sampler2DRect Data;
44

5-
in VertexData {
6-
vec2 TexCoord;
7-
} FragmentIn;
5+
in vec2 TexCoord;
86

9-
layout(location = 0) out vec4 Color;
7+
out vec4 Color;
108

119
void main(void)
1210
{
13-
ivec2 uv = ivec2(FragmentIn.TexCoord.x, FragmentIn.TexCoord.y);
11+
ivec2 uv = ivec2(TexCoord.x, TexCoord.y);
1412

1513
Color = texelFetch(Data, uv);
1614
}
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
#version 330
1+
#version 140
22

3-
in vec2 Position;
4-
in vec2 TexCoord;
3+
in vec2 InputPosition;
4+
in vec2 InputTexCoord;
55

6-
out VertexData {
7-
vec2 TexCoord;
8-
} VertexOut;
6+
out vec2 TexCoord;
97

108
void main(void)
119
{
12-
gl_Position = vec4(Position, 0.0, 1.0);
13-
VertexOut.TexCoord = TexCoord;
10+
gl_Position = vec4(InputPosition, 0.0, 1.0);
11+
TexCoord = InputTexCoord;
1412
}

examples/protonect/src/shader/filter1.fs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#version 330
1+
#version 140
22

33
struct Parameters
44
{
@@ -40,14 +40,12 @@ uniform sampler2DRect Norm;
4040

4141
uniform Parameters Params;
4242

43-
in VertexData {
44-
vec2 TexCoord;
45-
} FragmentIn;
43+
in vec2 TexCoord;
4644

47-
layout(location = 0) out vec4 Debug;
48-
layout(location = 1) out vec3 FilterA;
49-
layout(location = 2) out vec3 FilterB;
50-
layout(location = 3) out uint MaxEdgeTest;
45+
/*layout(location = 0)*/ out vec4 Debug;
46+
/*layout(location = 1)*/ out vec3 FilterA;
47+
/*layout(location = 2)*/ out vec3 FilterB;
48+
/*layout(location = 3)*/ out uint MaxEdgeTest;
5149

5250
void applyBilateralFilter(ivec2 uv)
5351
{
@@ -115,7 +113,7 @@ void applyBilateralFilter(ivec2 uv)
115113

116114
void main(void)
117115
{
118-
ivec2 uv = ivec2(FragmentIn.TexCoord.x, FragmentIn.TexCoord.y);
116+
ivec2 uv = ivec2(TexCoord.x, TexCoord.y);
119117

120118
applyBilateralFilter(uv);
121119

examples/protonect/src/shader/filter2.fs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#version 330
1+
#version 140
22

33
struct Parameters
44
{
@@ -39,12 +39,10 @@ uniform usampler2DRect MaxEdgeTest;
3939

4040
uniform Parameters Params;
4141

42-
in VertexData {
43-
vec2 TexCoord;
44-
} FragmentIn;
42+
in vec2 TexCoord;
4543

46-
layout(location = 0) out vec4 Debug;
47-
layout(location = 1) out float FilterDepth;
44+
/*layout(location = 0)*/ out vec4 Debug;
45+
/*layout(location = 1)*/ out float FilterDepth;
4846

4947
void applyEdgeAwareFilter(ivec2 uv)
5048
{
@@ -126,7 +124,7 @@ void applyEdgeAwareFilter(ivec2 uv)
126124

127125
void main(void)
128126
{
129-
ivec2 uv = ivec2(FragmentIn.TexCoord.x, FragmentIn.TexCoord.y);
127+
ivec2 uv = ivec2(TexCoord.x, TexCoord.y);
130128

131129
applyEdgeAwareFilter(uv);
132130

examples/protonect/src/shader/stage1.fs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#version 330
1+
#version 140
22

33
struct Parameters
44
{
@@ -43,16 +43,14 @@ uniform sampler2DRect ZTable;
4343

4444
uniform Parameters Params;
4545

46-
in VertexData {
47-
vec2 TexCoord;
48-
} FragmentIn;
46+
in vec2 TexCoord;
4947

50-
layout(location = 0) out vec4 Debug;
51-
52-
layout(location = 1) out vec3 A;
53-
layout(location = 2) out vec3 B;
54-
layout(location = 3) out vec3 Norm;
55-
layout(location = 4) out float Infrared;
48+
/*layout(location = 0)*/ out vec4 Debug;
49+
/* */
50+
/*layout(location = 1)*/ out vec3 A;
51+
/*layout(location = 2)*/ out vec3 B;
52+
/*layout(location = 3)*/ out vec3 Norm;
53+
/*layout(location = 4)*/ out float Infrared;
5654

5755
#define M_PI 3.1415926535897932384626433832795
5856

@@ -97,7 +95,7 @@ vec2 processMeasurementTriple(in ivec2 uv, in usampler2DRect p0table, in int off
9795

9896
void main(void)
9997
{
100-
ivec2 uv = ivec2(FragmentIn.TexCoord.x, FragmentIn.TexCoord.y);
98+
ivec2 uv = ivec2(TexCoord.x, TexCoord.y);
10199

102100
bool valid_pixel = 0.0 < texelFetch(ZTable, uv).x;
103101
bvec3 saturated = bvec3(valid_pixel);

0 commit comments

Comments
 (0)