ClearColor() public static method

public static ClearColor ( System.Color color ) : void
color System.Color
return void
Exemplo n.º 1
0
        protected override void OnLoad()
        {
            GL.ClearColor(1f, 1f, 1f, 1.0f);

            VertexBufferObject = GL.GenBuffer();
            GL.BindBuffer(BufferTarget.ArrayBuffer, VertexBufferObject);
            GL.BufferData(BufferTarget.ArrayBuffer, vertices.Length * sizeof(float), vertices, BufferUsageHint.StaticDraw);

            VertexArrayObject = GL.GenVertexArray();
            GL.BindVertexArray(VertexArrayObject);
            GL.BindBuffer(BufferTarget.ArrayBuffer, VertexArrayObject);
            GL.BufferData(BufferTarget.ArrayBuffer, vertices.Length * sizeof(float), vertices, BufferUsageHint.StaticDraw);

            ElementBufferObject = GL.GenBuffer();
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, ElementBufferObject);
            GL.BufferData(BufferTarget.ElementArrayBuffer, indices.Length * sizeof(uint), indices, BufferUsageHint.StaticDraw);

            GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 3 * sizeof(float), 0);
            GL.EnableVertexAttribArray(0);

            Shader = new Shader(
                Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"shaders\shader.vert.glsl")),
                Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"shaders\shader.frag.glsl")));

            Shader.Use();

            _timer = new Stopwatch();
            _timer.Start();

            base.OnLoad();
        }
Exemplo n.º 2
0
 private void GLLoad(object sender, EventArgs e)
 {
     _glLoaded = true;
     GL.ClearColor(Color.White);
     SetupViewport();
     _currentWaveFormList = new List <double>();
 }
Exemplo n.º 3
0
 private void _ClearTexture(COGLTexture texture)
 {
     if (texture.DataSize.Equals(texture.Size))
     {
         return;
     }
     GL.BindFramebuffer(OpenTK.Graphics.OpenGL.FramebufferTarget.Framebuffer, _FBO);
     GL.FramebufferTexture2D(OpenTK.Graphics.OpenGL.FramebufferTarget.Framebuffer, OpenTK.Graphics.OpenGL.FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D,
                             texture.Name, 0);
     GL.ClearColor(Color.FromArgb(0));
     GL.Clear(ClearBufferMask.ColorBufferBit);
     GL.ClearColor(Color.Black);
     GL.BindFramebuffer(OpenTK.Graphics.OpenGL.FramebufferTarget.Framebuffer, 0);
 }
Exemplo n.º 4
0
        public override bool Init()
        {
            if (!base.Init())
            {
                return(false);
            }

            // Init Texturing
            GL.Enable(EnableCap.Texture2D);

            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1);

            GL.DepthRange(CSettings.ZFar, CSettings.ZNear);
            GL.DepthFunc(DepthFunction.Lequal);
            GL.Enable(EnableCap.DepthTest);
            GL.ClearColor(Color.Black);

            GL.GenFramebuffers(1, out _FBO);

            return(true);
        }
Exemplo n.º 5
0
 private void Form1_Load(object sender, EventArgs e)
 {
     // Начало обратоки данных из буфера
     _sampleAggregator.FftCalculated += new EventHandler <FftEventArgs>(FftCalculated);
     _sampleAggregator.PerformFFT     = true;
     _waveIn = new WasapiLoopbackCapture();
     _waveIn.DataAvailable += OnDataAvailable;
     _waveIn.StartRecording();
     //Создание таймеров
     _waveformTmr          = new System.Timers.Timer();
     _waveformTmr.Interval = _timeTick;
     _waveformTmr.Elapsed += WaveformTick;
     _FFTTimer             = new System.Timers.Timer();
     _FFTTimer.Interval    = _timeTick;
     _FFTTimer.Elapsed    += FFTTimerTick;
     _FFTTimer.Start();
     //настройка OpenGl
     SetupViewport();
     GL.ClearColor(1f, 1f, 1f, 1f); // цвет фона
     GL.Enable(EnableCap.DepthTest);
     //задать позиции графиков FFT
     Calculation.setFFtNum(_FFTnum);
     //Загрузка текстур для графика FFT
     for (int i = 0; i < 5; i++)
     {
         bmpTex[i] = new Bitmap((i + 1) + ".bmp");
     }
     //Задание маленького начального радиуса
     for (int i = 0; i < 5; i++)
     {
         spectrRadius[i] = 1;
     }
     // заполение коллекции
     for (int i = 0; i < 1024; i++)
     {
         _FFTDataOld.Add(0);
     }
 }
Exemplo n.º 6
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            base.OnRenderFrame(e);
            GL.CullFace(CullFaceMode.Back);
            GL.FrontFace(FrontFaceDirection.Ccw);
            GL.Enable(EnableCap.DepthTest);
            GL.ClearColor(Color.FromArgb(0, 0, 138));
            GL.MatrixMode(MatrixMode.Modelview);


            GL.Enable(EnableCap.Fog);
            GL.Fog(FogParameter.FogMode, (int)FogMode.Linear);
            GL.Fog(FogParameter.FogColor, new float[] { 0.5f, 0.5f, 0.5f, 1.0f });
            GL.Fog(FogParameter.FogDensity, 2000f);
            GL.Hint(HintTarget.FogHint, HintMode.Nicest);
            GL.Fog(FogParameter.FogStart, 1.0f);
            GL.Fog(FogParameter.FogEnd, 4000.0f);

            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            camera.LoadMatrix();
            RenderObjects();
            SwapBuffers();
        }
Exemplo n.º 7
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

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

            GL.Material(TK.MaterialFace.Front, TK.MaterialParameter.Specular, mat_specular);
            GL.Material(TK.MaterialFace.Front, TK.MaterialParameter.Shininess, mat_shininess);
            GL.Light(TK.LightName.Light0, TK.LightParameter.Position, light_position);
            GL.Light(TK.LightName.Light0, TK.LightParameter.Ambient, light_ambient);
            GL.Light(TK.LightName.Light0, TK.LightParameter.Diffuse, mat_specular);

            GL.Enable(TK.EnableCap.CullFace);
            GL.Enable(TK.EnableCap.DepthTest);
            GL.ShadeModel(TK.ShadingModel.Smooth);
            GL.Enable(TK.EnableCap.ColorMaterial);
            GL.Enable(TK.EnableCap.Blend);
            GL.BlendFunc(TK.BlendingFactorSrc.SrcAlpha, TK.BlendingFactorDest.OneMinusSrcAlpha);
            GL.PolygonMode(TK.MaterialFace.FrontAndBack, TK.PolygonMode.Fill);

            GL.Viewport(0, 0, Width, Height);
            aspect_ratio = Width / (float)Height;
            checkAspectRatio();
            width  *= wp_scale_factor;
            height *= wp_scale_factor;

            VSync  = VSyncMode.On;
            eye    = new Vector3(0, 0, height * 1.5f);
            target = new Vector3(0, 0, 0);
            up     = new Vector3(0, 1, 0);
            fov    = (int)Math.Round(height * 0.75f);

            old_mouse = OpenTK.Input.Mouse.GetState();
            old_key   = OpenTK.Input.Keyboard.GetState();

            bodies = new List <Body>();

            generateRandomBodies(number_of_bodies, true);
            calculateGridEdge();
            foreach (Body body in bodies)
            {
                body.updateBoundingSphere();
                body.getBSphere().checkForCellIntersection();
            }

            mouse        = OpenTK.Input.Mouse.GetState();
            coord_transf = Screen.PrimaryScreen.Bounds.Height / 27f;

            timeSinceStart = new Stopwatch();
            timeSinceStart.Start();
            elaspedTime = timeSinceStart.ElapsedMilliseconds;
            Program.cd.InitializePlatformPropertiesAndDevices();
            Program.cd.deviceSpecs();
            Program.cd.ReadAllSources();
            Program.cd.CreateCollisionCellArray();
            Program.t.Start();
            while (Program.ready == false)
            {
                ;
            }
        }
Exemplo n.º 8
0
 public void ClearColor(float red, float green, float blue, float alpha)
 {
     GL.ClearColor(red, green, blue, alpha);
 }
Exemplo n.º 9
0
        private void GlPaint(object sender, PaintEventArgs e)
        {
            if (!_glLoaded)
            {
                return;
            }
            // Color fonColor = Color.FromArgb(_soundColor.R, _soundColor.B, 0);
            _fonStrong = ((_fonStrong * 3) + _total) / 4;
            if (_fonStrong > 1)
            {
                _fonStrong = 1;
            }

            Color fonColor = Color.FromArgb((int)(255 * _fonStrong),
                                            (int)(255 * _fonStrong), (int)(255 * _fonStrong * 0.2));

            GL.ClearColor(fonColor);
            // GL.ClearColor(1f, 1f, 1f, 1f);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            GL.LoadIdentity();

            GL.Disable(EnableCap.Lighting);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            //Прорисoвка круга
            if (Visual1.Colors.Count >= 10)
            {
                Color spin = new Color();
                GL.Begin(PrimitiveType.TriangleFan);
                GL.Color3(Visual1.Colors[0]);
                GL.Color4(Visual1.Colors[0].R, Visual1.Colors[0].G, Visual1.Colors[0].B, (double)0.5);
                GL.Color4(Color.FromArgb(Visual1.Colors[0].A * 0, Visual1.Colors[0].R, Visual1.Colors[0].G, Visual1.Colors[0].B));
                GL.Vertex3(-0, -0, -1);
                GL.Vertex3(Visual1.Coordinates[0].X, Visual1.Coordinates[0].Y, -1);
                for (int i = 0; i < Visual1.Coordinates.Count; i++)
                {
                    if ((i % 4 == 0) && (i > 0))
                    {
                        GL.End();

                        GL.Begin(PrimitiveType.TriangleFan);
                        GL.Vertex3(-0, -0, (float)((double)i / Visual1.Coordinates.Count / 2 - 1));
                        for (int j = i - 3; j < i; j++)
                        {
                            GL.Vertex3(-Visual1.Coordinates[j - 1].X, -Visual1.Coordinates[j - 1].Y,
                                       (float)((double)j / Visual1.Coordinates.Count / 2 - 1));
                        }
                        GL.End();

                        GL.Begin(PrimitiveType.TriangleFan);
                        GL.Vertex3(-0, -0, (float)((double)i / Visual1.Coordinates.Count / 2 - 1));
                        GL.Vertex3(Visual1.Coordinates[i - 1].X, Visual1.Coordinates[i - 1].Y,
                                   (float)((double)i / Visual1.Coordinates.Count / 2 - 1));
                    }

                    GL.Color3(Visual1.Colors[i]);
                    GL.Color4(Visual1.Colors[i].R, Visual1.Colors[i].G, Visual1.Colors[i].B, (double)0.5);
                    GL.Color4(Color.FromArgb((int)((double)i / Visual1.Coordinates.Count * TR * 255), Visual1.Colors[i].R, Visual1.Colors[i].G, Visual1.Colors[i].B));

                    GL.Vertex3(Visual1.Coordinates[i].X, Visual1.Coordinates[i].Y,
                               (float)((double)i / Visual1.Coordinates.Count / 2 - 1));
                }
                GL.End();
            }

            //////конец прорисовки круга

            float[] diffuse = new float[3] {
                0.5f, 0.5f, 0.5f
            };
            GL.Light(LightName.Light0, LightParameter.Diffuse, diffuse);

            float[] ambient = new float[3] {
                4, 4, 4
            };
            GL.Light(LightName.Light0, LightParameter.Ambient, ambient);

            float[] lightPos = new float[4] {
                -glControl1.Width, 0.0f, 10.0f, 1.0f
            };
            GL.Light(LightName.Light0, LightParameter.Position, lightPos);

            float[] specular = new float[4] {
                10, 10, 10, 1
            };
            GL.Light(LightName.Light0, LightParameter.Specular, specular);

            GL.Enable(EnableCap.Lighting);
            GL.Enable(EnableCap.Light0);

            GL.LightModel(LightModelParameter.LightModelTwoSide, 1);

            //звуковой спектр снизу в виде диаграмм
            Random rand = new Random();

            for (int color = 0; color < 5; color++)
            {
                LoadTexture(bmpTex[color]);
                for (int j = 0; j < 50; j++)
                {
                    if (_FFTnum[j] - 1 != color)
                    {
                        continue;
                    }
                    GL.Enable(EnableCap.Texture2D);

                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter,
                                    (int)TextureMinFilter.Nearest);
                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter,
                                    (int)TextureMagFilter.Linear);

                    GL.PolygonMode(MaterialFace.FrontAndBack, mode);
                    GL.Begin(PrimitiveType.QuadStrip);
                    double w = glControl1.Width / 25;

                    float  k = 0.5f;
                    double r = 0.5;
                    int    n = 20;
                    for (int i = 0; i <= n; ++i)
                    {
                        double a = Math.PI / n * i;
                        double x = r * Math.Cos(a);
                        double z = r * Math.Sin(a);
                        GL.TexCoord2(0, 1);
                        GL.Vertex3(x * w + w * j + (w / 2) - glControl1.Width,
                                   -glControl1.Height * (1 - _FFTSpectr[_FFTnum[j] - 1]), z);
                        GL.TexCoord2(1, 0);
                        GL.Vertex3(x * w + w * j + (w / 2) - glControl1.Width, -glControl1.Height, z);

                        if (i > 0)
                        {
                            GL.Normal3(-(x - r * Math.Cos(a - 1)), (x - r * Math.Cos(a - 1)), 0);
                        }
                    }
                    GL.End();
                }
            }

            GL.Disable(EnableCap.Lighting);
            GL.Disable(EnableCap.Texture2D);

            //myThread t1 = new myThread("Thread 1", glControl1.Width, glControl1.Height, firstColorSpectr, spectrRadius,
            //    _FFTSpectr, glControl1);
            //myThread t2 = new myThread("Thread 1", -glControl1.Width, glControl1.Height, firstColorSpectr, spectrRadius,
            //    _FFTSpectr, glControl1);
            //myThread t3 = new myThread("Thread 1", glControl1.Width, -glControl1.Height, firstColorSpectr, spectrRadius,
            //    _FFTSpectr, glControl1);
            //myThread t4 = new myThread("Thread 1", -glControl1.Width, -glControl1.Height, firstColorSpectr, spectrRadius,
            //    _FFTSpectr, glControl1);



            MusicCirsle(glControl1.Width, glControl1.Height, Math.PI, 3 * Math.PI / 2);
            MusicCirsle(-glControl1.Width, glControl1.Height, 3 * Math.PI / 2, 2 * Math.PI);
            MusicCirsle(glControl1.Width, -glControl1.Height, Math.PI / 2, 2 * Math.PI);
            MusicCirsle(-glControl1.Width, -glControl1.Height, 0, Math.PI / 2);

            //GL.Disable(EnableCap.Lighting);



            GL.Disable(EnableCap.Blend);

            GL.Flush();
            //GL.Finish();

            glControl1.SwapBuffers();
        }
Exemplo n.º 10
0
 public static void ClearColor(Color4 color)
 {
     GL.ClearColor(color.R, color.G, color.B, color.A);
 }
Exemplo n.º 11
0
 public static void ClearColor(Color color)
 {
     GL.ClearColor(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f);
 }
Exemplo n.º 12
0
 public static void ClearColor(System.Drawing.Color color)
 {
     GL.ClearColor(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f);
 }
Exemplo n.º 13
0
 public static void ClearColor(LayoutFarm.Drawing.Color color)
 {
     GL.ClearColor(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f);
 }