예제 #1
0
void GoodNightMorningApp::drawTweets()
{
	gl::color( ColorA( 1, 1, 1, mMorningTweetAlpha ) );
	if( mMorningTweetTex )
		gl::draw( mMorningTweetTex, Vec2f( 0.1f, mMorningTweetPos ) * mDrawBounds.getSize() + mDrawBounds.getUpperLeft() );
	gl::color( ColorA( 1, 1, 1, mNightTweetAlpha ) );
	if( mNightTweetTex )
		gl::draw( mNightTweetTex, Vec2f( 0.6f, mNightTweetPos ) * mDrawBounds.getSize() + mDrawBounds.getUpperLeft() );
	gl::color( Color::white() ); // restore for future drawing
}
예제 #2
0
//----------------------------------------------------------------------------//
void IrrlichtTexture::blitFromMemory(const void* sourceData, const Rectf& area)
{
    if (!d_texture)
        return;

    const size_t pitch = d_texture->getPitch();
    const std::uint32_t* src = static_cast<const std::uint32_t*>(sourceData);
    std::uint32_t* dst = static_cast<std::uint32_t*>(d_texture->lock());

    if (!dst)
        throw RendererException(
            "[IrrlichtRenderer] ITexture::lock failed.");

    dst += static_cast<size_t>(area.top()) * (pitch / 4) +
        static_cast<size_t>(area.left());

    const Sizef sz(area.getSize());

    for (int j = 0; j < sz.d_height; ++j)
    {
        for (int i = 0; i < sz.d_width; ++i)
        {
            dst[i] = src[i];
        }

        src += static_cast<int>(sz.d_width);
        dst += pitch / 4;
    }
    
    d_texture->unlock();
}
예제 #3
0
vec2 Control::getHitPercent( const vec2 &pt )
{
    vec2 hp;
    Rectf r = mHitRect;
    r.offset( getOrigin() );
    hp = ( pt - r.getUpperLeft() ) / r.getSize();
    return hp;
}
예제 #4
0
vec2 View::getHitPercent( const vec2 &pt )
{
    vec2 hp;
    Rectf r;
    r.set( 0, 0, getWidth(), getHeight() );
    r.offset( getOrigin() );
    hp = ( pt - r.getUpperLeft() ) / r.getSize();
    return hp;
}
예제 #5
0
//----------------------------------------------------------------------------//
void BasicImage::setArea(const Rectf& pixel_area)
{
    d_area = pixel_area;
    d_pixelSize = pixel_area.getSize();

    if (d_autoScaled != ASM_Disabled)
        notifyDisplaySizeChanged(
            System::getSingleton().getRenderer()->getDisplaySize());
}
예제 #6
0
파일: Texture.cpp 프로젝트: ruleless/CEGUI
//----------------------------------------------------------------------------//
void OpenGLESTexture::loadCompressedTextureBuffer(const Rectf& dest_area,
        const GLvoid* buffer) const
{
    const GLsizei image_size = getCompressedTextureSize(dest_area.getSize());

    glCompressedTexImage2D(GL_TEXTURE_2D, 0, d_format,
                           static_cast<GLsizei>(dest_area.getWidth()),
                           static_cast<GLsizei>(dest_area.getHeight()),
                           0, image_size, buffer);
}
  ShapeProxy(nvg::Context& vg, shared_ptr<Shape> shape) : mShape{ shape } {
    mBounds = mShape->getBounds();

    // Grow the bounds a little to preserve nice anti-aliasing at the edges.
    mBounds.inflate(vec2(2));

    auto fboSize = mBounds.getSize() * getWindow()->getContentScale();
    auto fbo = gl::Fbo::create(fboSize.x, fboSize.y, gl::Fbo::Format().stencilBuffer());
    gl::ScopedFramebuffer fboScp(fbo);

    gl::viewport(fboSize);
    gl::clear(ColorAf::zero());
    gl::clear(GL_STENCIL_BUFFER_BIT);

    vg.beginFrame(mBounds.getSize(), getWindow()->getContentScale());
    vg.translate(-mBounds.getUpperLeft());
    mShape->draw(vg);
    vg.endFrame();

    mTexture = fbo->getColorTexture();
  }
예제 #8
0
파일: Dialer.cpp 프로젝트: eriser/Cinder-UI
vec2 DialerT<T>::getHitPercent( const vec2 &pt )
{
    vec2 hp;
    Rectf r = mHitRect;
    r.offset( getOrigin() );
    r.x1 += mPadding.mLeft;
    r.x2 -= mPadding.mRight;
    r.y1 += mPadding.mTop;
    r.y2 -= mPadding.mBottom;
    hp = ( pt - r.getUpperLeft() ) / r.getSize();
    return hp;
}
예제 #9
0
//----------------------------------------------------------------------------//
BasicImage::BasicImage(const String& name, Texture* texture,
                       const Rectf& pixel_area, const Vector2f& pixel_offset,
                       const AutoScaledMode autoscaled, const Sizef& native_res) :
    d_name(name),
    d_texture(texture),
    d_pixelSize(pixel_area.getSize()),
    d_area(pixel_area),
    d_pixelOffset(pixel_offset),
    d_autoScaled(autoscaled),
    d_nativeResolution(native_res)

{
    // force initialisation of the autoscaling fields.
    notifyDisplaySizeChanged(
        System::getSingleton().getRenderer()->getDisplaySize());
}
예제 #10
0
//----------------------------------------------------------------------------//
void Direct3D10Texture::blitFromMemory(const void* sourceData, const Rectf& area)
{
    if (!d_texture)
        return;

    uint32* buff = new uint32[static_cast<size_t>(area.getWidth()) *
                              static_cast<size_t>(area.getHeight())];
    blitFromSurface(static_cast<const uint32*>(sourceData), buff,
                    area.getSize(), static_cast<size_t>(area.getWidth()) * 4);

    D3D10_BOX dst_box = {static_cast<UINT>(area.left()),
                         static_cast<UINT>(area.top()),
                         0,
                         static_cast<UINT>(area.right()),
                         static_cast<UINT>(area.bottom()),
                         1};

    d_device.UpdateSubresource(d_texture, 0, &dst_box, buff,
                               static_cast<UINT>(area.getWidth()) * 4, 0);

    delete[] buff;
}
예제 #11
0
//----------------------------------------------------------------------------//
void OpenGLESTexture::blitFromMemory(void* sourceData, const Rectf& area)
{
    // store size of original data we are loading
    d_dataSize = area.getSize();
    setTextureSize(d_dataSize);
    // update scale values
    updateCachedScaleValues();

    // save old texture binding
    GLuint old_tex;
    glGetIntegerv(GL_TEXTURE_BINDING_2D, reinterpret_cast<GLint*>(&old_tex));

    // do the real work of getting the data into the texture
    glBindTexture(GL_TEXTURE_2D, d_ogltexture);
    glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,
                    static_cast<GLsizei>(d_dataSize.d_width),
                    static_cast<GLsizei>(d_dataSize.d_height),
                    GL_RGBA, GL_UNSIGNED_BYTE, sourceData);

    // restore previous texture binding.
    glBindTexture(GL_TEXTURE_2D, old_tex);
}
예제 #12
0
    void TextComponent::render_impl(Window& srcWindow, Rectf& destRect,
      const CEGUI::ColourRect* modColours, const Rectf* clipper,
      bool /*clipToDisplay*/) const
    {
    
        updateFormatting(srcWindow, destRect.getSize());

        // Get total formatted height.
        const float textHeight = d_formattedRenderedString->getVerticalExtent(&srcWindow);

        // handle dest area adjustments for vertical formatting.
        const VerticalTextFormatting vertFormatting = d_vertFormatting.get(srcWindow);

        switch(vertFormatting)
        {
        case VTF_CENTRE_ALIGNED:
            destRect.d_min.y += (destRect.getHeight() - textHeight) * 0.5f;
            break;

        case VTF_BOTTOM_ALIGNED:
            destRect.d_min.y = destRect.d_max.y - textHeight;
            break;

        default:
            // default is VTF_TOP_ALIGNED, for which we take no action.
            break;
        }

        // calculate final colours to be used
        ColourRect finalColours;
        initColoursRect(srcWindow, modColours, finalColours);

        // add geometry for text to the target window.
        d_formattedRenderedString->draw(&srcWindow, srcWindow.getGeometryBuffers(),
                                        destRect.getPosition(),
                                        &finalColours, clipper);
    }
예제 #13
0
    std::map<int, TimelineContentInfo> GridLayoutTimeline::getRenderContent(//SceneContentProvider *contentProvider,
                                                                            bool shouldTransition)
    {
        std::map< int, TimelineContentInfo > returnContent;
        
        vector<ScreenRegion> transitionRegions;
        vector<ScreenRegion> compareRegions;
        vector<ScreenRegion> returnRegions;
        
        float curTransitionScale = shouldTransition ? mTransitionAmt : 1.0f;
        
        if (shouldTransition && mTransitionAmt < 1.0 && mIdxPrevLayout != -1)
        {
            // If there's a previous region, they each get 1/2 of the
            // allotted transition time.
            
            float prevTransitionScale = 1.0 - std::min(mTransitionAmt / 0.5f, 1.0f);
            float nextTransitionScale = std::max((mTransitionAmt - 0.5f) / 0.5f, 0.0f);
            
            if (nextTransitionScale > 0.0)
            {
                // Next layout is transitioning.
                transitionRegions = mGridLayouts[mIdxCurrentLayout].getRegions();
                compareRegions = mGridLayouts[mIdxPrevLayout].getRegions();
                
                curTransitionScale = nextTransitionScale;
            }
            else
            {
                // Previous layout is transitioning.
                transitionRegions = mGridLayouts[mIdxPrevLayout].getRegions();
                compareRegions = mGridLayouts[mIdxCurrentLayout].getRegions();
                
                curTransitionScale = prevTransitionScale;
            }
        }
        else
        {
            // Next layout is transitioning. There are no previous regions.
            transitionRegions = mGridLayouts[mIdxCurrentLayout].getRegions();
        }

        int numRegions = transitionRegions.size();
        int numCompareRegions = compareRegions.size();
        for (int i = 0; i < numRegions; ++i)
        {
            ScreenRegion transitionReg = transitionRegions[i];
            Rectf rA = transitionReg.rect;
            float rectScale = curTransitionScale;
            
            for (int j = 0; j < numCompareRegions; ++j)
            {
                ScreenRegion compareReg = compareRegions[j];
                /*
                Rectf rB = compareReg.rect;
                if (compareReg.isActive &&
                    rectCompare(rA, rB))
                {
                */
                if (compareReg.timelineID == transitionReg.timelineID)
                {
                    // No transition. Just draw at full blast.
                    rectScale = 1.0f;
                    break;
                }
            }
            
            //std::pair<ci::Rectf, RenderableContentRef> returnItem;
            TimelineContentInfo returnItem;
            returnItem.layoutIndex = i;
            
            // Now, create the new rect.
            Vec2f rectCenter = rA.getCenter();
            Vec2f rectHalfSize = rA.getSize() * 0.5f * rectScale;
            Rectf transitionRect(rectCenter - rectHalfSize,
                                 rectCenter + rectHalfSize);
            // returnItem.first = transitionRect;
            returnItem.rect = transitionRect;
            
            // Append content.
            SceneContentProviderRef contentProvider = SceneContentProvider::sharedContentProvider();
            if (contentProvider)
            {
                returnItem.contentKey = transitionReg.contentKey;
                returnItem.contentRef = contentProvider->contentForKey(transitionReg.contentKey);
                
                returnContent[transitionReg.timelineID] = returnItem;
            }
            else
            {
                ci::app::console() << "ERROR: No content provider.\n";
            }
        }
        
        return returnContent;
    }