opengles3-book icon indicating copy to clipboard operation
opengles3-book copied to clipboard

example Hello_Triangle. glCreateShader() = 0

Open OrangeWxc opened this issue 8 years ago • 6 comments

The example of Hello_Triangle. `GLuint LoadShader ( GLenum type, const char *shaderSrc ) { GLuint shader; GLint compiled;

// Create the shader object shader = glCreateShader ( type ); if (shader == 0) { return 0; }

// Load the shader source glShaderSource ( shader, 1, &shaderSrc, NULL );

// Compile the shader glCompileShader ( shader );

// Check the compile status glGetShaderiv ( shader, GL_COMPILE_STATUS, &compiled );

if ( !compiled ) { GLint infoLen = 0;

  glGetShaderiv ( shader, GL_INFO_LOG_LENGTH, &infoLen );

  if ( infoLen > 1 )
  {
     char *infoLog = malloc ( sizeof ( char ) * infoLen );

     glGetShaderInfoLog ( shader, infoLen, NULL, infoLog );
     esLogMessage ( "Error compiling shader:\n%s\n", infoLog );

     free ( infoLog );
  }

  glDeleteShader ( shader );
  return 0;

}

return shader;

}`

why glCreateShader() return 0? I didn't change any code.

OrangeWxc avatar Mar 14 '16 15:03 OrangeWxc

And you can see "(Error) There is no context bound to the current thread." in console...
Base Windows 7 and VisualStudio 2013.

OrangeWxc avatar Mar 14 '16 15:03 OrangeWxc

@OrangeWxc What GPU and OpenGL driver are you using? Which OpenGL ES 3.0 SDK? It sounds like somehow OpenGL ES context creation failed and glCreateShader is probably just the first entrypoint to be called.

danginsburg avatar Mar 15 '16 13:03 danginsburg

On windows10 system,I use PowerVR_SDK 4.0. build a new code,Now,a new prolem:

FATAL - Exception thrown in GLES32Api::glGetnUniformfvKHR -> FATAL: No EGL context available for type GLES32Api when calling glGetnUniformfvKHR FATAL - Exception thrown in GLES32Api::glGetnUniformfvKHR -> FATAL: No EGL context available for type GLES32Api when calling glGetnUniformfvKHR FATAL - Exception thrown in GLES32Api::glGetTexParameterIuivEXT -> FATAL: No EGL context available for type GLES32Api when calling glGetTexParameterIuivEXT

OrangeWxc avatar Mar 15 '16 14:03 OrangeWxc

Hello,

I am getting the same error. Not sure why I am getting this. I am using PowerVR SDK for linux. If you have any idea about this error, please share.

Thanks Ikshwaku

ikshwaku avatar Jan 28 '17 09:01 ikshwaku

found one more thing: eglChooseConfig is returning zero "numConfigs". So "esCreateWindow" is returning before creating window surface and context, later giving error "There is no context bound to the current thread". Here I am not sure why I am getting "numConfigs" as zero. If you have any idea please let me know.

Thanks, Ikshwaku

ikshwaku avatar Jan 28 '17 10:01 ikshwaku

I faced the same issue while trying to build another solution based on a sample.

The problem was in the _UNICODE preprocessor definition. I also had to switch the Character Set option to Use Multi-Byte Character Set.

I'm on Windows with vs 2017.

Hope it helps.

EugeneKosmin avatar Mar 16 '20 07:03 EugeneKosmin