當前位置: 首頁>>代碼示例>>C#>>正文


C# Effect.End方法代碼示例

本文整理匯總了C#中Microsoft.Xna.Framework.Graphics.Effect.End方法的典型用法代碼示例。如果您正苦於以下問題:C# Effect.End方法的具體用法?C# Effect.End怎麽用?C# Effect.End使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Microsoft.Xna.Framework.Graphics.Effect的用法示例。


在下文中一共展示了Effect.End方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Draw

 /// <summary>
 /// Draws the quad using the specified effect. Sets no parameters on the effect, nor any render states on
 /// the graphics device. Those must be set appropriately before calling Draw.
 /// This is a convenience function, calling Begin, End, and DrawGeometry for you.
 /// </summary>
 /// <param name="effect">The effect to draw with.</param>
 public void Draw(Effect effect)
 {
     effect.Begin();
     foreach (EffectPass pass in effect.CurrentTechnique.Passes)
     {
         pass.Begin();
         DrawGeometry();
         pass.End();
     }
     effect.End();
 }
開發者ID:idaohang,項目名稱:Helicopter-Autopilot-Simulator,代碼行數:17,代碼來源:Quad.cs

示例2: RenderScreenQuad

        public void RenderScreenQuad(Effect effect, EffectTechnique technique, Texture2D texture)
        {
            effect.CurrentTechnique = technique;

            sb.Begin(SpriteBlendMode.None, SpriteSortMode.Immediate, SaveStateMode.None);
            effect.Begin();
            technique.Passes[0].Begin();
            sb.Draw(texture, screen, Color.White);
            technique.Passes[0].End();
            effect.End();
            sb.End();
        }
開發者ID:idaohang,項目名稱:Helicopter-Autopilot-Simulator,代碼行數:12,代碼來源:PostProcessManager.cs

示例3: Draw

        public void Draw(Effect effect)
        {
            var device = GraphicsDeviceHolder.Device;
             device.VertexDeclaration = vertexDeclaration;
             device.Vertices[0].SetSource(vertexBuffer, 0, 3 * sizeof(float));

             effect.Parameters["xWorld"].SetValue(Matrix.Identity);
             effect.Begin();
             foreach (var pass in effect.CurrentTechnique.Passes)
             {
            pass.Begin();
            device.DrawPrimitives(PrimitiveType.LineList, 0, 2);
            pass.End();
             }
             effect.End();
        }
開發者ID:dennisyolkin,項目名稱:gta_gameworld_renderer,代碼行數:16,代碼來源:Line2D.cs

示例4: Draw

        public void Draw(GameTime gameTime, GraphicsDevice device, Effect effect, Matrix worldViewProjectionMatrix, int resolutionWidth, int resolutionHeight)
        {
            effect.Parameters["xWorldViewProjection"].SetValue(worldViewProjectionMatrix);
            effect.Parameters["xWidth"].SetValue(resolutionWidth);
            effect.Parameters["xHeight"].SetValue(resolutionHeight);

            effect.Begin();
            foreach (SModelMesh mesh in _meshes)
            {
                effect.Parameters["xTexture"].SetValue(mesh.texture);
                foreach (EffectPass pass in effect.CurrentTechnique.Passes)
                {
                    pass.Begin();
                    device.VertexDeclaration = _vertexDeclaration;
                    device.Vertices[0].SetSource(mesh.vertexBuffer, 0, _vertexSizeInBytes);
                    device.DrawPrimitives(PrimitiveType.TriangleList, 0, mesh.numPrimitives);
                    pass.End();
                }
            }
            effect.End();
        }
開發者ID:obyrnemj,項目名稱:computational-geometry-3d-vision,代碼行數:21,代碼來源:CMD2Model.cs

示例5: DrawSpawns

        void DrawSpawns(Effect effectToUse, String technique)
        {
            GraphicsDevice device = parentGame.device;

            foreach (EventFlag flag in parentGame.myLevel.FlagsList)
            {
                if (flag == activeFlag)
                {
                    foreach (GameEvent g_event in flag.Events)
                    {

                        VertexPositionColor[] pointList = new VertexPositionColor[2];

                        #region Get Corners

                        Vector3 corner = g_event.SpawnPoint.Position;
                        Vector2 center = FindCenter2D(flag.Corners);

                        Vector3 Center = new Vector3(center.X, 0, center.Y);
                        Vector3 norm;

                        if(parentGame.terrainEngine.IsOnHeightmap(Center))
                            parentGame.terrainEngine.GetHeight(Center, out Center.Y, out norm);

                        pointList[0] = new VertexPositionColor(corner, Color.Red);
                        pointList[1] = new VertexPositionColor(Center, Color.Red);

                        float scale = 0.05f;

                        if (activeEvent == g_event)
                            scale *= 1.5f;

                        parentGame.currentColor = Color.GreenYellow;

                            parentGame.DrawModel(effectToUse, parentGame.cornerModel, parentGame.tankTextures,

                            Matrix.CreateScale(scale)
                            *
                            Matrix.Identity
                            *
                            Matrix.CreateTranslation(corner),

                            technique, true);

                            parentGame.currentColor = Color.Brown;

                        #endregion

                        #region draw lines
                        short[] lineStripIndices = new short[2] { 0, 1 };

                        device.RenderState.FillMode = FillMode.WireFrame;
                        device.RenderState.CullMode = CullMode.None;

                        effectToUse.Begin();
                        foreach (EffectPass pass in effectToUse.CurrentTechnique.Passes)
                        {
                            pass.Begin();

                            device.VertexDeclaration = new
                                VertexDeclaration(device,
                                VertexPositionColor.VertexElements);

                            device.DrawUserIndexedPrimitives<VertexPositionColor>(
                                PrimitiveType.LineStrip,
                                pointList,
                                0,   // vertex buffer offset to add to each element of the index buffer
                                2,   // number of vertices to draw
                                lineStripIndices,
                                0,   // first index element to read
                                1    // number of primitives to draw
                            );

                            pass.End();

                        }
                        effectToUse.End();
                        //device.RenderState.FillMode = FillMode.Solid;
                        device.RenderState.FillMode = FillMode.Solid;
                        device.RenderState.CullMode = CullMode.CullClockwiseFace;

                        #endregion

                    }

                }
            }
        }
開發者ID:alittle1234,項目名稱:XNA_Project,代碼行數:88,代碼來源:LevelEditor.cs

示例6: renderPart

 //method shadow effect render part
 private void renderPart(GraphicsDevice device, List<SRenderInfoMesh> v_list, Matrix world, Effect shadow_effect)
 {
     shadow_effect.Begin();
     shadow_effect.Parameters["xWorld"].SetValue(world);
     for (int i = 0; i < v_list.Count; ++i)
     {
         VertexPositionNormalTexture[] vertices = v_list[i].vertex_info;
         //model_effect.Texture = getTexture(v_list[i].texture_name);
         foreach (EffectPass pass in shadow_effect.CurrentTechnique.Passes)
         {
             pass.Begin();
             int count_primitives = vertices.Length / 3;
             device.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, vertices, 0, count_primitives);
             pass.End();
         }
     }
     shadow_effect.End();
 }
開發者ID:obyrnemj,項目名稱:computational-geometry-3d-vision,代碼行數:19,代碼來源:CPK3Model.cs

示例7: DrawFlags

        void DrawFlags(Effect effectToUse, String technique)
        {
            GraphicsDevice device = parentGame.device;

            //effectToUse = new BasicEffect(device, new EffectPool());

            foreach (EventFlag flag in parentGame.myLevel.FlagsList)
            {
                currentColor.G -= 1;

                VertexPositionColor[] pointList = new VertexPositionColor[5];
                int x = 0;

                #region Get Corners

                foreach (Vector2 Crnr in flag.Corners)
                {
                    Vector3 corner = new Vector3(Crnr.X, 0, Crnr.Y);
                    Vector3 norm;

                    parentGame.terrainEngine.GetHeight(corner, out corner.Y, out norm);
                    corner.Y += 2;

                    pointList[x] = new VertexPositionColor(corner, Color.Red);
                    if (x == 0)
                    {
                        pointList[4] = new VertexPositionColor(corner, Color.Red);
                        currentColor = Color.Red;
                    }
                    else
                        currentColor = Color.Chartreuse;

                    float scale = 0.05f;
                    if (activeFlag == flag
                        && activeCorner == Crnr)
                        scale *= 1.5f;

                    parentGame.currentColor = Color.Brown;

                    parentGame.DrawModel(effectToUse, parentGame.cornerModel, parentGame.tankTextures,

                    Matrix.CreateScale(scale)
                    *
                    Matrix.Identity
                    *
                    Matrix.CreateTranslation(corner),

                    technique, true);

                    x++;
                }

                #endregion

                short[] lineStripIndices = new short[5] { 0, 1, 2, 3, 4 };

                device.RenderState.FillMode = FillMode.WireFrame;
                device.RenderState.CullMode = CullMode.None;

                effectToUse.Begin();
                foreach (EffectPass pass in effectToUse.CurrentTechnique.Passes)
                {
                    pass.Begin();

                    device.VertexDeclaration = new
                        VertexDeclaration(device,
                        VertexPositionColor.VertexElements);

                    device.DrawUserIndexedPrimitives<VertexPositionColor>(
                        PrimitiveType.LineStrip,
                        pointList,
                        0,   // vertex buffer offset to add to each element of the index buffer
                        5,   // number of vertices to draw
                        lineStripIndices,
                        0,   // first index element to read
                        4    // number of primitives to draw
                    );

                    pass.End();

                }
                effectToUse.End();
                //device.RenderState.FillMode = FillMode.Solid;
                device.RenderState.FillMode = FillMode.Solid;
                device.RenderState.CullMode = CullMode.CullClockwiseFace;
            }
        }
開發者ID:alittle1234,項目名稱:XNA_Project,代碼行數:87,代碼來源:LevelEditor.cs

示例8: Draw

        /// <summary>
        /// Отрисовывает объект
        /// </summary>
        /// <param name="effect">Эффект, который должен испльзоваться для отрисовки. Предполагается, что как минимум матрицы xProjection и xView уже заданы!</param>
        public void Draw(Effect effect, Matrix worldMatrix, bool useMaterial)
        {
            GraphicsDevice device = vertexDeclaration.GraphicsDevice;
             device.RenderState.CullMode = CullMode.None;

             effect.Parameters["xWorld"].SetValue(worldMatrix);

             device.VertexDeclaration = vertexDeclaration;
             device.Vertices[0].SetSource(vertexBuffer, 0, vertexSize);
             device.Indices = indexBuffer;

             foreach (ModelMeshPart3D part in meshParts)
             {
            if (useMaterial)
            {
               Material mat = materials[part.MaterialId];
               if (mat.Texture != null)
               {
                  effect.CurrentTechnique = effect.Techniques["Textured"];
                  effect.Parameters["xTexture"].SetValue(mat.Texture);
               }
               else
               {
                  effect.CurrentTechnique = effect.Techniques["SolidColored"];
                  effect.Parameters["xSolidColor"].SetValue(mat.Color.ToVector4());
               }
            }

            effect.Begin();
            foreach (var pass in effect.CurrentTechnique.Passes)
            {
               pass.Begin();

               device.DrawIndexedPrimitives(triangleStrip ? PrimitiveType.TriangleStrip : PrimitiveType.TriangleList, 0, 0,
                  verticesCount, part.StartIdx, part.PrimitivesCount);

               pass.End();
            }
            effect.End();
             }
        }
開發者ID:dennisyolkin,項目名稱:gta_gameworld_renderer,代碼行數:45,代碼來源:Model3D.cs

示例9: DrawQuad

        private void DrawQuad(Texture2D source, RenderTarget2D target, int x, int y, int width, int height, SpriteBlendMode spriteBlendMode, Effect effect, Color color)
        {
            graphics.GraphicsDevice.SetRenderTarget(0, target);

            if (effect != null)
                graphics.GraphicsDevice.Textures[0] = source;

            // Draw a fullscreen sprite to apply the postprocessing effect.
            spriteBatch.Begin(spriteBlendMode,
                              SpriteSortMode.Immediate,
                              SaveStateMode.SaveState);

            if (effect != null)
            {
                effect.Begin();
                effect.CurrentTechnique.Passes[0].Begin();
            }

            spriteBatch.Draw(source, new Rectangle(x, y, width, height), color);

            spriteBatch.End();

            if (effect != null)
            {
                effect.CurrentTechnique.Passes[0].End();
                effect.End();
            }

            graphics.GraphicsDevice.SetRenderTarget(0, null);
        }
開發者ID:wintermute-motherbrain,項目名稱:kaorudono,代碼行數:30,代碼來源:GeneratedGeometry.cs

示例10: drawMe

        public void drawMe(GraphicsDevice device, Effect effect)
        {
            if (mDecl == null)
            {
                mDecl = new VertexDeclaration(device, VertexPositionColor.VertexElements);
            }

            // update vert buffer.
            for (int i = 0; i < mPointMasses.Count; i++)
            {
                mVerts[i].Position = JelloPhysics.VectorTools.vec3FromVec2(mPointMasses[i].Position);

                float dist = (mPointMasses[i].Position - mGlobalShape[i]).Length() * 2.0f;
                if (dist > 1f) { dist = 1f; }

                mVerts[i].Color = mColor;
            }

            device.VertexDeclaration = mDecl;

            // draw me!
            effect.Begin();
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                device.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.TriangleList, mVerts, 0, mVerts.Length, mIndices, 0, mIndices.Length / 3);
                pass.End();
            }
            effect.End();
        }
開發者ID:kevinloken,項目名稱:FluidExperiments,代碼行數:30,代碼來源:DraggablePressureBody.cs

示例11: ApplyFullScreenEffect

 public void ApplyFullScreenEffect(Effect effect, Texture2D tex)
 {
     Viewport viewport = _graphicDevice.Viewport;
     effect.Begin();
     foreach (EffectPass pass in effect.CurrentTechnique.Passes)
     {
         _spriteBatch.Begin(SpriteBlendMode.None, SpriteSortMode.Immediate, SaveStateMode.None);
         pass.Begin();
         Rectangle destinationRectangle = new Rectangle(0, 0, viewport.Width, viewport.Height);
         _spriteBatch.Draw(tex, destinationRectangle, Color.White);
         _spriteBatch.End();
         pass.End();
     }
     effect.End();
 }
開發者ID:hubris,項目名稱:shaghal,代碼行數:15,代碼來源:VolumeRaycaster.cs

示例12: Generate


//.........這裏部分代碼省略.........
uniform float4 _vs_c[11] : register(vs, c0);
{4}
technique Shader
{0}
	pass
	{0}
		VertexShader = 
			asm 
			{0}
				{2}
			{1};
		PixelShader  = 
			asm 
			{0}
				{3}
			{1};
	{1}
{1}",
				"{", "}", vsAsm, psAsm, constantSetup);

			}
			else
			{
				string vsSource = vsConvert.GetSource();
				string psSource = psConvert.GetSource();

				//setup the technique.
				techniqueCode = string.Format(
	@"
{2}

{3}

technique Shader
{0}
	pass
	{0}
		VertexShader = compile {4} vsMain();
		PixelShader  = compile {5} psMain();
	{1}
{1}",
				"{", "}", vsSource, psSource, vsConvert.GetProfile().ToString().ToLower(), psConvert.GetProfile().ToString().ToLower());

			}
			
			TargetPlatform target = TargetPlatform.Unknown;
			switch (platform)
			{
				case Platform.Both:
					throw new ArgumentException();
				case Platform.Windows:
					target = TargetPlatform.Windows;
					break;
				case Platform.Xbox:
					target = TargetPlatform.Xbox360;
					break;
			}

			CompiledEffect effectSource = Effect.CompileEffectFromSource(techniqueCode, null, null, CompilerOptions.None, target);

			if (effectSource.Success == false)
				Common.ThrowError(effectSource.ErrorsAndWarnings, techniqueCode);

			byte[] code = effectSource.GetEffectCode();

			Effect effect = new Effect(Graphics.GraphicsDevice, code, CompilerOptions.None, new EffectPool());

			Vector4[] valuesV = new Vector4[11];
			for (int i = 0; i < valuesV.Length; i++)
			{
				valuesV[i] = new Vector4(i,0,0,0);
			}
			//Vector4[] valuesP = new Vector4[24];
			//for (int i = 0; i < valuesP.Length; i++)
			//{
			//    valuesP[i] = new Vector4(0, i, 0, 0);
			//}
			effect.Parameters[0].SetValue(valuesV);
			Vector4[] test = effect.Parameters[0].GetValueVector4Array(11);
			//effect.Parameters[1].SetValue(valuesP);
			//effect.Parameters[2].SetValue(new bool[] { false, false });

			GraphicsDevice gd = Graphics.GraphicsDevice;

			effect.CurrentTechnique = effect.Techniques[0];
			effect.Begin();
			effect.Techniques[0].Passes[0].Begin();


			Vector4[] outputV = gd.GetVertexShaderVector4ArrayConstant(0, 255);
			Vector4[] outputP = gd.GetPixelShaderVector4ArrayConstant(0, 24);
			//bool[] outputPB = gd.GetPixelShaderBooleanConstant(0, 2);

			effect.Techniques[0].Passes[0].End();
			effect.End();

			string asm = effect.Disassemble(false);

			return code;
        }
開發者ID:shadarath,項目名稱:Wirtualna-rzeczywistosc,代碼行數:101,代碼來源:AsmToTechniqueConverter.cs

示例13: Draw

        public void Draw(Effect effect,
                         string colorMapParamName,
                         string normalMapParamName,
                         string heightMapParamName,
                         Texture2D wallColorMap,
                         Texture2D wallNormalMap,
                         Texture2D wallHeightMap,
                         Texture2D floorColorMap,
                         Texture2D floorNormalMap,
                         Texture2D floorHeightMap,
                         Texture2D ceilingColorMap,
                         Texture2D ceilingNormalMap,
                         Texture2D ceilingHeightMap,
                         bool drawingCeiling)
        {
            graphicsDevice.VertexDeclaration = vertexDeclaration;
            graphicsDevice.Vertices[0].SetSource(vertexBuffer, 0, NormalMappedVertex.SizeInBytes);

            // Draw the scene geometry.

            effect.Begin();

            // Draw the walls.

            effect.Parameters[colorMapParamName].SetValue(wallColorMap);
            effect.Parameters[normalMapParamName].SetValue(wallNormalMap);
            effect.Parameters[heightMapParamName].SetValue(wallHeightMap);
            effect.CommitChanges();

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, wallsIndex, 8);
                pass.End();
            }

            if (drawingCeiling)
            {
                // Draw the ceiling.

                effect.Parameters[colorMapParamName].SetValue(ceilingColorMap);
                effect.Parameters[normalMapParamName].SetValue(ceilingNormalMap);
                effect.Parameters[heightMapParamName].SetValue(ceilingHeightMap);
                effect.CommitChanges();

                foreach (EffectPass pass in effect.CurrentTechnique.Passes)
                {
                    pass.Begin();
                    graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, ceilingIndex, 2);
                    pass.End();
                }
            }

            // Draw the floor.

            effect.Parameters[colorMapParamName].SetValue(floorColorMap);
            effect.Parameters[normalMapParamName].SetValue(floorNormalMap);
            effect.Parameters[heightMapParamName].SetValue(floorHeightMap);
            effect.CommitChanges();

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, floorIndex, 2);
                pass.End();
            }

            effect.End();
        }
開發者ID:narfman0,項目名稱:SunshineSlashers,代碼行數:69,代碼來源:NormalMappingUtils.cs

示例14: Draw

 public void Draw(GraphicsDevice graphics, Effect effect, Effect terrainEffect)
 {
     this.frustrum = new BoundingFrustum(terrainEffect.Parameters["WorldViewProjection"].GetValueMatrix());
     graphics.VertexDeclaration = this.terrainVertexDeclaration;
     graphics.RenderState.CullMode = CullMode.CullCounterClockwiseFace;
     graphics.RenderState.AlphaBlendEnable = true;
     graphics.Indices = this.indices;
     terrainEffect.CurrentTechnique = effect.Techniques["Default"];
     terrainEffect.Begin();
     for (int i = 0; i < this.mapBlocks.GetLength(0); i++)
     {
         for (int j = 0; j < this.mapBlocks.GetLength(1); j++)
         {
             if (this.mapBlocks[i, j].IsView(this.frustrum))
             {
                 this.mapBlocks[i, j].Draw(terrainEffect);
                 this.isView[i, j] = true;
             }
             else
             {
                 this.isView[i, j] = false;
             }
         }
     }
     terrainEffect.End();
     graphics.RenderState.AlphaBlendEnable = false;
     graphics.RenderState.CullMode = CullMode.CullClockwiseFace;
     graphics.VertexDeclaration = this.decorationVertexDeclaration;
     effect.CurrentTechnique = effect.Techniques["Default"];
     effect.Begin();
     for (int i = 0; i < this.decorationBlocks.GetLength(0); i++)
     {
         for (int j = 0; j < this.decorationBlocks.GetLength(1); j++)
         {
             if (this.isView[i, j])
             {
                 this.decorationBlocks[i, j].Draw(effect);
             }
         }
     }
     effect.End();
 }
開發者ID:Jiwan,項目名稱:ROSE-Camera-Editor,代碼行數:42,代碼來源:Terrain.cs

示例15: Draw

        /// <summary>
        /// Draws the tree mesh using a given effect.
        /// You should set the proper parameters on the effect first, such as World, View, and Projection matrices.
        /// </summary>
        /// <param name="effect">Effect to draw with.</param>
        public void Draw(Effect effect)
        {
            device.VertexDeclaration = vdeclaration;
            device.Vertices[0].SetSource(vbuffer, 0, TreeVertex.SizeInBytes);
            device.Indices = ibuffer;

            effect.Begin();
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, numvertices, 0, numtriangles);
                pass.End();
            }
            effect.End();
        }
開發者ID:wintermute-motherbrain,項目名稱:kaorudono,代碼行數:20,代碼來源:TreeMesh.cs


注:本文中的Microsoft.Xna.Framework.Graphics.Effect.End方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。