Beispiel #1
0
        public FormShaderLab()
        {
            InitializeComponent();

            // Initialises OpenGL.
            var renderContext = new FBORenderContext();

            //  Create the render context.
            renderContext.Create(GLVersion.OpenGL2_1, Width, Height, 32, null);
            renderContext.MakeCurrent();

            this.renderContext = renderContext;
        }
        private void CreateRenderContext()
        {
            // Initialises OpenGL.
            var renderContext = new FBORenderContext();

            //  Create the render context.
            renderContext.Create(OpenGLVersion, Width, Height, 32, null);

            this.renderContext = renderContext;

            renderContext.MakeCurrent();

            //  Set the most basic OpenGL styles.
            GL.ShadeModel(GL.GL_SMOOTH);
            // 天蓝色背景
            GL.ClearColor(clearColor.x, clearColor.y, clearColor.z, clearColor.w);
            GL.ClearDepth(1.0f);
            GL.Enable(GL.GL_DEPTH_TEST);
            GL.DepthFunc(GL.GL_LEQUAL);
            GL.Hint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            StringBuilder builder     = new StringBuilder();
            string        time        = DateTime.Now.ToString("yyyyMMdd-HHmmss");
            string        logName     = string.Format("CSharpGL.GLInformation.txt");
            string        logFullname = Path.Combine(Environment.CurrentDirectory, logName);

            // Initialises OpenGL.
            var renderContext = new FBORenderContext();

            //  Create the render context.
            renderContext.Create(GLVersion.OpenGL2_1, 1, 1, 32, null);

            renderContext.MakeCurrent();

            using (StreamWriter sw = new StreamWriter(logFullname, false))
            {
                sw.WriteLine(string.Format("GL version:  {0}", GL.GetString(GL.GL_VERSION)));
                sw.WriteLine(string.Format("GL vendor:   {0}", GL.GetString(GL.GL_VENDOR)));
                sw.WriteLine(string.Format("GL renderer: {0}", GL.GetString(GL.GL_RENDERER)));
                sw.WriteLine();

                //  Set the extensions info.
                var extensions = GL.GetString(GL.GL_EXTENSIONS).Split(
                    new[] { " " }, StringSplitOptions.RemoveEmptyEntries).OrderBy(s => s);
                sw.WriteLine("extensions:");
                sw.WriteLine(string.Join(System.Environment.NewLine, extensions));
                sw.WriteLine();

                //  Set the arb extensions info.
                try
                {
                    sw.WriteLine("ARB extensions:");
                    var arbExtensions = GL.GetExtensionsStringARB(renderContext.DeviceContextHandle).Split(
                        new[] { " " }, StringSplitOptions.RemoveEmptyEntries).OrderBy(s => s);
                    sw.WriteLine(string.Join(System.Environment.NewLine, arbExtensions));
                    sw.WriteLine();
                }
                catch (Exception e)
                {
                    sw.WriteLine("The ARB Extensions cannot be loaded.");
                }

                //  Get each member of the OpenGL object.
                var members = typeof(GL).GetMembers(BindingFlags.NonPublic | BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static);

                //  Go through each member.
                foreach (var member in members)
                {
                    if (member.Name.Substring(0, 2) == "gl" && member.MemberType == MemberTypes.NestedType)
                    {
                        string name      = member.Name;
                        bool   supported = IsExtensionFunctionSupported(name);

                        sw.WriteLine("function: {0} {1}", member.Name, supported ? "Supported" : "Not Supported");
                    }
                }
            }
            //{
            //    builder.AppendFormat("*********************Error occurred!*********************"); builder.AppendLine();
            //    builder.AppendFormat(e.ToString()); builder.AppendLine();
            //}

            //File.WriteAllText(logFullname, builder.ToString());
            Process.Start("explorer", logFullname);
        }