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


C# OpenGL.ClearColor方法代碼示例

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


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

示例1: Initialise

        /// <summary>
        /// Initialises the scene.
        /// </summary>
        /// <param name="gl">The OpenGL instance.</param>
        /// <param name="width">The width of the screen.</param>
        /// <param name="height">The height of the screen.</param>
        public void Initialise(OpenGL gl, float width, float height)
        {
            //  Set a blue clear colour.
            gl.ClearColor(0.4f, 0.6f, 0.9f, 0.0f);

            //  Create the shader program.
            var vertexShaderSource = ManifestResourceLoader.LoadTextFile("Shader.vert");
            var fragmentShaderSource = ManifestResourceLoader.LoadTextFile("Shader.frag");
            shaderProgram = new ShaderProgram();
            shaderProgram.Create(gl, vertexShaderSource, fragmentShaderSource, null);
            shaderProgram.BindAttributeLocation(gl, attributeIndexPosition, "in_Position");
            shaderProgram.BindAttributeLocation(gl, attributeIndexColour, "in_Color");
            shaderProgram.AssertValid(gl);

            //  Create a perspective projection matrix.
            const float rads = (60.0f / 360.0f) * (float)Math.PI * 2.0f;
            projectionMatrix = glm.perspective(rads, width / height, 0.1f, 100.0f);

            //  Create a view matrix to move us back a bit.
            viewMatrix = glm.translate(new mat4(1.0f), new vec3(0.0f, 0.0f, -5.0f));

            //  Create a model matrix to make the model a little bigger.
            modelMatrix = glm.scale(new mat4(1.0f), new vec3(2.5f));

            //  Now create the geometry for the square.
            CreateVerticesForSquare(gl);
        }
開發者ID:hhool,項目名稱:sharpgl,代碼行數:33,代碼來源:Scene.cs

示例2: Initialise

        public void Initialise(OpenGL gl)
        {
            //  Create the per pixel shader.
            shaderPerPixel = new ShaderProgram();
            shaderPerPixel.Create(gl, 
                ManifestResourceLoader.LoadTextFile(@"Shaders\PerPixel.vert"),
                ManifestResourceLoader.LoadTextFile(@"Shaders\PerPixel.frag"), null);
            shaderPerPixel.BindAttributeLocation(gl, VertexAttributes.Position, "Position");
            shaderPerPixel.BindAttributeLocation(gl, VertexAttributes.Normal, "Normal");
            gl.ClearColor(0f,0f, 0f, 1f);

            //  Immediate mode only features!
            gl.Enable(OpenGL.GL_TEXTURE_2D);
        }
開發者ID:rhynodegreat,項目名稱:sharpgl,代碼行數:14,代碼來源:Scene.cs

示例3: Initialize

        public void Initialize(OpenGL gl)
        {
            this.gl = gl;

            gl.Enable(OpenGL.GL_DEPTH_TEST);
            gl.DepthFunc(DepthFunction.LessThanOrEqual);
            gl.ClearDepth(1.0);

            gl.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);

            gl.Hint(HintTarget.PerspectiveCorrection, HintMode.Nicest);
            gl.Hint(HintTarget.LineSmooth,            HintMode.Nicest);
            gl.Hint(HintTarget.PointSmooth,           HintMode.Nicest);
            gl.Hint(HintTarget.PolygonSmooth,         HintMode.Nicest);

            gl.Enable(OpenGL.GL_SMOOTH);
            gl.Enable(OpenGL.GL_LINE_SMOOTH);
            gl.Enable(OpenGL.GL_POINT_SMOOTH);
            gl.Enable(OpenGL.GL_MULTISAMPLE);

            gl.MinSampleShading(4.0f);
        }
開發者ID:jtdubs,項目名稱:VoxelLand,代碼行數:22,代碼來源:Renderer.cs

示例4: SetClearColor

 public void SetClearColor(OpenGL _context, Color _color)
 {
     _context.ClearColor(_color.R, _color.G, _color.B, _color.A);
 }
開發者ID:mkramers,項目名稱:Projects,代碼行數:4,代碼來源:MainWindow.xaml.cs

示例5: OnRender

 public override void OnRender(OpenGL gl)
 {
     gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
     gl.ClearColor(0.137f, 0.121f, 0.125f, 0f);
     _graph.Render();
 }
開發者ID:veggielane,項目名稱:OpenCAD_old,代碼行數:6,代碼來源:ModelControl.cs

示例6: StartRendering

        /// <summary>
        /// Create device and renderbuffer, initialize NV_DX_interop and start rendering.
        /// </summary>
        private void StartRendering()
        {
            _gl = new OpenGL();

            _hwnd = new HwndSource(0, 0, 0, 0, 0, "test", IntPtr.Zero).Handle;

            _gl.Create(SharpGL.Version.OpenGLVersion.OpenGL2_1, RenderContextType.HiddenWindow, 1, 1, 32, _hwnd);

            //  Set the most basic OpenGL styles.
            _gl.ShadeModel(OpenGL.GL_SMOOTH);
            _gl.ClearColor(0.0f, 0.0f, 0.0f, 1.0f);
            _gl.ClearDepth(1.0f);

            _gl.Enable(OpenGL.GL_BLEND);
            _gl.Disable(OpenGL.GL_DEPTH_TEST);

            _gl.Enable(OpenGL.GL_TEXTURE_2D);
            _gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_REPLACE);

            _gl.BlendFunc(OpenGL.GL_SRC_ALPHA, OpenGL.GL_ONE_MINUS_SRC_ALPHA);

            //_gl.Enable(OpenGL.GL_MULTISAMPLE);
            //_gl.Enable(OpenGL.GL_MULTISAMPLE_ARB);

            _gl.Hint(0x8534, OpenGL.GL_FASTEST);

            ResizeRendering();

            // leverage the Rendering event of WPF's composition target to
            // update the custom D3D scene
            CompositionTarget.Rendering += OnRenderOpenGL;

            if (GLInitialize != null)
                GLInitialize(this, new EventArgs());
        }
開發者ID:LittleFox94,項目名稱:sharpgl,代碼行數:38,代碼來源:FastGLControl.xaml.cs

示例7: OnRender

        public override void OnRender(OpenGL gl)
        {
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            gl.ClearColor(0.137f, 0.121f, 0.125f, 0f);

            _graph.Render();

            gl.Disable(OpenGL.GL_DEPTH_TEST);
            using (new Bind(_shader))
            {
                gl.UniformMatrix4(_modelUniform, 1, false, Mat4.Identity.ToColumnMajorArray());

                gl.PointSize(10f);
                gl.Begin(BeginMode.Points);
                gl.Vertex(6, 0);
                gl.End();
            }

            gl.PointSize(5f);

            _points.Render();
            gl.Enable(OpenGL.GL_DEPTH_TEST);
        }
開發者ID:rho24,項目名稱:OpenCAD,代碼行數:23,代碼來源:ModelControl.cs


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