Răsfoiți Sursa

Examples: imgui_impl_opengl3: Fix empty printout on shader load. (#2584)

Fixed minor bug in CheckShader and CheckProgram

The log_length reported by 
glGetProgramiv(handle, GL_INFO_LOG_LENGTH, &log_length)
will at least return 1, since the string delimiter is also counted.

The old version would always print and empty string to stderr. This is annoying in the emscripten port, since it prints a red error message to the Javascript console. The new version fixes this behavior.
Mario Botsch 6 ani în urmă
părinte
comite
affa7e2422
1 a modificat fișierele cu 2 adăugiri și 2 ștergeri
  1. 2 2
      examples/imgui_impl_opengl3.cpp

+ 2 - 2
examples/imgui_impl_opengl3.cpp

@@ -384,7 +384,7 @@ static bool CheckShader(GLuint handle, const char* desc)
     glGetShaderiv(handle, GL_INFO_LOG_LENGTH, &log_length);
     glGetShaderiv(handle, GL_INFO_LOG_LENGTH, &log_length);
     if ((GLboolean)status == GL_FALSE)
     if ((GLboolean)status == GL_FALSE)
         fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to compile %s!\n", desc);
         fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to compile %s!\n", desc);
-    if (log_length > 0)
+    if (log_length > 1)
     {
     {
         ImVector<char> buf;
         ImVector<char> buf;
         buf.resize((int)(log_length + 1));
         buf.resize((int)(log_length + 1));
@@ -402,7 +402,7 @@ static bool CheckProgram(GLuint handle, const char* desc)
     glGetProgramiv(handle, GL_INFO_LOG_LENGTH, &log_length);
     glGetProgramiv(handle, GL_INFO_LOG_LENGTH, &log_length);
     if ((GLboolean)status == GL_FALSE)
     if ((GLboolean)status == GL_FALSE)
         fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to link %s! (with GLSL '%s')\n", desc, g_GlslVersionString);
         fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to link %s! (with GLSL '%s')\n", desc, g_GlslVersionString);
-    if (log_length > 0)
+    if (log_length > 1)
     {
     {
         ImVector<char> buf;
         ImVector<char> buf;
         buf.resize((int)(log_length + 1));
         buf.resize((int)(log_length + 1));