Beispiel #1
0
void Texture::create (TextureData::ptr data) {
    this->glHandle = 0;
    this->enforcePotImages = true;
    this->useHWMipMap = true;
    this->assetManager = 0;

    glHandle = createGLHandle();
    load(data);

    if (data->isManaged()) addManagedTexture(gdx_cpp::Gdx::app, shared_from_this());
}
Beispiel #2
0
void Texture::load (const TextureData::ptr& data) {
    if (this->data != NULL && data->isManaged() != this->data->isManaged()) {
        Gdx::app->error("Texture.cpp", "New data must have the same managed status as the old data");
    }

    this->data = data;

    if (data->getType() == TextureData::TextureDataType::Pixmap) {
        Pixmap::ptr pixmap = data->getPixmap();
        uploadImageData(pixmap);
        if (data->disposePixmap()) pixmap->dispose();
        setFilter(minFilter, magFilter);
        setWrap(uWrap, vWrap);
    }

    if (data->getType() == TextureData::TextureDataType::Compressed) {
        Gdx::gl->glBindTexture(GL_TEXTURE_2D, glHandle);
        data->uploadCompressedData();
        setFilter(minFilter, magFilter);
        setWrap(uWrap, vWrap);
    }
}