Пример #1
0
GLuint QGLTexturePool::createTexture(GLenum target,
                                            GLint level,
                                            GLint internalformat,
                                            GLsizei width,
                                            GLsizei height,
                                            GLenum format,
                                            GLenum type,
                                            QGLTexture *texture)
{
    GLuint tex;
    glGenTextures(1, &tex);
    glBindTexture(target, tex);
    do {
        glTexImage2D(target, level, internalformat, width, height, 0, format, type, 0);
        GLenum error = glGetError();
        if (error == GL_NO_ERROR) {
            if (texture)
                moveToHeadOfLRU(texture);
            return tex;
        } else if (error != GL_OUT_OF_MEMORY) {
            qWarning("QGLTexturePool: cannot create temporary texture because of invalid params");
            return 0;
        }
    } while (reclaimSpace(internalformat, width, height, format, type, texture));
    qWarning("QGLTexturePool: cannot reclaim sufficient space for a %dx%d texture",
             width, height);
    return 0;
}
Пример #2
0
bool QGLTexturePool::createPermanentTexture(GLuint tex,
                                            GLenum target,
                                            GLint level,
                                            GLint internalformat,
                                            GLsizei width,
                                            GLsizei height,
                                            GLenum format,
                                            GLenum type,
                                            const GLvoid *data)
{
    glBindTexture(target, tex);
    do {
        glTexImage2D(target, level, internalformat, width, height, 0, format, type, data);

        GLenum error = glGetError();
        if (error == GL_NO_ERROR) {
            return true;
        } else if (error != GL_OUT_OF_MEMORY) {
            qWarning("QGLTexturePool: cannot create permanent texture because of invalid params");
            return false;
        }
    } while (reclaimSpace(internalformat, width, height, format, type, 0));
    qWarning("QGLTexturePool: cannot reclaim sufficient space for a %dx%d texture",
             width, height);
    return 0;
}
VGImage QVGImagePool::createPermanentImage(VGImageFormat format,
                                           VGint width, VGint height,
                                           VGbitfield allowedQuality)
{
    VGImage image;
    do {
        image = vgCreateImage(format, width, height, allowedQuality);
        if (image != VG_INVALID_HANDLE)
            return image;
    } while (reclaimSpace(format, width, height, 0));
    qWarning("QVGImagePool: cannot reclaim sufficient space for a %dx%d image",
             width, height);
    return VG_INVALID_HANDLE;
}
VGImage QVGImagePool::createTemporaryImage(VGImageFormat format,
                                           VGint width, VGint height,
                                           VGbitfield allowedQuality,
                                           QVGPixmapData *keepData)
{
    VGImage image;
    do {
        image = vgCreateImage(format, width, height, allowedQuality);
        if (image != VG_INVALID_HANDLE)
            return image;
    } while (reclaimSpace(format, width, height, keepData));
    qWarning("QVGImagePool: cannot reclaim sufficient space for a %dx%d temporary image",
             width, height);
    return VG_INVALID_HANDLE;
}
VGImage QVGImagePool::createImageForPixmap(VGImageFormat format,
                                           VGint width, VGint height,
                                           VGbitfield allowedQuality,
                                           QVGPixmapData *data)
{
    VGImage image;
    do {
        image = vgCreateImage(format, width, height, allowedQuality);
        if (image != VG_INVALID_HANDLE) {
            if (data)
                moveToHeadOfLRU(data);
            return image;
        }
    } while (reclaimSpace(format, width, height, data));
    qWarning("QVGImagePool: cannot reclaim sufficient space for a %dx%d pixmap",
             width, height);
    return VG_INVALID_HANDLE;
}