MCPcopy Create free account
hub / github.com/christophhart/HISE / makeStatistics

Method makeStatistics

hi_scripting/scripting/api/ScriptingGraphics.cpp:705–763  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

703}
704
705void ScriptingObjects::ScriptShader::makeStatistics()
706{
707 using namespace juce::gl;
708
709 auto d = new DynamicObject();
710
711 int major = 0, minor = 0;
712
713 if(OpenGLContext::getCurrentContext() == nullptr)
714 {
715 d->setProperty("VersionString", "0.0");
716 d->setProperty("Major", minor);
717 d->setProperty("Minor", major);
718 d->setProperty("Vendor", "Inactive");
719 d->setProperty("Renderer", "Inactive");
720 d->setProperty("GLSL Version", "0.0.0");
721
722 openGLStats = var(d);
723 return;
724 }
725
726 auto vendor = String((const char*)glGetString(GL_VENDOR));
727 jassert(glGetError() == GL_NO_ERROR);
728
729 auto renderer = String((const char*)glGetString(GL_RENDERER));
730 jassert(glGetError() == GL_NO_ERROR);
731
732 auto version = String((const char*)glGetString(GL_VERSION));
733 jassert(glGetError() == GL_NO_ERROR);
734
735 glGetIntegerv(GL_MAJOR_VERSION, &major);
736 auto ok1 = glGetError();
737
738 glGetIntegerv(GL_MINOR_VERSION, &minor);
739 auto ok2 = glGetError();
740
741 auto shaderVersion = OpenGLShaderProgram::getLanguageVersion();
742 jassert(glGetError() == GL_NO_ERROR);
743
744 // Apparently this fails on older macs, so we need to parse the version integers from the string
745 if(ok1 != GL_NO_ERROR || ok2 != GL_NO_ERROR)
746 {
747 const auto v = version.upToFirstOccurrenceOf(" ", false, false);
748
749 major = v.upToFirstOccurrenceOf(".", false, false).getIntValue();
750 minor = v.fromFirstOccurrenceOf(".", false, false).getIntValue();
751 }
752
753
754
755 d->setProperty("VersionString", version);
756 d->setProperty("Major", major);
757 d->setProperty("Minor", minor);
758 d->setProperty("Vendor", vendor);
759 d->setProperty("Renderer", renderer);
760 d->setProperty("GLSL Version", shaderVersion);
761
762 openGLStats = var(d);

Callers 2

performMethod · 0.80
paintMethod · 0.80

Calls 6

varFunction · 0.85
StringClass · 0.50
setPropertyMethod · 0.45
upToFirstOccurrenceOfMethod · 0.45
getIntValueMethod · 0.45
fromFirstOccurrenceOfMethod · 0.45

Tested by

no test coverage detected