コード例 #1
0
        //Called after the window and OpenGL are initialized. Called exactly once, before the main loop.
        protected override void init()
        {
            g_fzNear = 1.0f;
            g_fzFar = 1000.0f;
            InitializeGInitialViewData();
            InitializeGViewScale();
            g_viewPole = new ViewPole(g_initialViewData, g_viewScale, MouseButtons.MB_LEFT_BTN);
            g_objtPole = new ObjectPole(g_initialObjectData, (float)(90.0f / 250.0f),
                    MouseButtons.MB_RIGHT_BTN, g_viewPole);

            InitializeProgram();

            try
            {
                string XmlFilesDirectory = GlsTutorialsClass.ProjectDirectory + @"/XmlFilesForMeshes";
                Stream unitcylinder = File.OpenRead(XmlFilesDirectory  + @"/unitcylinder9.xml");
                g_pCylinderMesh = new Mesh(unitcylinder);
                Stream unitplane = File.OpenRead(XmlFilesDirectory + @"/largeplane9.xml");
                g_pPlaneMesh = new Mesh(unitplane);
            }
            catch(Exception ex)
            {
                throw new Exception("Error:" + ex.ToString());
            }

            SetupDepthAndCull();

            reshape();
        }
コード例 #2
0
        //Called after the window and OpenGL are initialized. Called exactly once, before the main loop.
        protected override void init()
        {
            g_fzNear = 1.0f;
            g_fzFar = 1000.0f;
            InitializeGInitialViewData();
            InitializeGViewScale();
            g_viewPole = new ViewPole(g_initialViewData, g_viewScale, MouseButtons.MB_LEFT_BTN);
            g_objtPole = new ObjectPole(g_initialObjectData, (float)(90.0f / 250.0f),
                    MouseButtons.MB_RIGHT_BTN, g_viewPole);

            InitializePrograms();

            try
            {
                string XmlFilesDirectory = GlsTutorialsClass.ProjectDirectory + @"/XmlFilesForMeshes";
                Stream Infinity =  File.OpenRead(XmlFilesDirectory + @"/infinity.xml");
                g_pObjectMesh = new Mesh(Infinity);
                Stream UnitCube =  File.OpenRead(XmlFilesDirectory + @"/unitcubebasictexture.xml");
                g_pCubeMesh = new Mesh(UnitCube);
            }
            catch(Exception ex)
            {
                MessageBox.Show("Error creating meshes " + ex.ToString());
                throw;
            }

            SetupDepthAndCull();
            MatrixStack.rightMultiply = false;
            reshape();
            GL.Enable(EnableCap.Texture1D);

            //Setup our Uniform Buffers
            MaterialBlock mtl = new MaterialBlock();
            mtl.diffuseColor = new Vector4(1.0f, 0.673f, 0.043f, 1.0f);
            mtl.specularColor = new Vector4(1.0f, 0.673f, 0.043f, 1.0f) * 0.4f;
            mtl.specularShininess = g_specularShininess;

            g_litShaderProg.materialBlock.Update(mtl);
            g_litTextureProg.materialBlock.Update(mtl);

            CreateGaussianTextures();
        }