GLState &GLState::setNormalizedScissor(Rectanglef const &normScissorRect) { Rectangleui vp = viewport(); Rectangleui scis(Vector2ui(normScissorRect.left() * vp.width(), normScissorRect.top() * vp.height()), Vector2ui(std::ceil(normScissorRect.right() * vp.width()), std::ceil(normScissorRect.bottom() * vp.height()))); return setScissor(scis); }
Player::Player(Updatable* parent) : PatternAnimation(parent, NULL, textureResources.get("character"), Vector2ui(0, 0), Vector2ui(0, 0), Vector2ui(118, 99), Vector2ui(3, 1), 3, 10), m_shots(NULL), m_nbShots(0), m_orientation(AHEAD), m_currentWeapon(NULL) { m_updateFocus = false; m_currentWeapon = new MachineGun(this, NULL); m_weapons.add("MachineGun", m_currentWeapon); m_currentWeapon = new ShotGun(this, NULL); m_weapons.add("ShotGun", m_currentWeapon); setMaterial(&m_textureMaterial); scale(glm::vec3(0.22, 0.15, 1.0)); setPositionOrigin(glm::vec3(0.5, 0.5, 0.0), true); }
void LabelWidget::updateGeometry() { /// @todo What if patch replacement is disabled? if(d->patch) { patchinfo_t info; R_GetPatchInfo(*d->patch, &info); geometry().setSize(Vector2ui(info.geometry.size.width, info.geometry.size.height)); return; } FR_PushAttrib(); Size2Raw size; FR_SetFont(page().predefinedFont(mn_page_fontid_t(font()))); FR_TextSize(&size, d->text.toUtf8().constData()); geometry().setSize(Vector2ui(size.width, size.height)); FR_PopAttrib(); }
//------------------------------------------------------------------------------ Vector2ui Font::estimate(const std::string& text) const { if (! data) return Vector2ui(0, 0); int result = 0; int w = 0; int h = 0; if (text.empty()) result = TTF_SizeUTF8(data->font, " ", &w, &h); else result = TTF_SizeUTF8(data->font, text.c_str(), &w, &h); if (result == 0) return Vector2ui(w, h); else throw std::logic_error(TTF_GetError()); }
AbstractImage* GuillotineImageAtlas::ResizeImage(AbstractImage* oldImage, const Vector2ui& size) const { std::unique_ptr<Image> newImage(new Image(ImageType_2D, PixelFormatType_A8, size.x, size.y)); if (oldImage) { Image& image = *static_cast<Image*>(oldImage); newImage->Copy(image, Rectui(size), Vector2ui(0, 0)); // Copie des anciennes données } return newImage.release(); }
bool BoxFilterFilmBlock::AddSample(const Spectrum &s, const Vector2ui &global_pixel, const Vector2f &sample) { // Check we are inside pixel boundaries if (sample.x() < 0.f || sample.x() > 1.f || sample.y() < 0.f || sample.y() > 1.f) { return false; } // Compute local pixel coordinates Vector2ui local_pixel = global_pixel - Vector2ui(width_offset, height_offset); // Add sample raster[local_pixel.y() * width + local_pixel.x()] += s; // Increase number of samples of the pixel num_samples[local_pixel.y() * width + local_pixel.x()]++; return true; }
bool RenderWindow::CopyToImage(AbstractImage* image, const Vector3ui& dstPos) const { #if NAZARA_RENDERER_SAFE if (!m_context) { NazaraError("Window has not been created"); return false; } #endif return CopyToImage(image, Rectui(Vector2ui(0U), GetSize()), dstPos); }
void DeferredRenderTechnique::SetPass(RenderPassType relativeTo, int position, DeferredRenderPass* pass) { if (pass) { pass->Initialize(this); if (m_GBufferSize != Vector2ui(0U)) pass->Resize(m_GBufferSize); m_passes[relativeTo][position].reset(pass); } else m_passes[relativeTo].erase(position); }
void InlineListWidget::updateGeometry() { FR_PushAttrib(); FR_SetFont(page().predefinedFont(mn_page_fontid_t(font()))); Size2Raw maxSize{}; Size2Raw size; for (int i = 0; i < items().size(); ++i) { FR_TextSize(&size, items().at(i)->text().toUtf8().constData()); maxSize.width = de::max(maxSize.width, size.width); maxSize.height = de::max(maxSize.height, size.height); } geometry().setSize(Vector2ui(maxSize.width, maxSize.height)); FR_PopAttrib(); }
void initBlur() { if (blur) return; blur.reset(new BlurState); // The blurred version of the view is downsampled. blur->size = (self().root().viewSize() / GuiWidget::toDevicePixels(4)).max(Vector2ui(1, 1)); for (int i = 0; i < 2; ++i) { // Multisampling is disabled in the blurs for now. blur->fb[i].reset(new GLTextureFramebuffer(Image::RGB_888, blur->size, 1)); blur->fb[i]->glInit(); blur->fb[i]->colorTexture().setFilter(gl::Linear, gl::Linear, gl::MipNone); } // Set up the drawble. DefaultVertexBuf *buf = new DefaultVertexBuf; blur->drawable.addBuffer(buf); buf->setVertices(gl::TriangleStrip, DefaultVertexBuf::Builder().makeQuad( Rectanglef(0, 0, 1, 1), Vector4f(1, 1, 1, 1), Rectanglef(0, 0, 1, 1)), gl::Static); blur->uBlurStep = Vector2f(1.f / float(blur->size.x), 1.f / float(blur->size.y)); self().root().shaders().build(blur->drawable.program(), "fx.blur.horizontal") << blur->uMvpMatrix << blur->uTex << blur->uBlurStep << blur->uWindow; blur->drawable.addProgram("vert"); self().root().shaders().build(blur->drawable.program("vert"), "fx.blur.vertical") << blur->uMvpMatrix << blur->uTex << blur->uColor << blur->uBlurStep << blur->uWindow; }
//------------------------------------------------------------------------------ inline Vector2ui computeCoordinate ( const Vector2f& position, const Domain& domain ) { int i = static_cast<int> ( std::ceil((position.X - domain.Origin.X)/domain.Spacing) ); int j = static_cast<int> ( std::ceil((position.Y - domain.Origin.Y)/domain.Spacing) ); i = std::max<int>(0, std::min<int>(i, domain.Dimensions.X - 1)); j = std::max<int>(0, std::min<int>(j, domain.Dimensions.Y - 1)); return Vector2ui(i, j); }
CPlayer::CPlayer(CLevel *pLevel): _position(PLAYER_START_POSITION), _nextPosition(_position), _pLevel(pLevel) { IAnimation *pAnim = 0; AddAnimation(pAnim, PAI_WALK_UP); pAnim->SetTexture(TEXTURE_PLAYER_NAME); pAnim->SetFrameSize(Vector2ui(PAP_FRAME_WIDTH, PAP_FRAME_HEIGHT)); pAnim->SetFirstFrame(PAP_WALK_UP_FIRST); pAnim->SetLastFrame(PAP_WALK_UP_LAST); pAnim->SetDelayTime(PAP_DELAY); AddAnimation(pAnim, PAI_STAND_UP); pAnim->SetTexture(TEXTURE_PLAYER_NAME); pAnim->SetFrameSize(Vector2ui(PAP_FRAME_WIDTH, PAP_FRAME_HEIGHT)); pAnim->SetFirstFrame(PAP_STAND_UP_FIRST); pAnim->SetLastFrame(PAP_STAND_UP_LAST); pAnim->SetDelayTime(PAP_DELAY); AddAnimation(pAnim, PAI_WALK_DOWN); pAnim->SetTexture(TEXTURE_PLAYER_NAME); pAnim->SetFrameSize(Vector2ui(PAP_FRAME_WIDTH, PAP_FRAME_HEIGHT)); pAnim->SetFirstFrame(PAP_WALK_DOWN_FIRST); pAnim->SetLastFrame(PAP_WALK_DOWN_LAST); pAnim->SetDelayTime(PAP_DELAY); AddAnimation(pAnim, PAI_STAND_DOWN); pAnim->SetTexture(TEXTURE_PLAYER_NAME); pAnim->SetFrameSize(Vector2ui(PAP_FRAME_WIDTH, PAP_FRAME_HEIGHT)); pAnim->SetFirstFrame(PAP_STAND_DOWN_FIRST); pAnim->SetLastFrame(PAP_STAND_DOWN_LAST); pAnim->SetDelayTime(PAP_DELAY); AddAnimation(pAnim, PAI_WALK_RIGHT); pAnim->SetTexture(TEXTURE_PLAYER_NAME); pAnim->SetFrameSize(Vector2ui(PAP_FRAME_WIDTH, PAP_FRAME_HEIGHT)); pAnim->SetFirstFrame(PAP_WALK_RIGHT_FIRST); pAnim->SetLastFrame(PAP_WALK_RIGHT_LAST); pAnim->SetDelayTime(PAP_DELAY); AddAnimation(pAnim, PAI_STAND_RIGHT); pAnim->SetTexture(TEXTURE_PLAYER_NAME); pAnim->SetFrameSize(Vector2ui(PAP_FRAME_WIDTH, PAP_FRAME_HEIGHT)); pAnim->SetFirstFrame(PAP_STAND_RIGHT_FIRST); pAnim->SetLastFrame(PAP_STAND_RIGHT_LAST); pAnim->SetDelayTime(PAP_DELAY); AddAnimation(pAnim, PAI_WALK_LEFT); pAnim->SetTexture(TEXTURE_PLAYER_NAME); pAnim->SetFrameSize(Vector2ui(PAP_FRAME_WIDTH, PAP_FRAME_HEIGHT)); pAnim->SetFirstFrame(PAP_WALK_LEFT_FIRST); pAnim->SetLastFrame(PAP_WALK_LEFT_LAST); pAnim->SetDelayTime(PAP_DELAY); AddAnimation(pAnim, PAI_STAND_LEFT); pAnim->SetTexture(TEXTURE_PLAYER_NAME); pAnim->SetFrameSize(Vector2ui(PAP_FRAME_WIDTH, PAP_FRAME_HEIGHT)); pAnim->SetFirstFrame(PAP_STAND_LEFT_FIRST); pAnim->SetLastFrame(PAP_STAND_LEFT_LAST); pAnim->SetDelayTime(PAP_DELAY); _pCurrAnim = _animationsMap.at(PAI_STAND_RIGHT); _eState = PS_STAND_RIGHT; _nextPosition = _position; //_pCurrAnim->SetFrameSize(Vector2f(128.0f, 256.0f)); }
void LineEditWidget::updateGeometry() { FR_SetFont(mnRendState->textFonts[font()]); geometry().setSize(Vector2ui(FR_CharWidth('w') * d->maxLength - MNDATA_EDIT_BACKGROUND_OFFSET_X*2, 14)); }
void LineSetAccess::addLine(uint i, uint j) { mLines->push_back(Vector2ui(i,j)); }
void updateGeometry() { // If scroll position has changed, must update text geometry. int scrollY = self().scrollPositionY().valuei(); if (oldScrollY != scrollY) { oldScrollY = scrollY; self().requestGeometry(); } Rectanglei pos; if (self().hasChangedPlace(pos)) { self().requestGeometry(); } // Make sure the text has been wrapped for the current dimensions. int wrapWidth; if (widthPolicy == ui::Expand) { wrapWidth = maxLineWidth; } else { wrapWidth = self().rule().width().valuei() - self().margins().width().valuei(); } glText.setLineWrapWidth(wrapWidth); if (glText.update()) { // Text is ready for drawing? if (!glText.isBeingWrapped() && progress->isVisible()) { contentMaxWidth->set(de::max(contentMaxWidth->value(), float(glText.wrappedSize().x))); self().setContentSize(Vector2ui(contentMaxWidth->valuei(), glText.wrappedSize().y)); progress->hide(); } self().requestGeometry(); } if (!self().geometryRequested()) return; // Background and scroll indicator. VertexBuf::Builder verts; self().glMakeGeometry(verts); drawable.buffer<VertexBuf>(ID_BACKGROUND) .setVertices(gl::TriangleStrip, verts, self().isScrolling()? gl::Dynamic : gl::Static); uMvpMatrix = root().projMatrix2D(); if (!progress->isVisible()) { DENG2_ASSERT(glText.isReady()); // Determine visible range of lines. Font const &font = self().font(); int contentHeight = de::min(self().contentHeight(), self().rule().height().valuei()); int const extraLines = 1; int numVisLines = contentHeight / font.lineSpacing().valuei() + 2 * extraLines; int firstVisLine = scrollY / font.lineSpacing().valuei() - extraLines + 1; // Update visible range and release/alloc lines accordingly. Rangei visRange(firstVisLine, firstVisLine + numVisLines); if (visRange != glText.range()) { glText.setRange(visRange); glText.update(); // alloc visible lines VertexBuf::Builder verts; glText.makeVertices(verts, Vector2i(0, 0), ui::AlignLeft); drawable.buffer<VertexBuf>(ID_TEXT).setVertices(gl::TriangleStrip, verts, gl::Static); // Update content size to match the generated vertices exactly. self().setContentWidth(glText.verticesMaxWidth()); } uScrollMvpMatrix = root().projMatrix2D() * Matrix4f::translate(Vector2f(self().contentRule().left().valuei(), self().contentRule().top().valuei())); } // Geometry is now up to date. self().requestGeometry(false); }