public virtual void drawBundled(AsDrawingBlockCallback drawingBlock, int antiAliasing)
        {
            float       scale   = mActiveTexture.getScale();
            AsContext3D context = AsStarling.getContext();

            if (context == null)
            {
                throw new AsMissingContextError();
            }
            sScissorRect.setTo(0, 0, mActiveTexture.getWidth() * scale, mActiveTexture.getHeight() * scale);
            context.setScissorRectangle(sScissorRect);
            if (getIsPersistent())
            {
                AsTexture tmpTexture = mActiveTexture;
                mActiveTexture = mBufferTexture;
                mBufferTexture = tmpTexture;
                mHelperImage.setTexture(mBufferTexture);
            }
            mSupport.setRenderTarget(mActiveTexture);
            mSupport.clear();
            if (getIsPersistent() && mBufferReady)
            {
                mHelperImage.render(mSupport, 1.0f);
            }
            else
            {
                mBufferReady = true;
            }
            try
            {
                mDrawing = true;
                if (drawingBlock != null)
                {
                    drawingBlock();
                }
            }
            finally
            {
                mDrawing = false;
                mSupport.finishQuadBatch();
                mSupport.nextFrame();
                mSupport.setRenderTarget(null);
                context.setScissorRectangle(null);
            }
        }
Exemple #2
0
        protected virtual void parseAtlasXml(AsXML atlasXml)
        {
            float        scale          = mAtlasTexture.getScale();
            AsSubTexture __subTextures_ = atlasXml.SubTexture;

            if (__subTextures_ != null)
            {
                foreach (AsXML subTexture in __subTextures_)
                {
                    String      name        = subTexture.attribute("name");
                    float       x           = AsGlobal.parseFloat(subTexture.attribute("x")) / scale;
                    float       y           = AsGlobal.parseFloat(subTexture.attribute("y")) / scale;
                    float       width       = AsGlobal.parseFloat(subTexture.attribute("width")) / scale;
                    float       height      = AsGlobal.parseFloat(subTexture.attribute("height")) / scale;
                    float       frameX      = AsGlobal.parseFloat(subTexture.attribute("frameX")) / scale;
                    float       frameY      = AsGlobal.parseFloat(subTexture.attribute("frameY")) / scale;
                    float       frameWidth  = AsGlobal.parseFloat(subTexture.attribute("frameWidth")) / scale;
                    float       frameHeight = AsGlobal.parseFloat(subTexture.attribute("frameHeight")) / scale;
                    AsRectangle region      = new AsRectangle(x, y, width, height);
                    AsRectangle frame       = frameWidth > 0 && frameHeight > 0 ? new AsRectangle(frameX, frameY, frameWidth, frameHeight) : null;
                    addRegion(name, region, frame);
                }
            }
        }
 protected override void activate(int pass, AsContext3D context, AsTexture texture)
 {
     updateParameters(pass, (int)(texture.getWidth() * texture.getScale()), (int)(texture.getHeight() * texture.getScale()));
     context.setProgramConstantsFromVector(AsContext3DProgramType.VERTEX, 4, mOffsets);
     context.setProgramConstantsFromVector(AsContext3DProgramType.FRAGMENT, 0, mWeights);
     if(mUniformColor && pass == getNumPasses() - 1)
     {
         context.setProgramConstantsFromVector(AsContext3DProgramType.FRAGMENT, 1, mColor);
         context.setProgram(mTintedProgram);
     }
     else
     {
         context.setProgram(mNormalProgram);
     }
 }
 public override float getScale()
 {
     return(mParent.getScale());
 }