std::string AbstractObject::getLabelImplementationKhr(const GLenum identifier, const GLuint name) { /* Get label size (w/o null terminator). Specifying 0 as size is not allowed, thus we pass the maximum instead. */ GLsizei size = 0; #ifndef MAGNUM_TARGET_GLES glGetObjectLabel(identifier, name, maxLabelLength(), &size, nullptr); #elif !defined(CORRADE_TARGET_NACL) glGetObjectLabelKHR(identifier, name, maxLabelLength(), &size, nullptr); #else static_cast<void>(identifier); static_cast<void>(name); CORRADE_ASSERT_UNREACHABLE(); #endif /* Make place also for the null terminator */ std::string label; label.resize(size+1); #ifndef MAGNUM_TARGET_GLES glGetObjectLabel(identifier, name, size+1, nullptr, &label[0]); #elif !defined(CORRADE_TARGET_NACL) glGetObjectLabelKHR(identifier, name, size+1, nullptr, &label[0]); #else CORRADE_ASSERT_UNREACHABLE(); #endif /* Pop null terminator and return the string */ label.resize(size); return label; }
int maxLabelLength(node n, char **maxLabel) // get a pointer to longest label among leaves of this clade; { node child; char *bestMaxLabel; int max=0,len; if (isTip(n)) { *maxLabel = n->label; printf("Leaf = %s length = %i\n",n->label,strlen(n->label)); return strlen(n->label); } else if (!isRoot(n) && n->isCompactNode) { if (n->label ) // a root node might be compact but it is never a leaf in a rendered tree { *maxLabel = n->label; return strlen(n->label); } else { *maxLabel = ""; return 0; } } else { child=n->firstdesc; SIBLOOP(child) { len=maxLabelLength(child, maxLabel); if (len > max) { max = len; bestMaxLabel=*maxLabel; } } *maxLabel=bestMaxLabel; return max; } }
std::string AbstractObject::getLabelImplementationKhr(const GLenum identifier, const GLuint name) { /** * @todo Get rid of this workaround when NVidia returns proper size for * length=0 & label=nullptr (even crashes on length>0 & label=nullptr) */ #if 0 /* Get label size (w/o null terminator) */ GLsizei size; #ifndef MAGNUM_TARGET_GLES glGetObjectLabel(type, name, 0, &size, nullptr); #else glGetObjectLabelKHR(type, name, 0, &size, nullptr); #endif /* Make place also for the null terminator */ std::string label; label.resize(size+1); #ifndef MAGNUM_TARGET_GLES glGetObjectLabel(identifier, name, size+1, nullptr, &label[0]); #else glGetObjectLabelKHR(identifier, name, size+1, nullptr, &label[0]); #endif /* Pop null terminator and return the string */ label.resize(size); return label; #else GLsizei size; std::string label; label.resize(maxLabelLength()); /** @todo Re-enable when extension loader is available for ES */ #ifndef MAGNUM_TARGET_GLES glGetObjectLabel(identifier, name, label.size(), &size, &label[0]); #else static_cast<void>(identifier); static_cast<void>(name); CORRADE_INTERNAL_ASSERT(false); //glGetObjectLabelKHR(identifier, name, label.size(), &size, &label[0]); #endif return label.substr(0, size); #endif }