public void Resized(OpenGL gl, double aspect)
        {
            //  Set the projection matrix.
            gl.MatrixMode(OpenGL.GL_PROJECTION);

            //  Load the identity.
            gl.LoadIdentity();

            //  Create a perspective transformation.
            gl.Perspective(60.0f, aspect, 0.01, 100.0);
            CamController.Aspect = aspect;
            //  Use the 'look at' helper function to position and aim the camera.
            CamController.SetCam(gl);

            //  Set the modelview matrix.
            gl.MatrixMode(OpenGL.GL_MODELVIEW);
        }
        public void Update()
        {
            _starUpdateTime.Reset();
            _starUpdateTime.Start();
            _level.Update(settings);
            PhysEngine.PhysInteractions = 0;
            if (!StartupComplete)
            {
                return;
            }
            if (trash.Count > 0)
            {
                for (int i = 0; i < trash.Count; i++)
                {
                    GameObjects.Remove(trash[i]);
                }
                trash.Clear();
            }
            if (toAdd.Count > 0)
            {
                for (int i = 0; i < toAdd.Count; i++)
                {
                    GameObjects.Add(toAdd[i]);
                }
                toAdd.Clear();
                GameObjects.Sort(
                    delegate(GameObject p1, GameObject p2)
                {
                    return(p1.Z_Index.CompareTo(p2.Z_Index));
                }
                    );
            }

            if (!Paused)
            {
                CamController.Update();
                foreach (GameObject obj in GameObjects)
                {
                    obj.Update(settings);
                }
            }
            _starUpdateTime.Stop();
            UpdateTime = (int)_starUpdateTime.ElapsedMilliseconds;
        }
Exemplo n.º 3
0
        public void RenderObjects(OpenGL gl, GameObject[] objects)
        {
            //clears the screen
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            //St matrix mode to PROJECTION so we can move the camera
            gl.MatrixMode(OpenGL.GL_PROJECTION);
            //  Load the identity matrix.
            gl.LoadIdentity();
            //Move the camera
            CamController.SetCam(gl);
            //Set matrix mode back to Modelview so we can draw objects
            gl.MatrixMode(OpenGL.GL_MODELVIEW);

            if (_mode == RenderMode.WireFrame || _mode == RenderMode.Hitboxes)
            {
                foreach (GameObject obj in objects)
                {
                    //Draw the object with texture
                    obj.Draw(gl);
                    //Unbind texture so we can draw lines
                    gl.BindTexture(OpenGL.GL_TEXTURE_2D, 0);
                    if (_mode == RenderMode.Hitboxes)
                    {
                        obj.DrawVelocity(gl);
                        DrawCircle(gl, obj.GetPosition().x, obj.GetPosition().y, obj.GetPhysSize());
                    }
                    else
                    {
                        obj.DrawWireFrame(gl);
                    }
                }
            }
            else
            {
                foreach (GameObject obj in objects)
                {
                    //Draw the object with texture
                    obj.Draw(gl);
                }
            }
            //Unbind texture
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, 0);
        }