kashimAstro / ofxFurry

ofxFurry a simple addons furry mesh
68 stars 9 forks source link

ERROR: One or more attached shaders not successfully compiled (Mac OS) #4

Open LuZhouheng opened 7 years ago

LuZhouheng commented 7 years ago

Environment:

Console:

[notice ] SIZE-SHADER::3
[ error ] ofShader: setupShaderFromSource(): GL_GEOMETRY_SHADER_EXT shader failed to compile
[ error ] ofShader: GL_GEOMETRY_SHADER_EXT shader reports:
ERROR: 0:2: '' : syntax error: #version

[ error ] ofShader: GL_GEOMETRY_SHADER_EXT, offending line 2 :
        1   
        2   #version 150 compatibility
        3    
        4   #define VERT 3

[ error ] ofShader: setupShaderFromSource(): GL_VERTEX_SHADER shader failed to compile
[ error ] ofShader: GL_VERTEX_SHADER shader reports:
ERROR: 0:2: '' : syntax error: #version

[ error ] ofShader: GL_VERTEX_SHADER, offending line 2 :
        1   
        2   #version 150 compatibility
        3    in vec2 texCoord; out VertexAttrib { vec3 normal; vec4 color; vec2 texCoord; } vertex; void main() { gl_Position = gl_Vertex; vertex.normal = gl_Normal.xyz; vertex.color = vec4(1.0, 1.0, 0.0, 1.0); vertex.texCoord = texCoord; }
        4   

[ error ] ofShader: setupShaderFromSource(): GL_FRAGMENT_SHADER shader failed to compile
[ error ] ofShader: GL_FRAGMENT_SHADER shader reports:
ERROR: 0:2: '' : syntax error: #version

[ error ] ofShader: GL_FRAGMENT_SHADER, offending line 2 :
        1   
        2   #version 150 compatibility
        3    uniform sampler2D texture; uniform int NOTex; in vec4 vertex_color; in vec4 dist; in vec2 texCoordOut; const vec4 WIRE_COL = vec4(1.0,0.0,0.0,1); void main(void) { if(NOTex == 1){ vec4 tt = texture2D(texture,texCoordOut); gl_FragColor = tt * vertex_color; } else{ gl_FragColor = vertex_color; } }
        4   

[ error ] ofShader: checkProgramLinkStatus(): program failed to link
[ error ] ofShader: ofShader: program reports:
ERROR: One or more attached shaders not successfully compiled

My /gl/glInfoExample output:

-------------------------------------------------
opengl info
-------------------------------------------------
version=2.1 NVIDIA-10.12.68 355.10.05.05b16
vendor=NVIDIA Corporation
renderer=NVIDIA GeForce GT 750M OpenGL Engine
-------------------------------------------------
opengl limits
-------------------------------------------------
OpenGL limits:
    GL_MAX_ATTRIB_STACK_DEPTH = 16
    GL_MAX_CLIENT_ATTRIB_STACK_DEPTH = 16
    GL_MAX_CLIP_PLANES = 6
    GL_MAX_COLOR_MATRIX_STACK_DEPTH = 10
    GL_MAX_ELEMENTS_VERTICES = 1048575
    GL_MAX_ELEMENTS_INDICES = 150000
    GL_MAX_EVAL_ORDER = 10
    GL_MAX_LIGHTS = 8
    GL_MAX_LIST_NESTING = 64
    GL_MAX_MODELVIEW_STACK_DEPTH = 32
    GL_MAX_NAME_STACK_DEPTH = 128
    GL_MAX_PIXEL_MAP_TABLE = 256
    GL_MAX_PROJECTION_STACK_DEPTH = 10
    GL_MAX_TEXTURE_STACK_DEPTH = 10
    GL_MAX_TEXTURE_SIZE = 16384
    GL_MAX_3D_TEXTURE_SIZE = 2048
    GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB = 16384
    GL_MAX_RECTANGLE_TEXTURE_SIZE_NV = 16384
    GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB = 3
    GL_MAX_TEXTURE_UNITS_ARB = 8
    GL_MAX_TEXTURE_LOD_BIAS_EXT = 15
    GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT = 16
    GL_MAX_VIEWPORT_DIMS = 16384, 16384
    GL_ALIASED_LINE_WIDTH_RANGE = 1, 10
    GL_SMOOTH_LINE_WIDTH_RANGE = 1, 10
    GL_ALIASED_POINT_SIZE_RANGE = 1, 2047
    GL_SMOOTH_POINT_SIZE_RANGE = 1, 190
-------------------------------------------------
shader limits
-------------------------------------------------
Shader limits:
    GL_MAX_VERTEX_ATTRIBS = 16
    GL_MAX_VERTEX_UNIFORM_COMPONENTS = 4096
    GL_MAX_VARYING_FLOATS = 124
    GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = 16
    GL_MAX_TEXTURE_IMAGE_UNITS = 16
-------------------------------------------------
available extensions
-------------------------------------------------
    GL_ARB_color_buffer_float, GL_ARB_depth_buffer_float, GL_ARB_depth_clamp, 
    GL_ARB_depth_texture, GL_ARB_draw_buffers, 
    GL_ARB_draw_elements_base_vertex, GL_ARB_draw_instanced, 
    GL_ARB_fragment_program, GL_ARB_fragment_program_shadow, 
    GL_ARB_fragment_shader, GL_ARB_framebuffer_object, 
    GL_ARB_framebuffer_sRGB, GL_ARB_half_float_pixel, 
    GL_ARB_half_float_vertex, GL_ARB_imaging, GL_ARB_instanced_arrays, 
    GL_ARB_multisample, GL_ARB_multitexture, GL_ARB_occlusion_query, 
    GL_ARB_pixel_buffer_object, GL_ARB_point_parameters, GL_ARB_point_sprite, 
    GL_ARB_provoking_vertex, GL_ARB_seamless_cube_map, GL_ARB_shader_objects, 
    GL_ARB_shader_texture_lod, GL_ARB_shading_language_100, GL_ARB_shadow, 
    GL_ARB_sync, GL_ARB_texture_border_clamp, GL_ARB_texture_compression, 
    GL_ARB_texture_compression_rgtc, GL_ARB_texture_cube_map, 
    GL_ARB_texture_env_add, GL_ARB_texture_env_combine, 
    GL_ARB_texture_env_crossbar, GL_ARB_texture_env_dot3, 
    GL_ARB_texture_float, GL_ARB_texture_mirrored_repeat, 
    GL_ARB_texture_non_power_of_two, GL_ARB_texture_rectangle, 
    GL_ARB_texture_rg, GL_ARB_transpose_matrix, GL_ARB_vertex_array_bgra, 
    GL_ARB_vertex_blend, GL_ARB_vertex_buffer_object, GL_ARB_vertex_program, 
    GL_ARB_vertex_shader, GL_ARB_window_pos, GL_EXT_abgr, GL_EXT_bgra, 
    GL_EXT_bindable_uniform, GL_EXT_blend_color, 
    GL_EXT_blend_equation_separate, GL_EXT_blend_func_separate, 
    GL_EXT_blend_minmax, GL_EXT_blend_subtract, GL_EXT_clip_volume_hint, 
    GL_EXT_debug_label, GL_EXT_debug_marker, GL_EXT_depth_bounds_test, 
    GL_EXT_draw_buffers2, GL_EXT_draw_range_elements, GL_EXT_fog_coord, 
    GL_EXT_framebuffer_blit, GL_EXT_framebuffer_multisample, 
    GL_EXT_framebuffer_multisample_blit_scaled, GL_EXT_framebuffer_object, 
    GL_EXT_framebuffer_sRGB, GL_EXT_geometry_shader4, 
    GL_EXT_gpu_program_parameters, GL_EXT_gpu_shader4, 
    GL_EXT_multi_draw_arrays, GL_EXT_packed_depth_stencil, 
    GL_EXT_packed_float, GL_EXT_provoking_vertex, GL_EXT_rescale_normal, 
    GL_EXT_secondary_color, GL_EXT_separate_specular_color, 
    GL_EXT_shadow_funcs, GL_EXT_stencil_two_side, GL_EXT_stencil_wrap, 
    GL_EXT_texture_array, GL_EXT_texture_compression_dxt1, 
    GL_EXT_texture_compression_s3tc, GL_EXT_texture_env_add, 
    GL_EXT_texture_filter_anisotropic, GL_EXT_texture_integer, 
    GL_EXT_texture_lod_bias, GL_EXT_texture_mirror_clamp, 
    GL_EXT_texture_rectangle, GL_EXT_texture_shared_exponent, 
    GL_EXT_texture_sRGB, GL_EXT_texture_sRGB_decode, GL_EXT_timer_query, 
    GL_EXT_transform_feedback, GL_EXT_vertex_array_bgra, 
    GL_APPLE_aux_depth_stencil, GL_APPLE_client_storage, 
    GL_APPLE_element_array, GL_APPLE_fence, GL_APPLE_float_pixels, 
    GL_APPLE_flush_buffer_range, GL_APPLE_flush_render, 
    GL_APPLE_object_purgeable, GL_APPLE_packed_pixels, GL_APPLE_pixel_buffer, 
    GL_APPLE_rgb_422, GL_APPLE_row_bytes, GL_APPLE_specular_vector, 
    GL_APPLE_texture_range, GL_APPLE_transform_hint, 
    GL_APPLE_vertex_array_object, GL_APPLE_vertex_array_range, 
    GL_APPLE_vertex_point_size, GL_APPLE_vertex_program_evaluators, 
    GL_APPLE_ycbcr_422, GL_ATI_separate_stencil, GL_ATI_texture_env_combine3, 
    GL_ATI_texture_float, GL_ATI_texture_mirror_once, GL_IBM_rasterpos_clip, 
    GL_NV_blend_square, GL_NV_conditional_render, GL_NV_depth_clamp, 
    GL_NV_fog_distance, GL_NV_fragment_program_option, 
    GL_NV_fragment_program2, GL_NV_light_max_exponent, 
    GL_NV_multisample_filter_hint, GL_NV_point_sprite, 
    GL_NV_texgen_reflection, GL_NV_texture_barrier, 
    GL_NV_vertex_program2_option, GL_NV_vertex_program3, 
    GL_SGIS_generate_mipmap, GL_SGIS_texture_edge_clamp, GL_SGIS_texture_lod
-------------------------------------------------
opengl calls available
-------------------------------------------------

GL_VERSION_1_1:                                                OK 
---------------

GL_VERSION_1_2:                                                OK 
---------------
  glCopyTexSubImage3D:                                         OK
  glDrawRangeElements:                                         OK
  glTexImage3D:                                                OK
  glTexSubImage3D:                                             OK

GL_VERSION_1_2_1:                                              OK 
-----------------

GL_VERSION_1_3:                                                OK 
---------------
  glActiveTexture:                                             OK
  glClientActiveTexture:                                       OK
  glCompressedTexImage1D:                                      OK
  glCompressedTexImage2D:                                      OK
  glCompressedTexImage3D:                                      OK
  glCompressedTexSubImage1D:                                   OK
  glCompressedTexSubImage2D:                                   OK
  glCompressedTexSubImage3D:                                   OK
  glGetCompressedTexImage:                                     OK
  glLoadTransposeMatrixd:                                      OK
  glLoadTransposeMatrixf:                                      OK
  glMultTransposeMatrixd:                                      OK
  glMultTransposeMatrixf:                                      OK
  glMultiTexCoord1d:                                           OK
  glMultiTexCoord1dv:                                          OK
  glMultiTexCoord1f:                                           OK
  glMultiTexCoord1fv:                                          OK
  glMultiTexCoord1i:                                           OK
  glMultiTexCoord1iv:                                          OK
  glMultiTexCoord1s:                                           OK
  glMultiTexCoord1sv:                                          OK
  glMultiTexCoord2d:                                           OK
  glMultiTexCoord2dv:                                          OK
  glMultiTexCoord2f:                                           OK
  glMultiTexCoord2fv:                                          OK
  glMultiTexCoord2i:                                           OK
  glMultiTexCoord2iv:                                          OK
  glMultiTexCoord2s:                                           OK
  glMultiTexCoord2sv:                                          OK
  glMultiTexCoord3d:                                           OK
  glMultiTexCoord3dv:                                          OK
  glMultiTexCoord3f:                                           OK
  glMultiTexCoord3fv:                                          OK
  glMultiTexCoord3i:                                           OK
  glMultiTexCoord3iv:                                          OK
  glMultiTexCoord3s:                                           OK
  glMultiTexCoord3sv:                                          OK
  glMultiTexCoord4d:                                           OK
  glMultiTexCoord4dv:                                          OK
  glMultiTexCoord4f:                                           OK
  glMultiTexCoord4fv:                                          OK
  glMultiTexCoord4i:                                           OK
  glMultiTexCoord4iv:                                          OK
  glMultiTexCoord4s:                                           OK
  glMultiTexCoord4sv:                                          OK
  glSampleCoverage:                                            OK

GL_VERSION_1_4:                                                OK 
---------------
  glBlendColor:                                                OK
  glBlendEquation:                                             OK
  glBlendFuncSeparate:                                         OK
  glFogCoordPointer:                                           OK
  glFogCoordd:                                                 OK
  glFogCoorddv:                                                OK
  glFogCoordf:                                                 OK
  glFogCoordfv:                                                OK
  glMultiDrawArrays:                                           OK
  glMultiDrawElements:                                         OK
  glPointParameterf:                                           OK
  glPointParameterfv:                                          OK
  glPointParameteri:                                           OK
  glPointParameteriv:                                          OK
  glSecondaryColor3b:                                          OK
  glSecondaryColor3bv:                                         OK
  glSecondaryColor3d:                                          OK
  glSecondaryColor3dv:                                         OK
  glSecondaryColor3f:                                          OK
  glSecondaryColor3fv:                                         OK
  glSecondaryColor3i:                                          OK
  glSecondaryColor3iv:                                         OK
  glSecondaryColor3s:                                          OK
  glSecondaryColor3sv:                                         OK
  glSecondaryColor3ub:                                         OK
  glSecondaryColor3ubv:                                        OK
  glSecondaryColor3ui:                                         OK
  glSecondaryColor3uiv:                                        OK
  glSecondaryColor3us:                                         OK
  glSecondaryColor3usv:                                        OK
  glSecondaryColorPointer:                                     OK
  glWindowPos2d:                                               OK
  glWindowPos2dv:                                              OK
  glWindowPos2f:                                               OK
  glWindowPos2fv:                                              OK
  glWindowPos2i:                                               OK
  glWindowPos2iv:                                              OK
  glWindowPos2s:                                               OK
  glWindowPos2sv:                                              OK
  glWindowPos3d:                                               OK
  glWindowPos3dv:                                              OK
  glWindowPos3f:                                               OK
  glWindowPos3fv:                                              OK
  glWindowPos3i:                                               OK
  glWindowPos3iv:                                              OK
  glWindowPos3s:                                               OK
  glWindowPos3sv:                                              OK

GL_VERSION_1_5:                                                OK 
---------------
  glBeginQuery:                                                OK
  glBindBuffer:                                                OK
  glBufferData:                                                OK
  glBufferSubData:                                             OK
  glDeleteBuffers:                                             OK
  glDeleteQueries:                                             OK
  glEndQuery:                                                  OK
  glGenBuffers:                                                OK
  glGenQueries:                                                OK
  glGetBufferParameteriv:                                      OK
  glGetBufferPointerv:                                         OK
  glGetBufferSubData:                                          OK
  glGetQueryObjectiv:                                          OK
  glGetQueryObjectuiv:                                         OK
  glGetQueryiv:                                                OK
  glIsBuffer:                                                  OK
  glIsQuery:                                                   OK
  glMapBuffer:                                                 OK
  glUnmapBuffer:                                               OK

GL_VERSION_2_0:                                                OK 
---------------
  glAttachShader:                                              OK
  glBindAttribLocation:                                        OK
  glBlendEquationSeparate:                                     OK
  glCompileShader:                                             OK
  glCreateProgram:                                             OK
  glCreateShader:                                              OK
  glDeleteProgram:                                             OK
  glDeleteShader:                                              OK
  glDetachShader:                                              OK
  glDisableVertexAttribArray:                                  OK
  glDrawBuffers:                                               OK
  glEnableVertexAttribArray:                                   OK
  glGetActiveAttrib:                                           OK
  glGetActiveUniform:                                          OK
  glGetAttachedShaders:                                        OK
  glGetAttribLocation:                                         OK
  glGetProgramInfoLog:                                         OK
  glGetProgramiv:                                              OK
  glGetShaderInfoLog:                                          OK
  glGetShaderSource:                                           OK
  glGetShaderiv:                                               OK
  glGetUniformLocation:                                        OK
  glGetUniformfv:                                              OK
  glGetUniformiv:                                              OK
  glGetVertexAttribPointerv:                                   OK
  glGetVertexAttribdv:                                         OK
  glGetVertexAttribfv:                                         OK
  glGetVertexAttribiv:                                         OK
  glIsProgram:                                                 OK
  glIsShader:                                                  OK
  glLinkProgram:                                               OK
  glShaderSource:                                              OK
  glStencilFuncSeparate:                                       OK
  glStencilMaskSeparate:                                       OK
  glStencilOpSeparate:                                         OK
  glUniform1f:                                                 OK
  glUniform1fv:                                                OK
  glUniform1i:                                                 OK
  glUniform1iv:                                                OK
  glUniform2f:                                                 OK
  glUniform2fv:                                                OK
  glUniform2i:                                                 OK
  glUniform2iv:                                                OK
  glUniform3f:                                                 OK
  glUniform3fv:                                                OK
  glUniform3i:                                                 OK
  glUniform3iv:                                                OK
  glUniform4f:                                                 OK
  glUniform4fv:                                                OK
  glUniform4i:                                                 OK
  glUniform4iv:                                                OK
  glUniformMatrix2fv:                                          OK
  glUniformMatrix3fv:                                          OK
  glUniformMatrix4fv:                                          OK
  glUseProgram:                                                OK
  glValidateProgram:                                           OK
  glVertexAttrib1d:                                            OK
  glVertexAttrib1dv:                                           OK
  glVertexAttrib1f:                                            OK
  glVertexAttrib1fv:                                           OK
  glVertexAttrib1s:                                            OK
  glVertexAttrib1sv:                                           OK
  glVertexAttrib2d:                                            OK
  glVertexAttrib2dv:                                           OK
  glVertexAttrib2f:                                            OK
  glVertexAttrib2fv:                                           OK
  glVertexAttrib2s:                                            OK
  glVertexAttrib2sv:                                           OK
  glVertexAttrib3d:                                            OK
  glVertexAttrib3dv:                                           OK
  glVertexAttrib3f:                                            OK
  glVertexAttrib3fv:                                           OK
  glVertexAttrib3s:                                            OK
  glVertexAttrib3sv:                                           OK
  glVertexAttrib4Nbv:                                          OK
  glVertexAttrib4Niv:                                          OK
  glVertexAttrib4Nsv:                                          OK
  glVertexAttrib4Nub:                                          OK
  glVertexAttrib4Nubv:                                         OK
  glVertexAttrib4Nuiv:                                         OK
  glVertexAttrib4Nusv:                                         OK
  glVertexAttrib4bv:                                           OK
  glVertexAttrib4d:                                            OK
  glVertexAttrib4dv:                                           OK
  glVertexAttrib4f:                                            OK
  glVertexAttrib4fv:                                           OK
  glVertexAttrib4iv:                                           OK
  glVertexAttrib4s:                                            OK
  glVertexAttrib4sv:                                           OK
  glVertexAttrib4ubv:                                          OK
  glVertexAttrib4uiv:                                          OK
  glVertexAttrib4usv:                                          OK
  glVertexAttribPointer:                                       OK

GL_VERSION_2_1:                                                OK 
---------------
  glUniformMatrix2x3fv:                                        OK
  glUniformMatrix2x4fv:                                        OK
  glUniformMatrix3x2fv:                                        OK
  glUniformMatrix3x4fv:                                        OK
  glUniformMatrix4x2fv:                                        OK
  glUniformMatrix4x3fv:                                        OK

GL_VERSION_3_0:                                                OK 
---------------
  glBeginConditionalRender:                                    OK
  glBeginTransformFeedback:                                    OK
  glBindFragDataLocation:                                      OK
  glClampColor:                                                OK
  glClearBufferfi:                                             OK
  glClearBufferfv:                                             OK
  glClearBufferiv:                                             OK
  glClearBufferuiv:                                            OK
  glColorMaski:                                                OK
  glDisablei:                                                  OK
  glEnablei:                                                   OK
  glEndConditionalRender:                                      OK
  glEndTransformFeedback:                                      OK
  glGetBooleani_v:                                             OK
  glGetFragDataLocation:                                       OK
  glGetStringi:                                                OK
  glGetTexParameterIiv:                                        OK
  glGetTexParameterIuiv:                                       OK
  glGetTransformFeedbackVarying:                               OK
  glGetUniformuiv:                                             OK
  glGetVertexAttribIiv:                                        OK
  glGetVertexAttribIuiv:                                       OK
  glIsEnabledi:                                                OK
  glTexParameterIiv:                                           OK
  glTexParameterIuiv:                                          OK
  glTransformFeedbackVaryings:                                 OK
  glUniform1ui:                                                OK
  glUniform1uiv:                                               OK
  glUniform2ui:                                                OK
  glUniform2uiv:                                               OK
  glUniform3ui:                                                OK
  glUniform3uiv:                                               OK
  glUniform4ui:                                                OK
  glUniform4uiv:                                               OK
  glVertexAttribI1i:                                           OK
  glVertexAttribI1iv:                                          OK
  glVertexAttribI1ui:                                          OK
  glVertexAttribI1uiv:                                         OK
  glVertexAttribI2i:                                           OK
  glVertexAttribI2iv:                                          OK
  glVertexAttribI2ui:                                          OK
  glVertexAttribI2uiv:                                         OK
  glVertexAttribI3i:                                           OK
  glVertexAttribI3iv:                                          OK
  glVertexAttribI3ui:                                          OK
  glVertexAttribI3uiv:                                         OK
  glVertexAttribI4bv:                                          OK
  glVertexAttribI4i:                                           OK
  glVertexAttribI4iv:                                          OK
  glVertexAttribI4sv:                                          OK
  glVertexAttribI4ubv:                                         OK
  glVertexAttribI4ui:                                          OK
  glVertexAttribI4uiv:                                         OK
  glVertexAttribI4usv:                                         OK
  glVertexAttribIPointer:                                      OK

GL_VERSION_3_1:                                                OK 
---------------
  glDrawArraysInstanced:                                       OK
  glDrawElementsInstanced:                                     OK
  glPrimitiveRestartIndex:                                     OK
  glTexBuffer:                                                 OK

GL_VERSION_3_2:                                                OK 
---------------
  glFramebufferTexture:                                        OK
  glGetBufferParameteri64v:                                    OK
  glGetInteger64i_v:                                           OK

GL_VERSION_3_3:                                                OK 
---------------
  glVertexAttribDivisor:                                       OK

GL_VERSION_4_0:                                                OK 
---------------
  glBlendEquationSeparatei:                                    OK
  glBlendEquationi:                                            OK
  glBlendFuncSeparatei:                                        OK
  glBlendFunci:                                                OK
  glMinSampleShading:                                          OK

GL_VERSION_4_1:                                                MISSING 
---------------

GL_VERSION_4_2:                                                MISSING 
---------------
kashimAstro commented 7 years ago

Hi, which example of ofxFurry you are trying to run? these:

example-assimp
example-basic
example-kinect

they use a geometry shader that requires a version 3.2 openGL his glInfo appears to return a version of openGL 2.1 Version = 2.1 NVIDIA-10/12/68 355.10.05.05b16

try to rebuild one of the examples that use the geometry shader with this line in the setup:

ofLog()<<(char*)glGetString(GL_VERSION);

and hand me the result..

you have tried example-furryprimitive- *? these do not use a geometry shader but a bufferObject and contain more functionality to control the individual hair

example-furryprimitive-assimp
example-furryprimitive-customfur
example-furryprimitive-direction
example-furryprimitive

even if your video card supports openGL greater than 3.x seems not to have an extension that is used to run with this geometry shader, using these two labels to work:

GL_ARB_geometry_shader4 <-- this not present
GL_EXT_geometry_shader4

good day

LuZhouheng commented 7 years ago

Hi, @kashimAstro.

First of all, thanks for your reply ~

I try your example-kinect and add ofLog()<<(char*)glGetString(GL_VERSION); in the setup, here is the result:


[verbose] ofxKinect: context inited
[verbose] ofxKinect: 1 device found
[verbose] ofxKinect:     id: 0 serial: 0000000000000000
[notice ] sensor-emitter dist: 7.5cm
[notice ] sensor-camera dist:  2.4cm
[notice ] zero plane pixel size: 0.1042mm
[notice ] zero plane dist: 120mm
[verbose] ofShader: checkAndCreateProgram(): creating GLSL program
[notice ] SIZE-SHADER::3
[verbose] ofShader: setupShaderFromSource(): OpenGL error after checkAndCreateProgram() (probably harmless): error 1280
[ error ] ofShader: setupShaderFromSource(): GL_GEOMETRY_SHADER_EXT shader failed to compile
[ error ] ofShader: GL_GEOMETRY_SHADER_EXT shader reports:
ERROR: 0:2: '' : syntax error: #version

[ error ] ofShader: GL_GEOMETRY_SHADER_EXT, offending line 2 :
        1   
        2   #version 330 compatibility
        3    
        4   #define VERT 3

[ error ] ofShader: setupShaderFromSource(): GL_VERTEX_SHADER shader failed to compile
[ error ] ofShader: GL_VERTEX_SHADER shader reports:
ERROR: 0:2: '' : syntax error: #version

[ error ] ofShader: GL_VERTEX_SHADER, offending line 2 :
        1   
        2   #version 330 compatibility
        3    in vec2 texCoord; out VertexAttrib { vec3 normal; vec4 color; vec2 texCoord; } vertex; void main() { gl_Position = gl_Vertex; vertex.normal = gl_Normal.xyz; vertex.color = vec4(1.0, 1.0, 0.0, 1.0); vertex.texCoord = texCoord; }
        4   

[ error ] ofShader: setupShaderFromSource(): GL_FRAGMENT_SHADER shader failed to compile
[ error ] ofShader: GL_FRAGMENT_SHADER shader reports:
ERROR: 0:2: '' : syntax error: #version

[ error ] ofShader: GL_FRAGMENT_SHADER, offending line 2 :
        1   
        2   #version 330 compatibility
        3    uniform sampler2D texture; uniform int NOTex; in vec4 vertex_color; in vec4 dist; in vec2 texCoordOut; const vec4 WIRE_COL = vec4(1.0,0.0,0.0,1); void main(void) { if(NOTex == 1){ vec4 tt = texture2D(texture,texCoordOut); gl_FragColor = tt * vertex_color; } else{ gl_FragColor = vertex_color; } }
        4   

[verbose] ofShader: linkProgram(): attaching GL_FRAGMENT_SHADER shader to program 28
[verbose] ofShader: linkProgram(): attaching GL_VERTEX_SHADER shader to program 28
[verbose] ofShader: linkProgram(): attaching GL_GEOMETRY_SHADER_EXT shader to program 28
[ error ] ofShader: checkProgramLinkStatus(): program failed to link
[ error ] ofShader: ofShader: program reports:
ERROR: One or more attached shaders not successfully compiled

[notice ] 4.1 NVIDIA-10.12.68 355.10.05.05b16
[verbose] ofxKinect: device 0 0000000000000000 connection opened
[verbose] ofxKinect: device 0 connection closed

I get this image output:

01

screen shot 2016-12-14 at 11 41 51 am screen shot 2016-12-14 at 11 42 02 am screen shot 2016-12-14 at 11 42 17 am screen shot 2016-12-14 at 11 42 25 am

I am new for OpenGL & GLSL progamming, is there any way to fix this for Mac OS ?

Thanks very much~ 😄😄😄

arturoc commented 7 years ago

just saw this from the forum. i don't think it's a problem of compatibility, the gl info shows compatibility until 4.0 and the geometry extension is there. i think it's just a syntax error in the shader, probably one that doesn't happen in other platforms. can you try to remove the first breakline in the shader code, before the #version directive?

kashimAstro commented 7 years ago

The opengl version now seems consistent. Test the solution that suggests arturo, the lack of GL_ARB_geometry_shader4 It does not seem to affect..

arturoc commented 7 years ago

the geometry extension is there except that it's listed as GL_EXT instead of GL_ARB

LuZhouheng commented 7 years ago

After change syntax in main.cpp, here it is:

#include "ofMain.h"
#include "ofApp.h"

int main( ){
    ofGLWindowSettings settings;
    settings.setGLVersion(4, 1);
    settings.width = 1024;
    settings.height = 768;
    ofCreateWindow(settings);

    if(!ofGLCheckExtension("GL_ARB_geometry_shader4") && !ofGLCheckExtension("GL_EXT_geometry_shader4") && ofIsGLProgrammableRenderer()){
        ofLogFatalError() << "geometry shaders not supported on this graphics card";
        return 1;
    }

    ofRunApp( new ofApp());
}

Now, I even can not build success, the Console is:

[ fatal ] geometry shaders not supported on this graphics card

@arturoc remove the breakline in the shader code will make a invalid preprocessing directive ERROR.

kashimAstro commented 7 years ago

@LuZhouheng remove !ofGLCheckExtension ("GL_ARB_geometry_shader4").

@arturoc thanks for clarification, I always thought they were different extensions..

ARB – Extensions officially approved by the OpenGL Architecture Review Board EXT – Extensions agreed upon by multiple OpenGL vendors HP – Hewlett-Packard IBM – International Business Machines KTX – Kinetix, maker of 3D Studio Max INTEL – Intel NV – NVIDIA Corporation MESA – Brian Paul’s freeware portable OpenGL implementation SGI – Silicon Graphics SGIX – Silicon Graphics (experimental) SUN – Sun Microsystems WIN – Microsoft

arturoc commented 7 years ago

@kashimAstro osx drivers are always super outdated so that's probably why, they still support geometry shaders as a non standard extension instead of ARB

@LuZhouheng how are you removing the extra breakline? also perhaps try removing the compatibility bit like:

\n#version 330 compatibility\n

to

#version 330\n
LuZhouheng commented 7 years ago

Try both your advises.

Now it output this console:

[verbose] ofxKinect: context inited
[verbose] ofxKinect: 1 device found
[verbose] ofxKinect:     id: 0 serial: 0000000000000000
[notice ] sensor-emitter dist: 7.5cm
[notice ] sensor-camera dist:  2.4cm
[notice ] zero plane pixel size: 0.1042mm
[notice ] zero plane dist: 120mm
[verbose] ofShader: checkAndCreateProgram(): creating GLSL program
[notice ] SIZE-SHADER::3
[verbose] ofShader: setupShaderFromSource(): OpenGL error after checkAndCreateProgram() (probably harmless): error 1280
[verbose] ofShader: setupShaderFromSource(): GL_GEOMETRY_SHADER_EXT shader compiled
[ error ] ofShader: setupShaderFromSource(): GL_VERTEX_SHADER shader failed to compile
[ error ] ofShader: GL_VERTEX_SHADER shader reports:
ERROR: 0:2: Use of undeclared identifier 'gl_Vertex'
ERROR: 0:2: Use of undeclared identifier 'gl_Normal'

[ error ] ofShader: GL_VERTEX_SHADER, offending line 2 :
        1   #version 330 
        2    in vec2 texCoord; out VertexAttrib { vec3 normal; vec4 color; vec2 texCoord; } vertex; void main() { gl_Position = gl_Vertex; vertex.normal = gl_Normal.xyz; vertex.color = vec4(1.0, 1.0, 0.0, 1.0); vertex.texCoord = texCoord; }
        3   

[ error ] ofShader: setupShaderFromSource(): GL_FRAGMENT_SHADER shader failed to compile
[ error ] ofShader: GL_FRAGMENT_SHADER shader reports:
ERROR: 0:2: Invalid call of undeclared identifier 'texture2D'
ERROR: 0:2: Use of undeclared identifier 'gl_FragColor'
ERROR: 0:2: Use of undeclared identifier 'tt'
ERROR: 0:2: Use of undeclared identifier 'gl_FragColor'

[ error ] ofShader: GL_FRAGMENT_SHADER, offending line 2 :
        1   #version 330 
        2    uniform sampler2D texture; uniform int NOTex; in vec4 vertex_color; in vec4 dist; in vec2 texCoordOut; const vec4 WIRE_COL = vec4(1.0,0.0,0.0,1); void main(void) { if(NOTex == 1){ vec4 tt = texture2D(texture,texCoordOut); gl_FragColor = tt * vertex_color; } else{ gl_FragColor = vertex_color; } }
        3   

[verbose] ofShader: linkProgram(): attaching GL_FRAGMENT_SHADER shader to program 28
[verbose] ofShader: linkProgram(): attaching GL_VERTEX_SHADER shader to program 28
[verbose] ofShader: linkProgram(): attaching GL_GEOMETRY_SHADER_EXT shader to program 28
[ error ] ofShader: checkProgramLinkStatus(): program failed to link
[ error ] ofShader: ofShader: program reports:
ERROR: One or more attached shaders not successfully compiled

[notice ] 4.1 NVIDIA-10.12.68 355.10.05.05b16
[verbose] ofxKinect: device 0 0000000000000000 connection opened
[verbose] ofxKinect: device 0 connection closed
[warning] ofxKinect: update(): device 0 isn't delivering data, reconnecting tries: 1
[verbose] ofxKinect: device 0 0000000000000000 connection opened

and only settings.setGLVersion(2, 1) can use GL_ARB_geometry_shader4 && GL_EXT_geometry_shader4.

If I change to this setting:

int main( ){
    ofGLFWWindowSettings settings;
    settings.setGLVersion(2, 1);
    settings.width = 1024;
    settings.height = 768;
    ofCreateWindow(settings);

    if(!ofGLCheckExtension("GL_ARB_geometry_shader4") && !ofGLCheckExtension("GL_EXT_geometry_shader4") && ofIsGLProgrammableRenderer()){
        ofLogFatalError() << "geometry shaders not supported on this graphics card";
        return 1;
    }

    ofRunApp( new ofApp());
}

and change glsl version to this:

#version 120
#extension GL_EXT_geometry_shader4 : enable

It build success, but shader can not compile.

Console:

[verbose] ofxKinect: context inited
[verbose] ofxKinect: 1 device found
[verbose] ofxKinect:     id: 0 serial: 0000000000000000
[notice ] sensor-emitter dist: 7.5cm
[notice ] sensor-camera dist:  2.4cm
[notice ] zero plane pixel size: 0.1042mm
[notice ] zero plane dist: 120mm
[verbose] ofShader: checkAndCreateProgram(): creating GLSL program
[notice ] SIZE-SHADER::3
[ error ] ofShader: setupShaderFromSource(): GL_GEOMETRY_SHADER_EXT shader failed to compile
[ error ] ofShader: GL_GEOMETRY_SHADER_EXT shader reports:
ERROR: 0:14: 'layout' : syntax error: syntax error

[ error ] ofShader: GL_GEOMETRY_SHADER_EXT, offending line 14 :
       12   #define TWO_PI 6.28318530717958647693
       13    float map( float value, float inputMin, float inputMax, float outputMin, float outputMax ) { return ((value - inputMin) / (inputMax - inputMin) * (outputMax - outputMin) + outputMin); } float mapClamped( float value, float inputMin, float inputMax, float outputMin, float outputMax ) { return clamp( ((value - inputMin) / (inputMax - inputMin) * (outputMax - outputMin) + outputMin), outputMin, outputMax ); } vec3 map( vec3 value, vec3 inputMin, vec3 inputMax, vec3 outputMin, vec3 outputMax ) { return ((value - inputMin) / (inputMax - inputMin) * (outputMax - outputMin) + outputMin); } float stepInOut( float _edge1, float _edge2, float _val ) { return step(_edge1, _val) - step(_edge2,_val); } float linearStep( float _edge0, float _edge1, float _t ) { return clamp( (_t - _edge0)/(_edge1 - _edge0), 0.0, 1.0); } float linearStepInOut( float _low0, float _high0, float _high1, float _low1, float _t ) { return linearStep( _low0, _high0, _t ) * (1.0f - linearStep( _high1, _low1, _t )); } float smoothStepInOut( float _low0, float _high0, float _high1, float _low1, float _t ) { return smoothstep( _low0, _high0, _t ) * (1.0 - smoothstep( _high1, _low1, _t )); } float mod289(float x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec2 mod289(vec2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec4 mod289(vec4 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } float rand(vec2 co) { return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); } float permute(float x) { return mod289(((x*34.0)+1.0)*x); } vec3 permute(vec3 x) { return mod289(((x*34.0)+1.0)*x); } vec4 permute(vec4 x) { return mod289(((x*34.0)+1.0)*x); } float taylorInvSqrt(float r) { return 1.79284291400159 - 0.85373472095314 * r; } vec4 taylorInvSqrt(vec4 r) { return 1.79284291400159 - 0.85373472095314 * r; } mat4 makeLookAt(vec3 eye, vec3 center, vec3 up){ mat4 M; vec3 zaxis = normalize(eye - center); vec3 xaxis = normalize( cross(up, zaxis) ); vec3 yaxis = cross(zaxis,xaxis); M[0] = vec4(xaxis,0); M[1] = vec4(yaxis,0); M[2] = vec4(zaxis,0); M[3] = vec4(eye,1); return M; } mat4 rotationMatrix(vec3 axis, float angle){ axis = normalize(axis); float s = sin(angle); float c = cos(angle); float oc = 1.0 - c; return mat4(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0, oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0, oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0, 0.0, 0.0, 0.0, 1.0); } vec3 randomPointOnSphere( vec3 _random ){ float lambda = _random.x; float u = map( _random.y, 0.0, 1.0, -1.0, 1.0 ); float phi = _random.z * (2.0 * PI ); vec3 p; p.x = pow(lambda, 1.0/3.0) * sqrt(1.0 - u * u) * cos(phi); p.y = pow(lambda, 1.0/3.0) * sqrt(1.0 - u * u) * sin(phi); p.z = pow(lambda, 1.0/3.0) * u; return p; } float pulseSquare( float _t, float _frequency, float _width ) { return 1.0 - step( _width, mod( _t, _frequency ) ); } float pulseTriangle( float _t, float _frequency, float _width ) { float triangleT = mod( _t, _frequency ) / _width * 2.0; return (1.0 - abs(mod(triangleT,2.0) - 1.0)) * pulseSquare( _t, _frequency, _width ); } float pulseLineDownUp( float _t, float _frequency, float _width ) { float tmpVal = mod( _t, _frequency ) / _width; return tmpVal * (1.0 - step( 1.0, tmpVal )); } float pulseLineUpDown( float _t, float _frequency, float _width ) { float tmpVal = 1 - (mod( _t, _frequency ) / _width); return clamp( tmpVal * (1 - step( 1.0, tmpVal )), 0, 1); } float pulseSawTooth( float _t, float _frequency, float _width ) { float tmpVal = 1 - (mod( _t, _frequency ) / _width); return clamp( tmpVal * (1.0 - step( 1.0, tmpVal )), 0.0, 1.0); } float pulseSine( float _t, float _frequency, float _width ) { float tmpVal = clamp( (mod( _t, _frequency ) / _width), 0.0, 1.0); return sin(tmpVal * PI); } float pulseSmoothStep( float _t, float _frequency, float _x0, float _x1, float _x2, float _x3 ) { float tmpVal = mod( _t, _frequency ); return smoothStepInOut( _x0, _x1, _x2, _x3, tmpVal ) ; } float pulseLinearStep( float _t, float _frequency, float _x0, float _x1, float _x2, float _x3 ) { float tmpVal = mod( _t, _frequency ); return linearStepInOut( _x0, _x1, _x2, _x3, tmpVal ) ; } vec3 opTwistX( vec3 _p, float _angPerUnit ) { float c = cos( _angPerUnit * _p.x); float s = sin( _angPerUnit * _p.x); mat2 m = mat2(c,-s,s,c); return vec3( _p.x, m * _p.yz ); } vec3 opTwistY( vec3 _p, float _angPerUnit ) { float c = cos( _angPerUnit * _p.y); float s = sin( _angPerUnit * _p.y); mat2 m = mat2(c,-s,s,c); vec2 rotXZ = m * _p.xz; return vec3( rotXZ.x, _p.y, rotXZ.y ); } vec3 opTwistZ( vec3 _p, float _angPerUnit ) { float c = cos( _angPerUnit * _p.z); float s = sin( _angPerUnit * _p.z); mat2 m = mat2(c,-s,s,c); vec2 rotXY = m * _p.xy; return vec3( rotXY.x, rotXY.y, _p.z ); } float CatmullRom( float u, float x0, float x1, float x2, float x3 ) { float u2 = u * u; float u3 = u2 * u; return ((2 * x1) + (-x0 + x2) * u + (2*x0 - 5*x1 + 4*x2 - x3) * u2 + (-x0 + 3*x1 - 3*x2 + x3) * u3) * 0.5; } float cubicPulse( float c, float w, float x ) { x = abs(x - c); if( x>w ) return 0.0; x /= w; return 1.0 - x*x*(3.0-2.0*x); } float expStep( float x, float k, float n ) { return exp( -k*pow(x,n) ); } float parabola( float x, float k ) { return pow( 4.0*x*(1.0-x), k ); } float pcurve( float x, float a, float b ) { float k = pow(a+b,a+b) / (pow(a,a)*pow(b,b)); return k * pow( x, a ) * pow( 1.0-x, b ); } float impulse( float k, float x ) { float h = k*x; return h*exp(1.0-h); } float snoise(vec2 v) { const vec4 C = vec4(0.211324865405187, 0.366025403784439, -0.577350269189626, 0.024390243902439); vec2 i = floor(v + dot(v, C.yy) ); vec2 x0 = v - i + dot(i, C.xx); vec2 i1; i1.x = step( x0.y, x0.x ); i1.y = 1.0 - i1.x; i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0); x0 = x0 - 0.0 + 0.0 * C.xx ; vec4 x12 = x0.xyxy + C.xxzz; x12.xy -= i1; i = mod289(i); vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 )) + i.x + vec3(0.0, i1.x, 1.0 )); vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0); m = m*m ; m = m*m ; vec3 x = 2.0 * fract(p * C.www) - 1.0; vec3 h = abs(x) - 0.5; vec3 ox = floor(x + 0.5); vec3 a0 = x - ox; m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h ); vec3 g; g.x = a0.x * x0.x + h.x * x0.y; g.yz = a0.yz * x12.xz + h.yz * x12.yw; return 130.0 * dot(m, g); }
       14   layout(triangles) in; layout(triangle_strip, max_vertices=6) out; uniform mat4 viewMatrix; uniform mat4 projectionMatrix; uniform mat4 modelMatrix; uniform float time; uniform float hairLeng; uniform vec3 colors; uniform int polygonTypes; uniform vec2 collisionCoord; in VertexAttrib { vec3 normal; vec4 color; vec2 texCoord; } vertex[]; out VertexData { vec2 texCoord; vec3 normal; } VertexOut; out vec4 vertex_color; out vec3 dist; vec3 quaternionRotation(vec3 original, float angle, vec3 axis) { normalize(axis); float hcos = cos(angle / 2); float hsin = sin(angle / 2); float q10 = hcos; float q11 = axis.x * hsin; float q12 = axis.y * hsin; float q13 = axis.z * hsin; float q20 = hcos; float q21 = -axis.x * hsin; float q22 = -axis.y * hsin; float q23 = -axis.z * hsin; float qo0 = 0; float qo1 = original.x; float qo2 = original.y; float qo3 = original.z; float qt0 = q10 * qo0 - q11 * qo1 - q12 * qo2 - q13 * qo3; float qt1 = q10 * qo1 + q11 * qo0 + q12 * qo3 - q13 * qo2; float qt2 = q10 * qo2 - q11 * qo3 + q12 * qo0 + q13 * qo1; float qt3 = q10 * qo3 + q11 * qo2 - q12 * qo1 + q13 * qo0; float qe0 = qt0 * q20 - qt1 * q21 - qt2 * q22 - qt3 * q23; float qe1 = qt0 * q21 + qt1 * q20 + qt2 * q23 - qt3 * q22; float qe2 = qt0 * q22 - qt1 * q23 + qt2 * q20 + qt3 * q21; float qe3 = qt0 * q23 + qt1 * q22 - qt2 * q21 + qt3 * q20; return vec3(qe1, qe2, qe3); } void polygonA(mat4 projectionMatrix, mat4 modelViewMatrix){ vec3 a = vec3(gl_in[1].gl_Position - gl_in[0].gl_Position); vec3 b = vec3(gl_in[2].gl_Position - gl_in[0].gl_Position); vec3 center = vec3(gl_in[0].gl_Position + gl_in[1].gl_Position + gl_in[2].gl_Position) / 3.0; vec3 normal = normalize(cross(b, a)); float t = hairLeng / float(VERT); for(int i=0; i<VERT; i++) { vertex_color = vec4(colors.x,colors.y,colors.z, 1.0); vec3 position = normal * map( t, 0., 1., 1.0, 500. ) + center; position.x += snoise(vec2(.6f*position.x,.2f*position.y) * time); position.y += snoise(vec2(.4f*position.y,.4f*position.z) * time); position.z += snoise(vec2(.2f*position.x,.6f*position.y) * time); VertexOut.texCoord = vertex[i].texCoord; gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0); EmitVertex(); } } void polygonB(mat4 projectionMatrix, mat4 modelViewMatrix){ float xtime = 0.3 + time; vec3 lightDir = vec3(1.f,0.5,1.f); vec3 p0 = vec3(gl_in[0].gl_Position); vec3 p1 = vec3(gl_in[1].gl_Position); vec3 up = vec3(0, 0, 1); vec3 dir = normalize(cross(p1, p0)); vec3 right = normalize(cross(dir, up)); vec3 norm = cross(right, dir); float fColMult = abs(dot(norm, lightDir)); vec4 colMult = vec4(fColMult, fColMult, fColMult, 1.0); right *= hairLeng*55.5f; VertexOut.texCoord = vertex[0].texCoord; gl_Position = projectionMatrix * modelViewMatrix * vec4(p0 - right, 1.0) * xtime; vertex_color = vec4(colors.x,colors.y,colors.z, 1.0); EmitVertex(); VertexOut.texCoord = vertex[1].texCoord; gl_Position = projectionMatrix * modelViewMatrix * vec4(p0 + right, 1.0) * xtime; vertex_color = vec4(colors.x-0.1,colors.y-0.1,colors.z-0.1, 1.0); EmitVertex(); VertexOut.texCoord = vertex[2].texCoord; gl_Position = projectionMatrix * modelViewMatrix * vec4(p1 - right, 1.0) * xtime; vertex_color = vec4(colors.x-0.15,colors.y-0.15,colors.z-0.15, 1.0); EmitVertex(); gl_Position = projectionMatrix * modelViewMatrix * vec4(p1 + right, 1.0) * xtime; vertex_color = vec4(colors.x-0.2,colors.y-0.2,colors.z-0.2, 1.0); EmitVertex(); } void polygonC(mat4 projectionMatrix, mat4 modelViewMatrix){ float radius = hairLeng*55.5f; vec3 p0 = gl_in[0].gl_Position.xyz; vec3 p1 = gl_in[1].gl_Position.xyz; vec3 up = vec3(0, 0, 1); vec3 dir = normalize(p1 - p0); vec3 right = normalize(cross(dir, up)); vec3 norm = cross(right, dir); vec3 center = (p0 +p1) / 2.0; float len = distance(p0, p1); int hslices = 5; int vslices = 4; vec3 d; vec3 n; if (len > 190.0) { len = (20.0 - len) / 5.0 * 5.0; } for (int i = 0; i < hslices; i ++) { float vTheta0 = PI / hslices * i - PI / 2; float cosV0 = cos(vTheta0); float sinV0 = sin(vTheta0); float vTheta1 = PI / hslices * (i + 1) - PI / 2; float cosV1 = cos(vTheta1); float sinV1 = sin(vTheta1); vec3 c0 = center + dir * len / 2 * sinV0; vec3 c1 = center + dir * len / 2 * sinV1; vec3 r0 = right * cosV0; vec3 r1 = right * cosV1; vec3 normal; for (int j = 0; j <= vslices; j ++) { d = quaternionRotation(r0, TWO_PI * j / vslices, dir); gl_Position = projectionMatrix * modelViewMatrix * vec4(c0 + d * radius, 1.0); normal = normalize(d + normalize(c0) / 2.0); vertex_color = vec4(colors.x,colors.y,colors.z, 1.0); EmitVertex(); d = quaternionRotation(r1, TWO_PI * j / vslices, dir); gl_Position = projectionMatrix * modelViewMatrix * vec4(c1 + d * radius, 1.0); normal = normalize(d + normalize(c1) / 2.0); vertex_color = vec4(colors.x-0.1,colors.y-0.1,colors.z-0.1, 1.0); EmitVertex(); } } } void polygonD(mat4 projectionMatrix, mat4 modelViewMatrix){ float bbWidth=0.5; float bbHeight=1.0; float ctime=time+2.5; float spriteOffset=0.1; vec3 pos = gl_in[0].gl_Position.xyz; vec3 p0 = gl_in[0].gl_Position.xyz; vec3 p1 = gl_in[1].gl_Position.xyz; vec3 up = vec3(0, 0, 1); vec3 dir = normalize(p1 - p0); vec3 right = normalize(cross(dir, up)); vec3 d; vec3 toCamera = dir; right*=bbWidth; up *= bbHeight * hairLeng; pos -= (right * 0.5); pos.z=gl_in[0].gl_Position.z; d = quaternionRotation(pos, TWO_PI * hairLeng, dir); gl_Position = projectionMatrix * modelViewMatrix * vec4(p0 + d * hairLeng, 1.0); vertex_color = vec4(colors.x,colors.y,colors.z, 1.0); EmitVertex(); pos.y += 1.0; d = quaternionRotation(pos, TWO_PI * hairLeng, dir); gl_Position = projectionMatrix * modelViewMatrix * vec4(p0 + d * hairLeng, 1.0); vertex_color = vec4(colors.x-0.1,colors.y-0.1,colors.z-0.1, 1.0); EmitVertex(); pos.y -= 1.0; pos += right; d = quaternionRotation(pos, TWO_PI * hairLeng, dir); gl_Position = projectionMatrix * modelViewMatrix * vec4(p1 + d * hairLeng, 1.0); vertex_color = vec4(colors.x-0.15,colors.y-0.15,colors.z-0.15, 1.0); EmitVertex(); pos.y += 1.0; d = quaternionRotation(pos, TWO_PI * hairLeng, dir); gl_Position = projectionMatrix * modelViewMatrix * vec4(p1 + d * hairLeng, 1.0); vertex_color = vec4(colors.x-0.2,colors.y-0.2,colors.z-0.2, 1.0); EmitVertex(); } void polygonE(mat4 projectionMatrix, mat4 modelViewMatrix){ float SPEED = 5.0; float OFFSET = 25.0; float xtime = 0.004 + time; float radius = hairLeng *55.5f* xtime; vec3 a = vec3(gl_in[1].gl_Position - gl_in[0].gl_Position); vec3 b = vec3(gl_in[2].gl_Position - gl_in[0].gl_Position); vec3 center = vec3(gl_in[0].gl_Position + gl_in[1].gl_Position + gl_in[2].gl_Position) / 3.0; vec3 normal = normalize(cross(b, a)); for(int j = 0; j < gl_in.length(); j++) { vec3 newVertex; newVertex = normal * cos(time * SPEED + gl_in[j].gl_Position.x) *radius* OFFSET + vec3(gl_in[j].gl_Position.xyz); gl_Position = projectionMatrix * modelViewMatrix * vec4(newVertex, 1.0); vertex_color = vec4(colors.x,colors.y,colors.z, 1.0); EmitVertex(); } } void polygonF(mat4 projectionMatrix, mat4 modelViewMatrix){ vec3 a = vec3(gl_in[1].gl_Position - gl_in[0].gl_Position); vec3 b = vec3(gl_in[2].gl_Position - gl_in[0].gl_Position); vec3 center = vec3(gl_in[0].gl_Position + gl_in[1].gl_Position + gl_in[2].gl_Position) / 3.0; vec3 normal = normalize(cross(b, a)); float xtime = 0.004 + time; float radius = hairLeng *55.5f* xtime; for(int j = 0; j < gl_in.length(); j++) { vec3 newVertex; newVertex = center * normal * cos(xtime * TWO_PI + gl_in[j].gl_Position.x) * radius * PI + vec3(gl_in[j].gl_Position.xyz); gl_Position = projectionMatrix * modelViewMatrix * vec4(newVertex, 1.0); vertex_color = vec4(colors.x,colors.y,colors.z, 1.0); EmitVertex(); } } void main() { mat4 modelViewMatrix = viewMatrix * modelMatrix; mat4 viewProjectionMatrix = projectionMatrix * viewMatrix; for(int i=0; i<VERT; i++) { vertex_color = vec4(colors.x*snoise(vec2(colors.xy)),colors.y*snoise(vec2(colors.xy)),colors.z*snoise(vec2(colors.xy)),1.0); vec4 view_pos = modelViewMatrix * gl_in[i].gl_Position; gl_Position = projectionMatrix * view_pos; EmitVertex(); } if(polygonTypes == 0){ polygonA(projectionMatrix,modelViewMatrix); } if(polygonTypes == 1){ polygonB(projectionMatrix,modelViewMatrix); } if(polygonTypes == 2){ polygonC(projectionMatrix,modelViewMatrix); } if(polygonTypes == 3){ polygonD(projectionMatrix,modelViewMatrix); } if(polygonTypes == 4){ polygonE(projectionMatrix,modelViewMatrix); } if(polygonTypes == 5){ polygonF(projectionMatrix,modelViewMatrix); } EndPrimitive(); }
       15   

[ error ] ofShader: setupShaderFromSource(): GL_VERTEX_SHADER shader failed to compile
[ error ] ofShader: GL_VERTEX_SHADER shader reports:
ERROR: 0:5: ';' : syntax error: Uniform blocks may not have identifiers in GLSL 140

[ error ] ofShader: GL_VERTEX_SHADER, offending line 5 :
        3    
        4   #extension GL_EXT_geometry_shader4 : enable
        5    in vec2 texCoord; out VertexAttrib { vec3 normal; vec4 color; vec2 texCoord; } vertex; void main() { gl_Position = gl_Vertex; vertex.normal = gl_Normal.xyz; vertex.color = vec4(1.0, 1.0, 0.0, 1.0); vertex.texCoord = texCoord; }
        6   

[ error ] ofShader: setupShaderFromSource(): GL_FRAGMENT_SHADER shader failed to compile
[ error ] ofShader: GL_FRAGMENT_SHADER shader reports:
ERROR: 0:5: Invalid storage qualifiers 'in' in global variable context
ERROR: 0:5: Invalid storage qualifiers 'in' in global variable context
ERROR: 0:5: Invalid storage qualifiers 'in' in global variable context
ERROR: 0:5: Use of undeclared identifier 'texCoordOut'
ERROR: 0:5: Use of undeclared identifier 'tt'
ERROR: 0:5: Use of undeclared identifier 'vertex_color'
ERROR: 0:5: Use of undeclared identifier 'vertex_color'

[ error ] ofShader: GL_FRAGMENT_SHADER, offending line 5 :
        3    
        4   #extension GL_EXT_geometry_shader4 : enable
        5    uniform sampler2D texture; uniform int NOTex; in vec4 vertex_color; in vec4 dist; in vec2 texCoordOut; const vec4 WIRE_COL = vec4(1.0,0.0,0.0,1); void main(void) { if(NOTex == 1){ vec4 tt = texture2D(texture,texCoordOut); gl_FragColor = tt * vertex_color; } else{ gl_FragColor = vertex_color; } }
        6   

[verbose] ofShader: linkProgram(): attaching GL_FRAGMENT_SHADER shader to program 1
[verbose] ofShader: linkProgram(): attaching GL_VERTEX_SHADER shader to program 1
[verbose] ofShader: linkProgram(): attaching GL_GEOMETRY_SHADER_EXT shader to program 1
[ error ] ofShader: checkProgramLinkStatus(): program failed to link
[ error ] ofShader: ofShader: program reports:
ERROR: One or more attached shaders not successfully compiled

[notice ] 2.1 NVIDIA-10.12.68 355.10.05.05b16
[verbose] ofxKinect: device 0 0000000000000000 connection opened
[verbose] ofxKinect: device 0 connection closed
[warning] ofxKinect: update(): device 0 isn't delivering data, reconnecting tries: 1
[verbose] ofxKinect: device 0 0000000000000000 connection opened

Should I try to convert the GLSL to version 120? It is possible? @kashimAstro @arturoc

Thanks very much. 😃😃😃

kashimAstro commented 7 years ago

@LuZhouheng you can try converting to 120. this weekend I try to work on an example kinect without geometry shader.

arturoc commented 7 years ago

i don't think the geometry shader is the problem, there's some weird stuff in your shaders like gl_Vertex and gl_Normal which are not available anymore in opengl 3+ or glsl 150 or more, probably because of the compatibility flag you can use them in other platforms but i would recommend to use the predefined OF attributes:

in vec4 postiion;
in vec2 texcoord;
in vec3 normal;
in vec4 color;

which are custom attributes predefined when creating the shader by OF and completely compatible with opengl 3+

kashimAstro commented 7 years ago

@arturoc true this is a my error. @LuZhouheng I will try to do update this weekend.