示例#1
0
        public void updateQuadInRenderList(QuickGUIQuad q)
        {
            // minor optimization, where only the quad's dimensions have changed.
            if (!q.zOrderChanged() && !q.textureChanged())
            {
                foreach (QuickGUIQuad iq in mRenderList)
                {
                    if (iq.getID() == q.getID())
                    {
                        // update all vertices
                        for (int vertIndex = 0; vertIndex < QuickGUIQuad.VERTEX_PER_QUAD; ++vertIndex)
                        {
                            iq.setVertex(vertIndex, q.getVertex(vertIndex));
                        }
                        q._notifyChangesHandled();
                        break;
                    }
                }
            }
            // otherwise its easier/more efficient to remove the quad and re-add it into the list.
            else
            {
                removeQuadFromRenderList(q);
                addQuadToRenderList(q);
            }

            mRenderListDirty = true;
        }
示例#2
0
        /** Returns a pointer to the Listener singleton object */
        //static Renderer* getSingletonPtr();

        public void removeQuadFromRenderList(QuickGUIQuad q)
        {
            QuickGUIQuad qr = null;

            foreach (QuickGUIQuad iq in mRenderList)
            {
                // quad is already in the list! update quad instead
                if (iq.getID() == q.getID())
                {
                    qr = iq;
                    mRenderListDirty = true;
                    break;
                }
            }
            if (qr != null)
            {
                mRenderList.Remove(qr);
            }
        }
示例#3
0
        /*
         * Quads are kept sorted by zOrder, and within zOrder, by Texture.  In this way, we will
         * minimized batches.
         */
        public void addQuadToRenderList(QuickGUIQuad q)
        {
            bool added = false;

            for (int it = 0; it < mRenderList.Count; it++)
            {
                QuickGUIQuad iq = mRenderList[it];
                // quad is already in the list! update quad instead
                if (iq.getID() == q.getID())
                {
                    updateQuadInRenderList(q);
                    added = true;
                    break;
                }

                // zOrders are the same, now we want to group by texture
                if (iq.getZOrder() == q.getZOrder())
                {
                    // iterate until texture name found, or end of zOrder grouping
                    while (!iq.getTextureName().Equals(iq.getTextureName()) && (iq.getZOrder() == q.getZOrder()) && (it < mRenderList.Count))
                    {
                        ++it;
                    }

                    // it is pointing to the end of the list, a quad with the same texture name, or a quad of another zOrder
                    mRenderList.Insert(it, q);
                    q._notifyChangesHandled();
                    added = true;
                }
            }

            if (!added)
            {
                mRenderList.Remove(q);
            }

            mRenderListDirty = true;
        }
示例#4
0
        private void _renderVertexBuffer()
        {
            if (mRenderList.Count == 0 || (mVertexBufferUsage == 0))
            {
                return;
            }

            uint bufferPosition = 0;

            /*
             * Since mRenderList is sorted by zOrder and by Texture, we can send quads with similar textures into one renderOperation.
             * Everything rendered in one _render call will receive the texture set previously by _setTexture.
             */
            for (int it = 0; it < mRenderList.Count; it++)
            {
                QuickGUIQuad iq             = mRenderList[it];
                string       currentTexture = iq.getTextureName();
                mRenderOperation.vertexData.vertexStart = bufferPosition;
                // Iterate over quads with the same texture.
                while ((it < mRenderList.Count) && (iq.getTextureName() == currentTexture))
                {
                    bufferPosition += QuickGUIQuad.VERTEX_PER_QUAD;
                    ++it;
                }
                // render quads
                mRenderOperation.vertexData.vertexCount = bufferPosition - mRenderOperation.vertexData.vertexStart;
                mRenderSystem._setTexture(0, true, currentTexture);
                initRenderState();
                mRenderSystem._render(mRenderOperation);

                // with the while loop it is possible to iterate to the end of the list.
                // At this point the for loop will increment it again, causing a crash.
                if (it == mRenderList.Count)
                {
                    break;
                }
            }
        }