Esempio n. 1
0
        private static void OnClose()
        {
            CarModel.cube.Dispose();
            CarModel.cubeNormals.Dispose();
            CarModel.cubeUV.Dispose();
            CarModel.cubeQuads.Dispose();
            CarModel.bodyTexture.Dispose();
            CarModel.kacaTexture.Dispose();
            CarModel.rodaTexture.Dispose();

            Rain.OnClose();
            Smoke.OnClose();
            program.DisposeChildren = true;
            program.Dispose();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            wplayer.URL = "song.mp3";
            wplayer.controls.stop();

            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH | Glut.GLUT_MULTISAMPLE);
            Glut.glutInitWindowSize(width, height);
            Glut.glutCreateWindow("UAS IF3260 - Grafika Komputer");

            Glut.glutIdleFunc(OnRenderFrame);
            Glut.glutDisplayFunc(OnDisplay);

            Glut.glutKeyboardFunc(OnKeyboardDown);
            Glut.glutKeyboardUpFunc(OnKeyboardUp);
            Glut.glutMouseWheelFunc(MouseWheel);

            Glut.glutCloseFunc(OnClose);
            Glut.glutReshapeFunc(OnReshape);

            Gl.Enable(EnableCap.DepthTest);
            Gl.Enable(EnableCap.Multisample);
            Gl.Enable(EnableCap.ProgramPointSize);
            Gl.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.One);

            program = new ShaderProgram(VertexShader, FragmentShader);

            program.Use();
            program["projection_matrix"].SetValue(Matrix4.CreatePerspectiveFieldOfView(0.45f, (float)width / height, 0.1f, 1000f));
            program["view_matrix"].SetValue(Matrix4.LookAt(new Vector3(0, 0, 6), new Vector3(1.2f, 0.2f, 0f), new Vector3(0, 1, 0)));

            program["light_direction"].SetValue(new Vector3(0, 0, 1));
            program["enable_lighting"].SetValue(lighting);

            carmodel = new CarModel();
            rain     = new Rain();
            smoke    = new Smoke();

            watch = System.Diagnostics.Stopwatch.StartNew();
            Glut.glutMainLoop();
        }