Ejemplo n.º 1
0
        static void Main()
        {
            try {
                string envDebug = Environment.GetEnvironmentVariable("DEBUG");

                if (envDebug == "GL")
                {
                    KhronosApi.RegisterApplicationLogDelegate(delegate(string format, object[] args) {
                        Console.WriteLine(format, args);
                    });
                }

                // RPi runs on EGL
                Egl.IsRequired = true;

                if (Egl.IsAvailable == false)
                {
                    throw new InvalidOperationException("EGL is not available. Aborting.");
                }

                using (VideoCoreWindow nativeWindow = new VideoCoreWindow()) {
                    using (DeviceContext eglContext = DeviceContext.Create(nativeWindow.Display, nativeWindow.Handle)) {
                        eglContext.ChoosePixelFormat(new DevicePixelFormat(32));

                        IntPtr glContext = eglContext.CreateContext(IntPtr.Zero);

                        eglContext.MakeCurrent(glContext);

                        Initialize();

                        Gl.Viewport(0, 0, 1920, 1080);
                        Gl.ClearColor(0.0f, 0.0f, 0.0f, 1.0f);

                        while (true)
                        {
                            Gl.Clear(ClearBufferMask.ColorBufferBit);
                            Draw();
                            eglContext.SwapBuffers();
                            break;
                        }

                        System.Threading.Thread.Sleep(10000);

                        Terminate();
                        eglContext.DeleteContext(glContext);
                    }
                }
            } catch (Exception exception) {
                Console.WriteLine(exception.ToString());
            }
        }
Ejemplo n.º 2
0
        static void Main()
        {
            string envDebug = Environment.GetEnvironmentVariable("DEBUG");

            if (envDebug == "GL")
            {
                KhronosApi.RegisterApplicationLogDelegate(delegate(string format, object[] args) {
                    Console.WriteLine(format, args);
                });
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new SampleForm());
        }