diff --git a/example-ofxKinect/src/main.cpp b/example-ofxKinect/src/main.cpp index 39e1528..7be09a6 100644 --- a/example-ofxKinect/src/main.cpp +++ b/example-ofxKinect/src/main.cpp @@ -1,8 +1,11 @@ #include "testApp.h" #include "ofAppGLFWWindow.h" +#include "ofGLProgrammableRenderer.h" + int main() { ofAppGLFWWindow window; + ofSetCurrentRenderer(ofGLProgrammableRenderer::TYPE); ofSetupOpenGL(&window, 2048, 768, OF_WINDOW); ofRunApp(new testApp()); diff --git a/src/ofxReprojectionCalibration.cpp b/src/ofxReprojectionCalibration.cpp index 86e20e4..5f4efe9 100644 --- a/src/ofxReprojectionCalibration.cpp +++ b/src/ofxReprojectionCalibration.cpp @@ -872,7 +872,7 @@ void ofxReprojectionCalibration::updateStatusMessages() { void ofxReprojectionCalibration::drawChessboard(float x, float y, float w, float h) { if(!chessboardImage.isAllocated() || chessboardImage.getWidth() < w || chessboardImage.getHeight() < h) { ofLogVerbose("ofxReprojection") << "allocating " << w << "," << h ; - chessboardImage.allocate(w,h,GL_LUMINANCE); + chessboardImage.allocate(w,h,GL_RGB); updateChessboard(); } chessboardImage.draw(x,y,w,h); diff --git a/src/ofxReprojectionUtils.cpp b/src/ofxReprojectionUtils.cpp index 2cdf255..f3e99e3 100644 --- a/src/ofxReprojectionUtils.cpp +++ b/src/ofxReprojectionUtils.cpp @@ -70,8 +70,7 @@ const string ofxReprojectionUtils::stringGeometryShader2DPoints = ""; -const string ofxReprojectionUtils::stringVertexShader2DTriangles = "#version 120\n" - "#extension GL_ARB_texture_rectangle : enable\n" +const string ofxReprojectionUtils::stringVertexShader2DTriangles = "#version 150\n" STRINGIFY( // depth_map: R32F format, 32 bit floats in red channel @@ -82,52 +81,67 @@ const string ofxReprojectionUtils::stringVertexShader2DTriangles = "#version 12 uniform sampler2DRect color_image; uniform mat4 transform; + + uniform mat4 modelViewProjectionMatrix; + + in vec4 position; + + out vec3 frontColorVertex; void main() { - vec4 pos = gl_Vertex; - gl_FrontColor.rgb = texture2DRect(color_image, pos.xy).rgb; - float z = texture2DRect(depth_map, pos.xy).r; + vec4 pos = position; + frontColorVertex.rgb = texture(color_image, pos.xy).rgb; + float z = texture(depth_map, pos.xy).r; pos.z = z; pos = pos*transform; pos.z = z; - gl_Position = gl_ModelViewProjectionMatrix * pos; + gl_Position = modelViewProjectionMatrix * pos; if(abs(pos.z) < 1e-5) { - gl_FrontColor.rgb = vec3(0,0,0); + frontColorVertex.rgb = vec3(0,0,0); } } ); -const string ofxReprojectionUtils::stringFragmentShader2DTriangles = "#version 120\n" +const string ofxReprojectionUtils::stringFragmentShader2DTriangles = "#version 150\n" STRINGIFY( + in vec3 frontColorGeometry; + out vec4 outputColor; + void main() { - gl_FragColor = gl_Color; + outputColor = vec4(frontColorGeometry, 1); } ); // TODO: Clean up this shader a little? -const string ofxReprojectionUtils::stringGeometryShader2DTriangles = "#version 120\n" - "#extension GL_EXT_geometry_shader4 : enable\n" +const string ofxReprojectionUtils::stringGeometryShader2DTriangles = "#version 150\n" STRINGIFY( // Pointsize variable used as maximum length of triangle side. // 0.2 seems like a good value here, but a better measure // for distortion should be used (TODO) + + layout(triangles) in; + layout(triangle_strip, max_vertices = 3) out; + + in vec3 frontColorVertex[]; + out vec3 frontColorGeometry; + uniform float pointsize; void main() { vec3 sumcolor = vec3(1,1,1); - for (int i = 0; i < gl_VerticesIn; i++) { - if(gl_FrontColorIn[i].rgb == vec3(0,0,0)) { + for (int i = 0; i < gl_in.length(); i++) { + if(frontColorVertex[i].rgb == vec3(0,0,0)) { sumcolor = vec3(0,0,0); } } - float lena = length((gl_PositionIn[1] - gl_PositionIn[0]).xy); - float lenb = length((gl_PositionIn[2] - gl_PositionIn[0]).xy); - float lenc = length((gl_PositionIn[2] - gl_PositionIn[1]).xy); + float lena = length((gl_in[1].gl_Position - gl_in[0].gl_Position).xy); + float lenb = length((gl_in[2].gl_Position - gl_in[0].gl_Position).xy); + float lenc = length((gl_in[2].gl_Position - gl_in[1].gl_Position).xy); if(sumcolor != vec3(0,0,0) && lena < pointsize && lenb < pointsize && lenc < pointsize) { - for (int i = 0; i < gl_VerticesIn; i++) { - gl_Position = gl_PositionIn[i]; - gl_FrontColor = gl_FrontColorIn[i]; + for (int i = 0; i < gl_in.length(); i++) { + gl_Position = gl_in[i].gl_Position; + frontColorGeometry = frontColorVertex[i]; EmitVertex(); }