openglLogs.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #include "openglLogs.h"
  2. #include <glad/glad.h>
  3. //https://learnopengl.com/In-Practice/Debugging
  4. void GLAPIENTRY glDebugOutput(GLenum source,
  5. GLenum type,
  6. unsigned int id,
  7. GLenum severity,
  8. GLsizei length,
  9. const char *message,
  10. const void *userParam)
  11. {
  12. // ignore non-significant error/warning codes
  13. if (id == 131169 || id == 131185 || id == 131218 || id == 131204
  14. || id == 131222
  15. || id == 131140 //that dittering thing
  16. ) return;
  17. pika::OpenglLogsWindow *openglLogsWindow = (pika::OpenglLogsWindow*)userParam;
  18. if (type == GL_DEBUG_TYPE_PERFORMANCE) return;
  19. openglLogsWindow->errorsReported[id] ++;
  20. __noop();
  21. }
  22. void pika::OpenglLogsWindow::init(pika::pikaImgui::ImGuiIdsManager &idManager)
  23. {
  24. imguiId = idManager.getImguiIds();
  25. //glEnable(GL_DEBUG_OUTPUT);
  26. //glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
  27. //glDebugMessageCallback(glDebugOutput, this);
  28. //glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE);
  29. }
  30. void pika::OpenglLogsWindow::update(bool &open)
  31. {
  32. ImGui::PushID(imguiId);
  33. if (!ImGui::Begin(ICON_NAME, &open))
  34. {
  35. ImGui::End();
  36. ImGui::PopID();
  37. return;
  38. }
  39. ImGui::SetWindowSize({300,100}, ImGuiCond_FirstUseEver);
  40. for (auto &i : errorsReported)
  41. {
  42. ImGui::Text("Message id %iu, count %iu", i.first, i.second);
  43. }
  44. ImGui::End();
  45. ImGui::PopID();
  46. }