示例#1
0
        private static void RenderFrameEvent(object sender, EventArgs args)
        {
            // clear the window
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            DrawCube.Draw(view);

            // swap back and front buffers
            Window.SwapBuffers();
        }
示例#2
0
        /// <summary>
        /// Initialize CubeViewer
        /// </summary>
        static CubeViewer()
        {
            OpenTK.Toolkit.Init();

            Log.LogStuff("OpenTK initialized.");

            Vector3[] renderColors = new Vector3[]
            {
                new Vector3(255, 106, 0),
                new Vector3(255, 255, 255),
                new Vector3(0, 255, 0),
                new Vector3(255, 255, 0),
                new Vector3(255, 0, 0),
                new Vector3(0, 0, 255)
            };

            for (int i = 0; i < renderColors.Length; i++)
            {
                renderColors[i] /= 255f;
            }

            Log.LogStuff("DrawCube initialized.");

            Window = new GLControl();
            Window.MakeCurrent();
            Window.VSync = false;

            DrawCube.Init(renderColors);

            view = new View(Window.Width, Window.Height,
                            Settings.CameraFov, Settings.CameraDistance);

            Log.LogStuff("Window and view initialized.");

            GL.Enable(EnableCap.DepthTest);
            GL.ClearColor(Color.Black);

            // add events to window
            Window.Resize += WindowResizeEvent;
            Window.Paint  += RenderFrameEvent;
            AttachInputEvents();
        }