Esempio n. 1
0
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;
}
Esempio n. 2
0
/**
 * 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;
}
Esempio n. 3
0
std::string object_label     (const type& object)
{
  GLint       size ; glGetIntegerv(GL_MAX_LABEL_LENGTH, &size);
  std::string label; label.resize(size);
  glGetObjectLabel(type::native_type, object.id(), size, nullptr, &label[0]);
  return label;
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengles_GLES32_nglGetObjectLabel__IIIJJ(JNIEnv *__env, jclass clazz, jint identifier, jint name, jint bufSize, jlong lengthAddress, jlong labelAddress) {
    glGetObjectLabelPROC glGetObjectLabel = (glGetObjectLabelPROC)tlsGetFunction(324);
    intptr_t length = (intptr_t)lengthAddress;
    intptr_t label = (intptr_t)labelAddress;
    UNUSED_PARAM(clazz)
    glGetObjectLabel(identifier, name, bufSize, length, label);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL43_nglGetObjectLabel(JNIEnv *__env, jclass clazz, jint identifier, jint name, jint bufSize, jlong lengthAddress, jlong labelAddress, jlong __functionAddress) {
	GLsizei *length = (GLsizei *)(intptr_t)lengthAddress;
	GLchar *label = (GLchar *)(intptr_t)labelAddress;
	glGetObjectLabelPROC glGetObjectLabel = (glGetObjectLabelPROC)(intptr_t)__functionAddress;
	UNUSED_PARAMS(__env, clazz)
	glGetObjectLabel(identifier, name, bufSize, length, label);
}
Esempio n. 6
0
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
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL43_nglGetObjectLabel(JNIEnv *env, jclass clazz, jint identifier, jint name, jint bufSize, jlong length, jlong label, jlong function_pointer) {
	GLsizei *length_address = (GLsizei *)(intptr_t)length;
	GLchar *label_address = (GLchar *)(intptr_t)label;
	glGetObjectLabelPROC glGetObjectLabel = (glGetObjectLabelPROC)((intptr_t)function_pointer);
	glGetObjectLabel(identifier, name, bufSize, length_address, label_address);
}
enum piglit_result
piglit_display(void)
{
	bool pass = true;
	GLchar label[11];
	GLsizei length;
	GLuint ids[10];
	GLint param;

	/* Throw some invalid inputs at glCreateRenderbuffers */

	/* n is negative */
	glCreateRenderbuffers(-1, ids);
	SUBTEST(GL_INVALID_VALUE, pass, "n < 0");

	/* Throw some valid inputs at glCreateRenderbuffers. */

	/* n is zero */
	glCreateRenderbuffers(0, NULL);
	SUBTEST(GL_NO_ERROR, pass, "n == 0");

	/* n is more than 1 */
	glCreateRenderbuffers(10, ids);
	SUBTEST(GL_NO_ERROR, pass, "n > 1");

	/* test the default state of dsa-created render buffer objects */
	SUBTESTCONDITION(glIsRenderbuffer(ids[2]), pass, "IsRenderbuffer()");

	glBindRenderbuffer(GL_RENDERBUFFER, ids[2]);
	piglit_check_gl_error(GL_NO_ERROR);

	glGetRenderbufferParameteriv(GL_RENDERBUFFER,
				     GL_RENDERBUFFER_WIDTH, &param);
	piglit_check_gl_error(GL_NO_ERROR);
	SUBTESTCONDITION(param == 0, pass,
			 "default width(%d) == 0", param);

	glGetRenderbufferParameteriv(GL_RENDERBUFFER,
				     GL_RENDERBUFFER_HEIGHT, &param);
	piglit_check_gl_error(GL_NO_ERROR);
	SUBTESTCONDITION(param == 0, pass,
			 "default height(%d) == 0", param);

	glGetRenderbufferParameteriv(GL_RENDERBUFFER,
				     GL_RENDERBUFFER_INTERNAL_FORMAT, &param);
	piglit_check_gl_error(GL_NO_ERROR);
	SUBTESTCONDITION(param == GL_RGBA, pass,
			 "default internal format == RGBA");

	glGetRenderbufferParameteriv(GL_RENDERBUFFER,
				     GL_RENDERBUFFER_RED_SIZE, &param);
	piglit_check_gl_error(GL_NO_ERROR);
	SUBTESTCONDITION(param == 0, pass,
			 "default red size(%d) == 0", param);

	glGetRenderbufferParameteriv(GL_RENDERBUFFER,
				     GL_RENDERBUFFER_GREEN_SIZE, &param);
	piglit_check_gl_error(GL_NO_ERROR);
	SUBTESTCONDITION(param == 0, pass,
			 "default green size(%d) == 0", param);

	glGetRenderbufferParameteriv(GL_RENDERBUFFER,
				     GL_RENDERBUFFER_BLUE_SIZE, &param);
	piglit_check_gl_error(GL_NO_ERROR);
	SUBTESTCONDITION(param == 0, pass,
			 "default blue size(%d) == 0", param);

	glGetRenderbufferParameteriv(GL_RENDERBUFFER,
				     GL_RENDERBUFFER_ALPHA_SIZE, &param);
	piglit_check_gl_error(GL_NO_ERROR);
	SUBTESTCONDITION(param == 0, pass,
			 "default alpha size(%d) == 0", param);

	glGetRenderbufferParameteriv(GL_RENDERBUFFER,
				     GL_RENDERBUFFER_DEPTH_SIZE, &param);
	piglit_check_gl_error(GL_NO_ERROR);
	SUBTESTCONDITION(param == 0, pass,
			 "default depth size(%d) == 0", param);

	glGetRenderbufferParameteriv(GL_RENDERBUFFER,
				     GL_RENDERBUFFER_STENCIL_SIZE, &param);
	piglit_check_gl_error(GL_NO_ERROR);
	SUBTESTCONDITION(param == 0, pass,
			 "default stencil size(%d) == 0", param);

	glGetRenderbufferParameteriv(GL_RENDERBUFFER,
				     GL_RENDERBUFFER_SAMPLES, &param);
	piglit_check_gl_error(GL_NO_ERROR);
	SUBTESTCONDITION(param == 0, pass,
			 "default no. of samples(%d) == 0", param);

	glGetObjectLabel(GL_RENDERBUFFER, ids[2], 11, &length, label);
	piglit_check_gl_error(GL_NO_ERROR);
	SUBTESTCONDITION(length == 0, pass,
			 "default label size(%d) == 0", length);

	/* clean up */
	glDeleteRenderbuffers(10, ids);

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}