示例#1
0
    ParticleSystemQuad::ParticleSystemQuad(fzUInt number, Texture2D *texture)
    : ParticleSystem(number, texture)
    {
        // allo cating quads
        p_quads = new fzC4_T2_V2_Quad[getTotalParticles()];
        
        // initialize only once the texCoords and the indices
        initTexCoordsWithRect(fzRect(FZPointZero, p_texture->getContentSize()));
        initIndices();
        
#if FZ_GL_SHADERS
        setGLProgram(kFZShader_mat_aC4_TEX);
#endif  
    }
示例#2
0
    void Director::updateViewRect()
    {
        if(!(m_dirtyFlags & kFZDDirty_viewPort))
            return;
        
        if(m_windowSize == FZSizeZero && m_originalCanvasSize == FZSizeZero)
            setFullscreen();
        else if(m_windowSize == FZSizeZero)
            setWindowSize(m_originalCanvasSize);
        
        fzSize windowSize = getWindowSize();
        fzSize canvasSize = (m_originalCanvasSize == FZSizeZero) ? windowSize : m_originalCanvasSize;
        fzOrientation orientation = getOrientation();
        
        if(orientation == kFZOrientation_LandscapeLeft ||
           orientation == kFZOrientation_LandscapeRight)
        {
            FZ_SWAP(canvasSize.width, canvasSize.height);
        }
                
        fzFloat windowRate = windowSize.width/windowSize.height;
        fzFloat canvasRate = canvasSize.width/canvasSize.height;
        fzSize newCanvasSize = canvasSize; // could be the same

        if(windowRate == canvasRate) {
            
            // No resizing because the canvas and window rate is the same.
            m_renderingRect = fzRect(FZPointZero, windowSize);
        
        }else{
            
            // The window and the canvas rate is different, so we have to apply
            // the proper resizing algorythm
            switch (m_resizeMode) {
                    
                case kFZResizeMode_None:
                {
                    m_renderingRect.size = canvasSize;
                    m_renderingRect.origin = (windowSize - canvasSize)/2;
                    
                    break;
                }
                case kFZResizeMode_Expand:
                {
                    m_renderingRect = fzRect(FZPointZero, windowSize);
                    
                    break;
                }
                case kFZResizeMode_Fit:
                {
                    if(canvasRate > windowRate)
                    {
                        m_renderingRect.size.width = windowSize.width;
                        m_renderingRect.size.height = canvasSize.height * windowSize.width/canvasSize.width;
                        m_renderingRect.origin = fzPoint(0, (windowSize.height-m_renderingRect.size.height)/2);
                    }else{
                        m_renderingRect.size.height = windowSize.height;
                        m_renderingRect.size.width = canvasSize.width * windowSize.height/canvasSize.height;
                        m_renderingRect.origin = fzPoint((windowSize.width-m_renderingRect.size.width)/2, 0);
                    }
                    break;
                }
                case kFZResizeMode_FitFill:
                {
                    if(canvasRate > windowRate)
                        newCanvasSize.height = canvasSize.width / windowRate;
                    else
                        newCanvasSize.width = canvasSize.height * windowRate;
                                        
                    m_renderingRect = fzRect(FZPointZero, windowSize);
                    break;
                }
                case kFZResizeMode_IntFit:
                {                    
                    fzFloat factorX = windowSize.width / canvasSize.width;
                    fzFloat factorY = windowSize.height / canvasSize.height;
                    fzFloat factor = MIN(factorX, factorY);
                    factor = (factor >= 1.0f) ? static_cast<fzInt>(factor) : factor;
                    
                    m_renderingRect.size = canvasSize * factor;
                    m_renderingRect.origin = (windowSize - m_renderingRect.size)/2;
                    
                    break;
                }
                case kFZResizeMode_IntFitFill:
                {
                    fzFloat factorX = windowSize.width / canvasSize.width;
                    fzFloat factorY = windowSize.height / canvasSize.height;
                    fzFloat factor = MIN(factorX, factorY);
                    factor = (factor >= 1.0f) ? static_cast<fzInt>(factor) : factor;

                    newCanvasSize = windowSize / factor;
                    
                    m_renderingRect = fzRect(FZPointZero, windowSize);
                    
                    break;
                }
                    
                default:
                    break;
            }
        }
        m_canvasSize = newCanvasSize;

        if(orientation == kFZOrientation_LandscapeLeft ||
           orientation == kFZOrientation_LandscapeRight)
        {
            FZ_SWAP(m_canvasSize.width, m_canvasSize.height);
        }
        
        // FACTORS
        fzSize viewPort = getViewPort();
        fzFloat factorX = viewPort.width / newCanvasSize.width;
        fzFloat factorY = viewPort.height / newCanvasSize.height;
        
        
        // COMPUTE FINAL FACTOR
        fzFloat newFactor = roundf(MAX(MAX(factorX, factorY), 1));
        if(newFactor > DeviceConfig::Instance().getMaxFactor())
            newFactor = DeviceConfig::Instance().getMaxFactor();
        
        if(newFactor > m_resourcesFactor)
        {
            TextureCache::Instance().removeAllTextures();
            FontCache::Instance().removeAllFonts();
        }
        m_resourcesFactor = newFactor;
        
        m_dirtyFlags &= ~kFZDDirty_viewPort;
        m_dirtyFlags |= kFZDDirty_projection;
        
        
        // Notify changes to the OS Wrapper
        OSW::setOrientation(orientation);
        OSW::updateWindow();
    }
示例#3
0
 void ParticleSystemQuad::setTexture(Texture2D *t)
 {
     setTexture(t, fzRect(FZPointZero, p_texture->getContentSize()));
 }
示例#4
0
 Sprite::Sprite(Texture2D* texture)
 : Sprite(texture, ((texture) ? fzRect(FZPointZero, texture->getContentSize()) : FZRectZero))
 { }