예제 #1
0
        public Program()
        {
            WriteSystemInformation();

            Window         = new GameWindow(1600, 900, new OpenTK.Graphics.GraphicsMode(32, 24, 0, 8), "Rubix Cube", GameWindowFlags.Default);
            Window.VSync   = VSyncMode.Off;
            Window.Resize += Window_Resize;
            Window.TargetRenderFrequency = 60;
            Window.TargetUpdateFrequency = 60;
            Window.UpdateFrame          += Window_UpdateFrame;
            Window.RenderFrame          += Window_RenderFrame;
            Window.MouseDown            += Window_MouseDown;
            Window.MouseUp    += Window_MouseUp;
            Window.MouseMove  += Window_MouseMove;
            Window.MouseWheel += Window_MouseWheel;
            Window.KeyDown    += Window_KeyDown;

            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.Texture2D);

            ObjLoader loader = new ObjLoader();

            var vao = loader.loadVBOS("Content/cube-part.obj", 3);

            Matrix4 proj = Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(80), 108f / 72, .1f, 100);

            shader = new ShaderProgram("Shaders/shader.vert", "Shaders/shader.frag", "default");
            shader.Use();
            shader.setUniform("proj", proj);

            pickShader = new ShaderProgram("Shaders/pick.vert", "Shaders/pick.frag", "pick");
            pickShader.Use();
            pickShader.setUniform("proj", proj);

            Texture txt = new Texture("Content/txt.bmp");

            addCubes(vao, txt, shader);

            camera            = new Camera(10);
            camera.Projection = proj;
            camera.setDepth(0, 20);

            cubeState = new CubeState();

            Texture cubeTexture = new Texture();

            cubeTexture.loadAsCubeMap("Content/Cubemap/");

            skybox = new SkyBox(cubeTexture.Id);

            animationManager = new AnimationManager(60, AnimaitonDuration, CubeDistance, parts, cubeState);
            animationManager.AnimationSequenceFinished += animationManager_AnimationSequenceFinished;
            animationManager.AnimationFinished         += AnimationManager_AnimationFinished;

            Window.Run(60);
        }