Texture::Texture(const ImagePtr& image, bool buildMipmaps) { m_id = 0; if(!setupSize(image->getSize(), buildMipmaps)) return; createTexture(); ImagePtr glImage = image; if(m_size != m_glSize) { glImage = ImagePtr(new Image(m_glSize, image->getBpp())); glImage->paste(image); } else glImage = image; bind(); if(buildMipmaps) { int level = 0; do { setupPixels(level++, glImage->getSize(), glImage->getPixelData(), glImage->getBpp()); } while(glImage->nextMipmap()); m_hasMipmaps = true; } else setupPixels(0, glImage->getSize(), glImage->getPixelData(), glImage->getBpp()); setupWrap(); setupFilters(); }
bool Font::cacheChar(wchar_t charCode) { if (isCharCached(charCode)) return true; if (charCode == 0) return false; if (!setupSize()) return false; CacheEntry* Entry = new CacheEntry; Entry->charCode = charCode; Entry->glyphIndex = FT_Get_Char_Index(mFace, charCode); if (Entry->glyphIndex == 0) { delete Entry; return false; } if (FT_Load_Glyph(mFace, Entry->glyphIndex, FT_LOAD_RENDER) != 0) { delete Entry; return false; } Entry->Width = mWidth; Entry->Height = mHeight; Entry->glyphWidth = mFace->glyph->bitmap.width; Entry->glyphHeight = mFace->glyph->bitmap.rows; renderGlyph(&mFace->glyph->bitmap, Entry->Texture, Entry->textureWidth, Entry->textureHeight); Entry->Left = mFace->glyph->bitmap_left; Entry->Top = mFace->glyph->bitmap_top; Entry->Advance = mFace->glyph->advance.x / 64; mCache.insert(std::pair<wchar_t, CacheEntry*>(charCode, Entry)); return true; }
Texture::Texture(const Size& size) { m_id = 0; if(!setupSize(size)) return; createTexture(); bind(); setupPixels(0, m_glSize, nullptr, 4); setupWrap(); setupFilters(); }
Window::Window(QWidget *parent) : QWidget(parent) { // set window flags as dde-lock, so we can easily cover it. setWindowFlags(Qt::BypassWindowManagerHint | Qt::FramelessWindowHint); setupSize(); setStyleSheet("Window { background: black }"); m_image = new QLabel(this); m_image->setPixmap(QPixmap(":/images/lowpower.png")); setupImagePosition(); }
AnimatedTexture::AnimatedTexture(const Size& size, std::vector<ImagePtr> frames, std::vector<int> framesDelay, bool buildMipmaps, bool compress) { if(!setupSize(size, buildMipmaps)) return; for(uint i=0;i<frames.size();++i) { m_frames.push_back(new Texture(frames[i], buildMipmaps, compress)); } m_framesDelay = framesDelay; m_hasMipmaps = buildMipmaps; m_id = m_frames[0]->getId(); m_currentFrame = 0; m_animTimer.restart(); }