Пример #1
0
        /// <summary>
        /// Original renderer
        /// </summary>
        /// <param name="gameTime"></param>
        private void StandardRenderer(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            PrepFrame();

            if (this.m_curEffect != null)
            {
                CurPrimitive.Draw(m_curEffect);
            }

            base.Draw(gameTime);
        }
Пример #2
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            if (m_curEffect != null)
            {
                //Set Matrices
                var p1 = m_curEffect.Parameters["xWorld"];
                if (p1 != null)
                {
                    p1.SetValue(m_World);
                }

                var p2 = m_curEffect.Parameters["xView"];
                if (p2 != null)
                {
                    p2.SetValue(m_camera.View);
                }

                var p3 = m_curEffect.Parameters["xProjection"];
                if (p3 != null)
                {
                    p3.SetValue(m_camera.Projection);
                }


                //Set textures
                //for (int i = 0; i < m_texSlots.Length; i++)
                //{
                //    if (m_texSlots[i] != null)
                //    {
                //        var p4 = m_curEffect.Parameters[string.Format("xTexSlot{0}", i)];
                //        if (p4 != null)
                //            p4.SetValue(m_texSlots[i]);
                //    }
                //}

                //UI Parameters
                foreach (var p in Parameters)
                {
                    var px = m_curEffect.Parameters[p.Name];

                    //UIFloatParam
                    if (px != null && px.ParameterType == EffectParameterType.Single && p is UIFloatParam)
                    {
                        var floatParam = p as UIFloatParam;
                        px.SetValue(floatParam.Value);
                    }
                    //UITexture2DParam
                    else if (px != null && px.ParameterType == EffectParameterType.Texture2D && p is UITexture2DParam)
                    {
                        var       texParam = p as UITexture2DParam;
                        Texture2D tex      = null;
                        int       idx      = 0;
                        if (int.TryParse(texParam.Value, out idx))
                        {
                            if (idx >= 0 && idx < m_texSlots.Length && m_texSlots[idx] != null)
                            {
                                tex = m_texSlots[idx];
                            }
                        }
                        px.SetValue(tex);
                    }
                }


                //Set pass0
                m_curEffect.CurrentTechnique.Passes[0].Apply();

                //Draw
                CurPrimitive.Draw(m_curEffect);
            }

            base.Draw(gameTime);
        }