示例#1
0
        public _GraphicsContext()
        {
            addaddrfunc = addaddrfunc ?? (GraphicsContext.GetAddressDelegate) typeof(Utilities).InvokePrivateStatic("CreateGetAddress");

            this.ctx = new GraphicsContext(new ContextHandle(), addaddrfunc, FrameFactory.getcurrentfunc);

            this.ctx.LoadAll();

            int major, minor;

            GL.GetInteger(GetPName.MajorVersion, out major);
            GL.GetInteger(GetPName.MinorVersion, out minor);

            Console.WriteLine("Major {0}\nMinor {1}", major, minor);

            Console.WriteLine($"Context-Handle {FrameFactory.getcurrentfunc()}");
        }
示例#2
0
        internal OpenTKRenderer(FrameFactory owner, IXwtRender xwtrender, Xwt.Canvas window, IRenderOwner renderer, size videosize)
        {
            //    OpenTKRenderer.usecnt = 1;
            this.owner     = owner;
            this.Xwt       = xwtrender;
            this.videosize = videosize;
            this.window    = window;
            this.renderer  = renderer;

            this.viewsize         = window.Size;
            window.BoundsChanged += viewsizechanged;

            this.actionthread = new Thread(run)
            {
                Name = "opentk"
            };
            this.actionthread.Start();

            var _this = this;

            this.Xwt.CreateForWidgetContext(this, this.renderer, window);

            // Invoke(() =>
            //  {
            this.Lock(false);
            try
            {
                try
                {
                    //        GL.GetInternalformat(TextureTarget.Texture2D, SizedInternalFormat.Rgba8, InternalFormatParameter..TEXTUREIMAGEFORMAT, 1, &preferred_format).

                    this.vertices1 = new vertices(_vertices);
                    this.vertices2 = new vertices(_vertices2);

                    /*   GL.GenBuffers(1, out buf_vertices2); // Generate 1 buffer
                     * GL.BindBuffer(BufferTarget.ArrayBuffer, buf_vertices2);
                     * GL.VertexAttribPointer(0, 2, VertexAttribPointerType.Float, false, 4 * sizeof(float), 0);
                     * GL.VertexAttribPointer(1, 2, VertexAttribPointerType.Float, false, 4 * sizeof(float), 2 * sizeof(float));
                     * GL.BufferData(BufferTarget.ArrayBuffer, sizeof(float) * vertices2.Length, vertices2, BufferUsageHint.StaticDraw);
                     * GL.EnableVertexAttribArray(0);
                     * GL.EnableVertexAttribArray(1);
                     *
                     * GL.GenBuffers(1, out buf_vertices3); // Generate 1 buffer
                     * GL.BindBuffer(BufferTarget.ArrayBuffer, buf_vertices3);
                     * GL.VertexAttribPointer(0, 2, VertexAttribPointerType.Float, false, 4 * sizeof(float), 0);
                     * GL.VertexAttribPointer(1, 2, VertexAttribPointerType.Float, false, 4 * sizeof(float), 2 * sizeof(float));
                     * GL.BufferData(BufferTarget.ArrayBuffer, sizeof(float) * vertices3.Length, vertices3, BufferUsageHint.StaticDraw);
                     * GL.EnableVertexAttribArray(0);
                     * GL.EnableVertexAttribArray(1);*/

                    //     GL.BindBuffer(BufferTarget.ArrayBuffer, 0);

                    /*    this.presentshader = new shader(shadervertex, shaderfragment, vertices1);
                     *  GL.UseProgram(this.presentshader);
                     *  var pos = GL.GetUniformLocation(this.presentshader, "tex");
                     *  GL.Uniform1(pos, 0);
                     */
                    /*             this.combineshader = new shader(combineshadervertex, combineshaderfragment, vertices1);
                     *
                     *           GL.UseProgram(combineshader);
                     *           var pos = GL.GetUniformLocation(this.combineshader, "tex");
                     *           GL.Uniform1(pos, 0);
                     *           pos = GL.GetUniformLocation(this.combineshader, "vpHeight");
                     *           GL.Uniform1(pos, (float)videosize.height);
                     *
                     *           this.deinterlaceblendshader = new shader(combineshadervertex, blendshaderfragment, vertices1);
                     *           GL.UseProgram(deinterlaceblendshader);
                     *           pos = GL.GetUniformLocation(this.deinterlaceblendshader, "vpHeight");
                     *           GL.Uniform1(pos, (float)videosize.height);
                     *
                     *           this.deinterlacesplitshader = new shader(combineshadervertex, splitshaderfragment, vertices1);
                     *
                     *           GL.UseProgram(deinterlacesplitshader);
                     *           pos = GL.GetUniformLocation(this.deinterlacesplitshader, "vpHeight");
                     *           GL.Uniform1(pos, (float)videosize.height);*/
                }
                catch (Exception e)
                {
                    //         Log.LogException(e);
                    Dispose(true);
                    GC.SuppressFinalize(this);
                    throw;
                }
            }
            finally
            {
                Unlock(false);
            }
            //   });
        }