Esempio n. 1
0
 static void Main(string[] args)
 {
     using (var window = new RenderingWindow())
     {
         window.Run();
     }
 }
Esempio n. 2
0
        private void InitializeGraphics()
        {
            try
            {
                // platform graphics setup
                this.RenderingWindow = new RenderingWindow();
                this.RenderingWindow.Show();

                this.DisplayManager = new DisplayManager();

                this.PlatformManager = new PlatformGraphicsManager(this.DisplayManager.GetDisplay(this.RenderingWindow));

                this.PlatformManager.BindApi(Api.EGL_OPENGL_ES_API);

                var attribs = new Attribs <ConfigAttributes>();

                this.OnConfigureAttributes(attribs);

                var config = this.PlatformManager.ChooseConfigs(attribs, 1).FirstOrDefault();

                if (config == null)
                {
                    throw new InvalidOperationException("Could not find matching configuration");
                }

                this.RenderingContext = this.PlatformManager.CreateContext(config, ContextVersion.OPENGL_ES_2);

                this.RenderingSurface = this.PlatformManager.CreateWindowSurface(config, this.RenderingWindow);

                this.RenderingContext.MakeCurrent(this.RenderingSurface, this.RenderingSurface);

                // graphics device setup
                this.GraphicsDevice = new GraphicsDevice
                {
                    ClearColor = new Vector4(1, 1, 1, 1f),
                    Viewport   = new Rectangle(
                        0,
                        0,
                        this.RenderingWindow.Width,
                        this.RenderingWindow.Height)
                };

                var error = NativeGl.glGetError();

                if (error != NativeGl.GL_NO_ERROR)
                {
                    throw new InvalidOperationException("Error while initializing graphics.");
                }
            }
            catch (PlatformGraphicsException x)
            {
                MessageBox.Show(x.ToString());
                this.ExitGame = true;
            }
        }