BsGLEventQuery.cpp 899 B

12345678910111213141516171819202122232425262728293031323334
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "BsGLEventQuery.h"
  4. #include "BsRenderStats.h"
  5. namespace BansheeEngine
  6. {
  7. GLEventQuery::GLEventQuery()
  8. :mQueryObj(0)
  9. {
  10. glGenQueries(1, &mQueryObj);
  11. BS_INC_RENDER_STAT_CAT(ResCreated, RenderStatObject_Query);
  12. }
  13. GLEventQuery::~GLEventQuery()
  14. {
  15. glDeleteQueries(1, &mQueryObj);
  16. BS_INC_RENDER_STAT_CAT(ResDestroyed, RenderStatObject_Query);
  17. }
  18. void GLEventQuery::begin()
  19. {
  20. glQueryCounter(mQueryObj, GL_TIMESTAMP);
  21. setActive(true);
  22. }
  23. bool GLEventQuery::isReady() const
  24. {
  25. GLint done = 0;
  26. glGetQueryObjectiv(mQueryObj, GL_QUERY_RESULT_AVAILABLE, &done);
  27. return done == GL_TRUE;
  28. }
  29. }