示例#1
0
        protected override void RenderSelf(GLContext glContext)
        {
            if (_startPoint == null || _vector == null)
                return;

            var endPoint = _startPoint.Clone().Add(_vector.Clone().Scale(Scale));
            LineSegment.RenderLine(_startPoint, endPoint, Color, LineWidth, true);

            var smallVec = endPoint.Clone().Subtract(_startPoint).Normalize().Scale(-10);
            var left = new Vec2(-smallVec.y, smallVec.x);
            var right = new Vec2(smallVec.y, -smallVec.x);
            left.Add(smallVec).Add(endPoint);
            right.Add(smallVec).Add(endPoint);

            LineSegment.RenderLine(endPoint, left, Color, LineWidth, true);
            LineSegment.RenderLine(endPoint, right, Color, LineWidth, true);
        }
示例#2
0
        //------------------------------------------------------------------------------------------------------------------------
        //                                                        Game()
        //------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="GXPEngine.Game"/> class.
        /// This class represents a game window, containing an openGL view.
        /// </summary>
        /// <param name='width'>
        /// Width of the window in pixels.
        /// </param>
        /// <param name='height'>
        /// Height of the window in pixels.
        /// </param>
        /// <param name='fullScreen'>
        /// If set to <c>true</c> the application will run in fullscreen mode.
        /// </param>
        public Game(int pWidth, int pHeight, bool pFullScreen, bool pVSync = true)
            : base()
        {
            if (main != null) {
                throw new Exception ("Only a single instance of Game is allowed");
            } else {

                main = this;
                _updateManager = new UpdateManager ();
                _collisionManager = new CollisionManager ();
                _glContext = new GLContext (this);
                _glContext.CreateWindow (pWidth, pHeight, pFullScreen, pVSync);
                _gameObjectsContained = new List<GameObject>();

                //register ourselves for updates
                Add (this);

            }
        }
示例#3
0
 //------------------------------------------------------------------------------------------------------------------------
 //                                                        RenderSelf()
 //------------------------------------------------------------------------------------------------------------------------
 protected override void RenderSelf(GLContext glContext)
 {
     if (game != null) {
         Vector2[] bounds = GetExtents();
         float maxX = float.MinValue;
         float maxY = float.MinValue;
         float minX = float.MaxValue;
         float minY = float.MaxValue;
         for (int i=0; i<4; i++) {
             if (bounds[i].x > maxX) maxX = bounds[i].x;
             if (bounds[i].x < minX) minX = bounds[i].x;
             if (bounds[i].y > maxY) maxY = bounds[i].y;
             if (bounds[i].y < minY) minY = bounds[i].y;
         }
         bool test = (maxX < 0) || (maxY < 0) || (minX >= game.width) || (minY >= game.height);
         if (test == false) {
             if (blendMode != null) blendMode.enable ();
             _texture.Bind();
             glContext.SetColor((byte)((_color >> 16) & 0xFF),
                                (byte)((_color >> 8) & 0xFF),
                                (byte)(_color & 0xFF),
                                (byte)(_alpha * 0xFF));
             glContext.DrawQuad(GetArea(), _uvs);
             glContext.SetColor(1, 1, 1, 1);
             _texture.Unbind();
             if (blendMode != null) BlendMode.NORMAL.enable();
         }
     }
 }
示例#4
0
 //------------------------------------------------------------------------------------------------------------------------
 //                                                        RenderSelf()
 //------------------------------------------------------------------------------------------------------------------------
 protected override void RenderSelf(GLContext glContext)
 {
     //empty
 }
示例#5
0
        //------------------------------------------------------------------------------------------------------------------------
        //                                                        Render()
        //------------------------------------------------------------------------------------------------------------------------
        protected override void RenderSelf(GLContext glContext)
        {
            if (_invalidate) {
                _texture.UpdateGLTexture ();
                _invalidate = false;
            }

            base.RenderSelf (glContext);
        }
示例#6
0
 //------------------------------------------------------------------------------------------------------------------------
 //                                                        RenderSelf
 //------------------------------------------------------------------------------------------------------------------------
 protected virtual void RenderSelf(GLContext glContext)
 {
     if (visible == false) return;
     glContext.PushMatrix(matrix);
     glContext.PopMatrix();
 }
示例#7
0
        //------------------------------------------------------------------------------------------------------------------------
        //                                                        Render
        //------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// This function is called by the renderer. You can override it to change this object's rendering behaviour.
        /// When not inside the GXPEngine package, specify the parameter as GXPEngine.Core.GLContext.
        /// This function was made public to accomoadate split screen rendering. Use SetViewPort for that.
        /// </summary>
        /// <param name='glContext'>
        /// Gl context, will be supplied by internal caller.
        /// </param>
        public virtual void Render(GLContext glContext)
        {
            if (visible) {
                glContext.PushMatrix(matrix);

                RenderSelf (glContext);
                foreach (GameObject child in GetChildren()) {
                    child.Render(glContext);
                }

                glContext.PopMatrix();
            }
        }
 //------------------------------------------------------------------------------------------------------------------------
 //                                                        RenderSelf()
 //------------------------------------------------------------------------------------------------------------------------
 protected override void RenderSelf(GLContext glContext)
 {
     if (game != null && Start != null && End != null)
     {
         RenderLine(Start, End, Color, LineWidth);
     }
 }