• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# GraphicsContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中GraphicsContext的典型用法代码示例。如果您正苦于以下问题:C# GraphicsContext类的具体用法?C# GraphicsContext怎么用?C# GraphicsContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GraphicsContext类属于命名空间,在下文中一共展示了GraphicsContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Filter

        public void Filter( GraphicsContext graphics )
        {
            // Y軸方向へのガウス
            // uniform
            int idReciprocalTexHeight = shaderGaussianY.FindUniform( "ReciprocalTexHeight" );
            if( idReciprocalTexHeight >= 0 ){
            shaderGaussianY.SetUniformValue( idReciprocalTexHeight, 1.0f / texScene.Height );
            }
            int idWeight = shaderGaussianY.FindUniform( "Weight" );
            if( idWeight >= 0 ){
            shaderGaussianY.SetUniformValue( idWeight, 0, gaussianWeightTable );
            }
            int idOffset = shaderGaussianY.FindUniform( "Offset" );
            if( idOffset >= 0 ){
            Vector2 offset = new Vector2( 0.0f, 16.0f / texScene.Height );
            shaderGaussianY.SetUniformValue( idOffset, ref offset );
            }

            // render
            FrameBuffer oldBuffer = graphics.GetFrameBuffer();

            if( this.Target != null ){
            graphics.SetFrameBuffer( this.Target );
            }

            texRenderer.BindGraphicsContext( graphics );
            texRenderer.Begin( shaderGaussianY );
            texRenderer.Render( texScene );
            texRenderer.End();

            if( this.Target != null ){
            graphics.SetFrameBuffer( oldBuffer );
            }
        }
开发者ID:hatano0x06,项目名称:Coroppoxus,代码行数:34,代码来源:GaussianYFilter.cs


示例2: Sprite

        public Sprite(GraphicsContext graphics, Texture2D texture)
        {
            if(shaderProgram == null)
            {
                shaderProgram = new ShaderProgram("/Application/shaders/Sprite.cgx");
                shaderProgram.SetUniformBinding(0, "u_WorldMatrix");
            }

            if (texture == null)
            {
                throw new Exception("ERROR: texture is null.");
            }

            this.graphics = graphics;
            this.texture = texture;
            this.width = texture.Width;
            this.height = texture.Height;

            indices = new ushort[indexSize];
            indices[0] = 0;
            indices[1] = 1;
            indices[2] = 2;
            indices[3] = 3;

            vertexBuffer = new VertexBuffer(4, indexSize, VertexFormat.Float3,
                                            VertexFormat.Float2, VertexFormat.Float4);
        }
开发者ID:andierocca,项目名称:destructive-santa,代码行数:27,代码来源:Sprite.cs


示例3: Main

        static void Main(string[] args)
        {
            graphics = new GraphicsContext(960,544,PixelFormat.Rgba,PixelFormat.Depth16,MultiSampleMode.None);
            UISystem.Initialize(graphics);

            MainScene scene = new MainScene();
            SetupListNum(scene.RootWidget);
            scene.SetWidgetLayout(LayoutOrientation.Horizontal);
            UISystem.SetScene(scene);
            for (; ; )
            {
                SystemEvents.CheckEvents();

                // update
                {
                    List<TouchData> touchDataList = Touch.GetData(0);
                    var gamePad = GamePad.GetData (0);
                    UISystem.Update(touchDataList, ref gamePad);
                }

                // draw
                {
                    graphics.SetViewport(0, 0, graphics.Screen.Width, graphics.Screen.Height);
                    graphics.SetClearColor(
                        0xFF,
                        0xFF,
                        0xFF,
                        0xff);
                    graphics.Clear();

                    UISystem.Render();
                    graphics.SwapBuffers();
                }
            }
        }
开发者ID:nakamura001,项目名称:PlayStationMobile-UISampleCode,代码行数:35,代码来源:__DummyProgram.cs


示例4: Saucer

 public Saucer(GraphicsContext g, Texture2D t, Vector3 p, Player pl)
     : base(g,t,p, pl)
 {
     player = pl;
     vel= (new Vector3(.5f*(float)gen.Next(3,5),.7f*(float)gen.Next(3,5),0));
     graphics=g;
 }
开发者ID:andierocca,项目名称:destructive-santa,代码行数:7,代码来源:Saucer.cs


示例5: RayTracerWindow

        public RayTracerWindow(int width, int height)
        {
            _nativeWindow = new NativeWindow(width, height, "", GameWindowFlags.Default, GraphicsMode.Default, DisplayDevice.Default);
            GraphicsContextFlags flags = GraphicsContextFlags.Default;
            #if DEBUG
            //flags |= GraphicsContextFlags.Debug;
            #endif
            _graphicsContext = new GraphicsContext(GraphicsMode.Default, _nativeWindow.WindowInfo, 3, 0, flags);
            _graphicsContext.MakeCurrent(_nativeWindow.WindowInfo);
            ((IGraphicsContextInternal)_graphicsContext).LoadAll(); // wtf is this?

            SetInitialStates();
            SetViewport();

            _nativeWindow.Resize += OnGameWindowResized;
            _nativeWindow.Closing += OnWindowClosing;
            _nativeWindow.KeyDown += OnKeyDown;

            _scene = Scene.TwoPlanes;
            _scene.Camera.ReflectionDepth = DefaultReflectionDepth;

            SetTitle();

            _renderTexture = new RenderTexture(_nativeWindow.Width, _nativeWindow.Height);

            _scenes = typeof(Scene).GetProperties()
                .Where(pi => pi.PropertyType == typeof(Scene))
                .Select(pi => pi.GetValue(null))
                .Cast<Scene>().ToList();
        }
开发者ID:mellinoe,项目名称:RayTracer,代码行数:30,代码来源:RayTracerWindow.cs


示例6: PaintVerticalBar

 protected override void PaintVerticalBar(GraphicsContext context, SizeF size, SizeF knobSize)
 {
     var rect = new RectangleF (new PointF (), new SizeF (knobSize.Width, size.Height - knobSize.Height));
     var brush = new LinearGradientBrush (rect, Color.Black, Color.Black,
         LinearGradientMode.Vertical);
     DrawBar (context, brush, rect);
 }
开发者ID:johtela,项目名称:Compose3D,代码行数:7,代码来源:ColorSlider.cs


示例7: GraphicsContextEventArgs

        public GraphicsContextEventArgs(GraphicsContext context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            this.Graphics = context;
        }
开发者ID:HaKDMoDz,项目名称:Samurai,代码行数:7,代码来源:GraphicsContextEventArgs.cs


示例8: InitGL

 private void InitGL()
 {
     windowInfo = Utilities.CreateWindowsWindowInfo(window.Handle);
     context = new GraphicsContext(GraphicsMode.Default, windowInfo);
     context.MakeCurrent(windowInfo);
     context.LoadAll();
 }
开发者ID:lilinghui,项目名称:DeltaEngine,代码行数:7,代码来源:OpenTKDevice.cs


示例9: Claw

 public Claw(GraphicsContext g, Texture2D t, Vector3 p)
     : base(g,t,p)
 {
     graphics = g;
     sprite.Position = p;
     vel= (new Vector3(0, -1, 0));
 }
开发者ID:andierocca,项目名称:destructive-santa,代码行数:7,代码来源:Claw.cs


示例10: DebugString

        public DebugString(GraphicsContext graphics, Texture2D texture, int charaWidth, int charaHeight)
        {
            if(shaderProgram == null)
            {
                shaderProgram=CreateSimpleSpriteShader();
            }

            this.graphics = graphics;

            this.texture = texture;

            this.charaWidth = charaWidth;
            this.charaHeight = charaHeight;

            charaPositions = new float[maxNumOfCharactor * 4 * 3];
            charaTexcoords = new float[maxNumOfCharactor * 4 * 2];
            charaColors = new float[maxNumOfCharactor * 4 * 4];
            charaIndices = new ushort[maxNumOfCharactor * indexSize];

            vertices = new VertexBuffer(maxNumOfCharactor * 4, maxNumOfCharactor * indexSize,
                VertexFormat.Float3, VertexFormat.Float2, VertexFormat.Float4);

            PixelScreenPosition = new Vector3(0.0f, 0.0f, 0.0f);

            ImageRect rectPixelScreen = graphics.GetViewport();

            //@j ピクセルの座標系をスクリーンの座標系に変換する行列。
            //@e Line to convert a pixel coordinate system into a screen coordinate system.
            unitScreenMatrix = new Matrix4(
                 2.0f/rectPixelScreen.Width,	0.0f,	0.0f, 0.0f,
                 0.0f, -2.0f/rectPixelScreen.Height,	0.0f, 0.0f,
                 0.0f,	0.0f, 1.0f, 0.0f,
                -1.0f, 1.0f, 0.0f, 1.0f
            );
        }
开发者ID:simard,项目名称:FloWS,代码行数:35,代码来源:DebugString.cs


示例11: InitGraphicsContext

 public static void InitGraphicsContext()
 {
     if (null != sm_GraphicsContext) {
     return;
     }
     sm_GraphicsContext = new GraphicsContext();
 }
开发者ID:khiraiwa,项目名称:psm-avi_movie_player,代码行数:7,代码来源:AppMain.cs


示例12: Initialize

        public static void Initialize()
        {
            // Set up the graphics system
            graphics = new GraphicsContext ();
            // Set up background sprite
            ImageRect rectScreen = graphics.Screen.Rectangle;
            Console.WriteLine("Screen size: " + rectScreen.Width + " x " + rectScreen.Height);

            texture = new Texture2D("/Application/resources/bg.png", false);
            bgSprite = new Sprite(graphics, texture);
            bgSprite.Position.X = 0.0f; //rectScreen.Width/2.0f;
            bgSprite.Position.Y = 0.0f; //rectScreen.Height/2.0f;
            bgSprite.Position.Z = 0.0f;

            patternGrid = new PatternGrid(graphics, texture, new Vector2(240.0f, 144.0f), new Vector2(720.0f, 400.0f));
            patternGrid.Update(currentPattern);

            textWriter = new Text(graphics, 16.0f);

            m_song.Load("/Documents/songs/flowers1.xds");

            // Start playback thread
            //simStart = false;
            playbackThread = new Thread(new ThreadStart(playbackThreadMain));
            playbackThread.Start();
        }
开发者ID:james7780,项目名称:PXDrumVita,代码行数:26,代码来源:AppMain.cs


示例13: Initialize

		public static void Initialize ()
		{
			// Set up the graphics system
			graphics = new GraphicsContext ();
#if BUILD_FOR_PSV
			program = new ShaderProgram("/Application/shaders/Texture.cgx");
#else
			program = new ShaderProgram("/Application/shaders/Texture_sim.cgx");
#endif
			program.SetUniformBinding(0, "WorldViewProj");
			program.SetAttributeBinding(0, "a_Position");
			program.SetAttributeBinding(1, "a_TexCoord");
			vertices = new VertexBuffer(4, VertexFormat.Float3, VertexFormat.Float2);

			float[] positions = {
				-1.0f, 1.0f, 0.0f,
				-1.0f, -1.0f, 0.0f,
				1.0f, 1.0f, 0.0f,
				1.0f, -1.0f, 0.0f,
			};
			float[] texcoords = {
				0.0f, 0.0f,
				0.0f, 1.0f,
				1.0f, 0.0f,
				1.0f, 1.0f,
			};
			vertices.SetVertices(0, positions);
			vertices.SetVertices(1, texcoords);
			texture = new Texture2D(256, 224, false, PixelFormat.Rgb565);
			
			SampleDraw.Init(graphics);
			
		}
开发者ID:Theswweet,项目名称:PSV-FC,代码行数:33,代码来源:AppMain.cs


示例14: Initialize

        public static void Initialize()
        {
            // Set up the graphics system
            _graphics = new GraphicsContext ();

            _texture = new Texture2D("/Application/32.png", false);

            _spriteBatch = new MonoGameSpriteBatch(_graphics, 256);
            //_spriteBatch = new MonoGameSpriteBatchNoIndex(_graphics, 256);
            //_spriteBatch = new MonoGameSpriteBatchVector3(_graphics, 256);
            //_spriteBatch = new MonoGameSpriteBatchUnpacked(_graphics, 256);

            //_spriteBatch = new DoubleBufferedSpriteBatch(new MonoGameSpriteBatch(_graphics, 256), new MonoGameSpriteBatch(_graphics, 256));
            //_spriteBatch = new TripleBufferedSpriteBatch(new MonoGameSpriteBatch(_graphics, 256), new MonoGameSpriteBatch(_graphics, 256), new MonoGameSpriteBatch(_graphics, 256));

            //_spriteBatch = new DoubleBufferedSpriteBatch(
            //	new DoubleBufferedSpriteBatch(new MonoGameSpriteBatch(_graphics, 256), new MonoGameSpriteBatch(_graphics, 256)),
            //	new DoubleBufferedSpriteBatch(new MonoGameSpriteBatch(_graphics, 256), new MonoGameSpriteBatch(_graphics, 256)));

            //_spriteBatch = new TripleBufferedSpriteBatch(
            //	new TripleBufferedSpriteBatch(new MonoGameSpriteBatch(_graphics, 256), new MonoGameSpriteBatch(_graphics, 256), new MonoGameSpriteBatch(_graphics, 256)),
            //	new TripleBufferedSpriteBatch(new MonoGameSpriteBatch(_graphics, 256), new MonoGameSpriteBatch(_graphics, 256), new MonoGameSpriteBatch(_graphics, 256)),
            //	new TripleBufferedSpriteBatch(new MonoGameSpriteBatch(_graphics, 256), new MonoGameSpriteBatch(_graphics, 256), new MonoGameSpriteBatch(_graphics, 256)));

            //_spriteBatch2 = new MonoGameSpriteBatch(_graphics, 256);
        }
开发者ID:danzel,项目名称:PssSpritePerformanceTests,代码行数:26,代码来源:AppMain.cs


示例15: Filter

        /// フィルタ処理の実行
        public void Filter( GraphicsContext graphics )
        {
            texRenderer.BindGraphicsContext( graphics );
            FrameBuffer oldBuffer = graphics.GetFrameBuffer();

            bool isSwap = false;
            int width = oldBuffer.Width;
            int height = oldBuffer.Height;

            if( this.Target != null ){
            graphics.SetFrameBuffer( this.Target );
            width = this.Target.Width;
            height = this.Target.Height;
            isSwap = true;
            }
            graphics.SetViewport( 0, 0, width, height );

            texRenderer.Begin( shaderDOF );
            graphics.SetTexture( 2, texDepth );
            texRenderer.Render( texScene,
                            texBlur,
                            0, 0, 0, 0, width, height );
            texRenderer.End();
            if( isSwap ){
            graphics.SetFrameBuffer( oldBuffer );
            }
        }
开发者ID:hatano0x06,项目名称:Coroppoxus,代码行数:28,代码来源:DepthOfFealdFilter.cs


示例16: PatternGrid

        public PatternGrid(GraphicsContext graphics, Texture2D texture, Vector2 position, Vector2 size)
        {
            if(shaderProgram == null)
            {
                //shaderProgram=CreateSimpleSpriteShader();
                shaderProgram = new ShaderProgram("/Application/shaders/Sprite.cgx");
                shaderProgram.SetUniformBinding(0, "u_WorldMatrix");
            }

            //if (texture == null)
            //{
            //	throw new Exception("ERROR: texture is null.");
            //}

            this.graphics = graphics;
            //this.texture = texture;
            this.texture = new Texture2D("/Application/resources/textures512.png", false);
            this.width = size.X;
            this.height = size.Y;
            this.origin = position;

            //@e                                                Vertex coordinate,               Texture coordinate,     Vertex color
            //vertexBuffer = new VertexBuffer(4, indexSize, VertexFormat.Float3, VertexFormat.Float2, VertexFormat.Float4);
            vertexBuffer = new VertexBuffer(NUMVERTICES, VertexFormat.Float3, VertexFormat.Float2, VertexFormat.Float4);
        }
开发者ID:james7780,项目名称:PXDrumVita,代码行数:25,代码来源:PatternGrid.cs


示例17: SpriteRenderer

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="maxSprites">The maximum number of sprites which can be batched.</param>
        public SpriteRenderer(GraphicsContext graphics, int maxSprites)
        {
            if (graphics == null)
                throw new ArgumentNullException("graphics");

            if (maxSprites <= 0)
                throw new ArgumentOutOfRangeException("maxSprites", "MaxSprites must be >= 1.");

            this.graphics = graphics;

            this.vertices = new Vertex[maxSprites * 4];

            this.vertexBuffer = new DynamicVertexBuffer<Vertex>(this.graphics);

            ushort[] indices = new ushort[1024 * 6];
            for (ushort i = 0, vertex = 0; i < indices.Length; i += 6, vertex += 4)
            {
                indices[i] = vertex;
                indices[i + 1] = (ushort)(vertex + 1);
                indices[i + 2] = (ushort)(vertex + 3);
                indices[i + 3] = (ushort)(vertex + 1);
                indices[i + 4] = (ushort)(vertex + 2);
                indices[i + 5] = (ushort)(vertex + 3);
            }

            this.indexBuffer = new StaticIndexBuffer<ushort>(this.graphics, indices);

            this.transform = new Matrix4()
            {
                M33 = 1f,
                M44 = 1f,
                M41 = -1f,
                M42 = 1f
            };
        }
开发者ID:smack0007,项目名称:Samurai,代码行数:40,代码来源:SpriteRenderer.cs


示例18: Main

        public static void Main(string[] args)
        {
            //Initialize ();

            GraphicsContext graphics = new GraphicsContext();
            UISystem.Initialize(graphics);

            window = new HighScoreApp.MainWindow();
            UISystem.SetScene(window);
            socket = new Sockets();

            while (true) {
                SystemEvents.CheckEvents();

                List<TouchData> touchData = Touch.GetData(0);
                UISystem.Update (touchData);

                Update ();

                graphics.SetViewport(0, 0, graphics.Screen.Width, graphics.Screen.Height);
                graphics.SetClearColor(new Vector4(0,0,0,1));
                graphics.SetClearDepth(1.0f);
                graphics.Clear();

                UISystem.Render ();
                graphics.SwapBuffers();
            }
        }
开发者ID:Kinnear,项目名称:PS-Vita-GController,代码行数:28,代码来源:AppMain.cs


示例19: CanvasBrush

        public CanvasBrush(GraphicsContext graphics)
        {
            if (graphics == null)
                throw new ArgumentNullException("graphics");

            this.Grahpics = graphics;
        }
开发者ID:HaKDMoDz,项目名称:Samurai,代码行数:7,代码来源:CanvasBrush.cs


示例20: SampleWindow

        public unsafe SampleWindow()
        {
            int desiredWidth = 960, desiredHeight = 540;
            _nativeWindow = new NativeWindow(desiredWidth, desiredHeight, "ImGui.NET", GameWindowFlags.Default, OpenTK.Graphics.GraphicsMode.Default, DisplayDevice.Default);
            _scaleFactor = _nativeWindow.Width / desiredWidth;

            GraphicsContextFlags flags = GraphicsContextFlags.Default;
            _graphicsContext = new GraphicsContext(GraphicsMode.Default, _nativeWindow.WindowInfo, 3, 0, flags);
            _graphicsContext.MakeCurrent(_nativeWindow.WindowInfo);
            ((IGraphicsContextInternal)_graphicsContext).LoadAll(); // wtf is this?
            GL.ClearColor(Color.Black);
            _nativeWindow.Visible = true;
            _nativeWindow.X = _nativeWindow.X; // Work around OpenTK bug (?) on Ubuntu.

            _nativeWindow.KeyDown += OnKeyDown;
            _nativeWindow.KeyUp += OnKeyUp;
            _nativeWindow.KeyPress += OnKeyPress;

            ImGui.GetIO().FontAtlas.AddDefaultFont();

            SetOpenTKKeyMappings();

            _textInputBufferLength = 1024;
            _textInputBuffer = Marshal.AllocHGlobal(_textInputBufferLength);
            long* ptr = (long*)_textInputBuffer.ToPointer();
            for (int i = 0; i < 1024 / sizeof(long); i++)
            {
                ptr[i] = 0;
            }

            CreateDeviceObjects();
        }
开发者ID:mellinoe,项目名称:ImGui.NET,代码行数:32,代码来源:SampleWindow.cs



注:本文中的GraphicsContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# GraphicsContextFlags类代码示例发布时间:2022-05-24
下一篇:
C# Graphics类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap