Ejemplo n.º 1
0
        /// <summary>
        /// Call this function to iniatilise a scene loaded from a file.
        /// </summary>
        /// <param name="ctrl">The OpenGLCtrl.</param>
        /// <param name="sceneType">The scene type.</param>
        public virtual void IntialiseFromSerial(int width, int height, SceneType sceneType)
        {
            //	Create OpenGL.
            gl = new OpenGL();
            gl.Create(width, height);

            //	Find out how many lights OpenGL can support.
            int [] umaxlights = new int[1];
            gl.GetInteger(OpenGL.MAX_LIGHTS, umaxlights);

            //	Re-create as many openGL lights as we can.
            for(uint u = 0; u < umaxlights[0]; u++)
            {
                if(u < Lights.Count)
                {
                    Light light = lights[(int)u];
                    light.GLCode = OpenGL.LIGHT0 + u;
                }
            }

            //	Re-create all the quadrics
            foreach(Quadric quadric in quadrics)
                quadric.Create(gl);

            //	Set the scene type.
            SetSceneType(sceneType);

            //	Initialise stock drawing.
            gl.InitialiseStockDrawing();

            //	Set the Scene OpenGL for the quadrics.
            Quadric.SceneOpenGL = OpenGL;
        }