std::string AbstractObject::getLabelImplementationExt(const GLenum identifier, const GLuint name) { GLsizei size = 0; /* Get label size (w/o null terminator) */ #ifndef CORRADE_TARGET_NACL const GLenum type = extTypeFromKhrIdentifier(identifier); glGetObjectLabelEXT(type, name, 0, &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 CORRADE_TARGET_NACL glGetObjectLabelEXT(identifier, name, size+1, nullptr, &label[0]); #else CORRADE_ASSERT_UNREACHABLE(); #endif /* Pop null terminator and return the string */ label.resize(size); return label; }
std::string AbstractObject::getLabelImplementationExt(const GLenum identifier, const GLuint name) { const GLenum type = extTypeFromKhrIdentifier(identifier); /* Get label size (w/o null terminator) */ GLsizei size; /** @todo Re-enable when extension loader is available for ES */ #ifndef MAGNUM_TARGET_GLES glGetObjectLabelEXT(type, name, 0, &size, nullptr); #else static_cast<void>(type); static_cast<void>(name); CORRADE_INTERNAL_ASSERT(false); #endif /* Make place also for the null terminator */ std::string label; label.resize(size+1); /** @todo Re-enable when extension loader is available for ES */ #ifndef MAGNUM_TARGET_GLES glGetObjectLabelEXT(identifier, name, size+1, nullptr, &label[0]); #endif /* Pop null terminator and return the string */ label.resize(size); return label; }
/** * Get a GL_KHR_debug/GL_EXT_debug_label object label. * * The returned string should be destroyed with free() when no longer * necessary. */ char * getObjectLabel(Context &context, GLenum identifier, GLuint name) { if (!name) { return NULL; } GLsizei length = 0; if (context.KHR_debug) { /* * XXX: According to * http://www.khronos.org/registry/gles/extensions/KHR/debug.txt * description of glGetObjectLabel: * * "If <label> is NULL and <length> is non-NULL then no string will * be returned and the length of the label will be returned in * <length>." * * However NVIDIA 319.60 drivers return a zero length in such * circumstances. 310.14 drivers worked fine though. So, just rely on * GL_MAX_LABEL_LENGTH instead, which might waste a bit of memory, but * should work reliably everywhere. */ if (0) { glGetObjectLabel(identifier, name, 0, &length, NULL); } else { glGetIntegerv(GL_MAX_LABEL_LENGTH, &length); } } if (context.EXT_debug_label) { glGetObjectLabelEXT(identifier, name, 0, &length, NULL); } if (!length) { return NULL; } char *label = (char *)calloc(length + 1, 1); if (!label) { return NULL; } if (context.KHR_debug) { glGetObjectLabel(identifier, name, length + 1, NULL, label); } if (context.EXT_debug_label) { glGetObjectLabelEXT(identifier, name, length + 1, NULL, label); } if (label[0] == '\0') { free(label); return NULL; } return label; }
JNIEXPORT void JNICALL Java_org_lwjgl_opengles_EXTDebugLabel_nglGetObjectLabelEXT__IIIJJ(JNIEnv *__env, jclass clazz, jint type, jint object, jint bufSize, jlong lengthAddress, jlong labelAddress) { glGetObjectLabelEXTPROC glGetObjectLabelEXT = (glGetObjectLabelEXTPROC)tlsGetFunction(401); intptr_t length = (intptr_t)lengthAddress; intptr_t label = (intptr_t)labelAddress; UNUSED_PARAM(clazz) glGetObjectLabelEXT(type, object, bufSize, length, label); }